150
|
1 " Vim syntax file
|
|
2 " Language: mlir
|
|
3 " Maintainer: The MLIR team, http://github.com/tensorflow/mlir/
|
|
4 " Version: $Revision$
|
|
5 " Some parts adapted from the LLVM vim syntax file.
|
|
6
|
|
7 if version < 600
|
|
8 syntax clear
|
|
9 elseif exists("b:current_syntax")
|
|
10 finish
|
|
11 endif
|
|
12
|
|
13 syn case match
|
|
14
|
|
15 " Types.
|
221
|
16 "
|
236
|
17 syn keyword mlirType index f16 f32 f64 bf16
|
221
|
18 " Signless integer types.
|
150
|
19 syn match mlirType /\<i\d\+\>/
|
221
|
20 " Unsigned integer types.
|
|
21 syn match mlirType /\<ui\d\+\>/
|
|
22 " Signed integer types.
|
|
23 syn match mlirType /\<si\d\+\>/
|
150
|
24
|
|
25 " Elemental types inside memref, tensor, or vector types.
|
236
|
26 syn match mlirType /x\s*\zs\(bf16|f16\|f32\|f64\|i\d\+\|ui\d\+\|si\d\+\)/
|
150
|
27
|
|
28 " Shaped types.
|
|
29 syn match mlirType /\<memref\ze\s*<.*>/
|
|
30 syn match mlirType /\<tensor\ze\s*<.*>/
|
|
31 syn match mlirType /\<vector\ze\s*<.*>/
|
|
32
|
|
33 " vector types inside memref or tensor.
|
|
34 syn match mlirType /x\s*\zsvector/
|
|
35
|
|
36 " Operations.
|
221
|
37 " TODO: this list is not exhaustive.
|
|
38 syn keyword mlirOps alloc alloca addf addi and call call_indirect cmpf cmpi
|
|
39 syn keyword mlirOps constant dealloc divf dma_start dma_wait dim exp
|
|
40 syn keyword mlirOps getTensor index_cast load log memref_cast
|
|
41 syn keyword mlirOps memref_shape_cast mulf muli negf powf prefetch rsqrt sitofp
|
|
42 syn keyword mlirOps splat store select sqrt subf subi subview tanh
|
|
43 syn keyword mlirOps view
|
150
|
44
|
236
|
45 " Math ops.
|
|
46 syn match mlirOps /\<math\.erf\>/
|
|
47
|
150
|
48 " Affine ops.
|
|
49 syn match mlirOps /\<affine\.apply\>/
|
|
50 syn match mlirOps /\<affine\.dma_start\>/
|
|
51 syn match mlirOps /\<affine\.dma_wait\>/
|
|
52 syn match mlirOps /\<affine\.for\>/
|
|
53 syn match mlirOps /\<affine\.if\>/
|
|
54 syn match mlirOps /\<affine\.load\>/
|
221
|
55 syn match mlirOps /\<affine\.parallel\>/
|
150
|
56 syn match mlirOps /\<affine\.prefetch\>/
|
|
57 syn match mlirOps /\<affine\.store\>/
|
223
|
58 syn match mlirOps /\<scf\.execute_region\>/
|
|
59 syn match mlirOps /\<scf\.for\>/
|
|
60 syn match mlirOps /\<scf\.if\>/
|
|
61 syn match mlirOps /\<scf\.yield\>/
|
150
|
62
|
|
63 " TODO: dialect name prefixed ops (llvm or std).
|
|
64
|
|
65 " Keywords.
|
|
66 syn keyword mlirKeyword
|
221
|
67 \ affine_map
|
|
68 \ affine_set
|
150
|
69 \ dense
|
|
70 \ else
|
|
71 \ func
|
|
72 \ module
|
|
73 \ return
|
|
74 \ step
|
|
75 \ to
|
|
76
|
|
77 " Misc syntax.
|
|
78
|
|
79 syn match mlirNumber /-\?\<\d\+\>/
|
|
80 " Match numbers even in shaped types.
|
|
81 syn match mlirNumber /-\?\<\d\+\ze\s*x/
|
|
82 syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
|
|
83
|
|
84 syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
|
|
85 syn match mlirFloat /\<0x\x\+\>/
|
|
86 syn keyword mlirBoolean true false
|
236
|
87 " Spell checking is enabled only in comments by default.
|
|
88 syn match mlirComment /\/\/.*$/ contains=@Spell
|
150
|
89 syn region mlirString start=/"/ skip=/\\"/ end=/"/
|
|
90 syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
|
236
|
91 " Prefixed identifiers usually used for ssa values and symbols.
|
150
|
92 syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
|
236
|
93 syn match mlirIdentifier /[%@]\d\+\>/
|
|
94 " Prefixed identifiers usually used for blocks.
|
|
95 syn match mlirBlockIdentifier /\^[a-zA-Z$._-][a-zA-Z0-9$._-]*/
|
|
96 syn match mlirBlockIdentifier /\^\d\+\>/
|
|
97 " Prefixed identifiers usually used for types.
|
|
98 syn match mlirTypeIdentifier /![a-zA-Z$._-][a-zA-Z0-9$._-]*/
|
|
99 syn match mlirTypeIdentifier /!\d\+\>/
|
|
100 " Prefixed identifiers usually used for attribute aliases and result numbers.
|
|
101 syn match mlirAttrIdentifier /#[a-zA-Z$._-][a-zA-Z0-9$._-]*/
|
|
102 syn match mlirAttrIdentifier /#\d\+\>/
|
150
|
103
|
|
104 " Syntax-highlight lit test commands and bug numbers.
|
|
105 syn match mlirSpecialComment /\/\/\s*RUN:.*$/
|
|
106 syn match mlirSpecialComment /\/\/\s*CHECK:.*$/
|
|
107 syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
|
|
108 syn match mlirSpecialComment /\/\/\s*expected-error.*$/
|
|
109 syn match mlirSpecialComment /\/\/\s*expected-remark.*$/
|
|
110 syn match mlirSpecialComment /;\s*XFAIL:.*$/
|
|
111 syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/
|
|
112 syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/
|
|
113
|
|
114 if version >= 508 || !exists("did_c_syn_inits")
|
|
115 if version < 508
|
|
116 let did_c_syn_inits = 1
|
|
117 command -nargs=+ HiLink hi link <args>
|
|
118 else
|
|
119 command -nargs=+ HiLink hi def link <args>
|
|
120 endif
|
|
121
|
|
122 HiLink mlirType Type
|
|
123 HiLink mlirOps Statement
|
|
124 HiLink mlirNumber Number
|
|
125 HiLink mlirComment Comment
|
|
126 HiLink mlirString String
|
|
127 HiLink mlirLabel Label
|
|
128 HiLink mlirKeyword Keyword
|
|
129 HiLink mlirBoolean Boolean
|
|
130 HiLink mlirFloat Float
|
|
131 HiLink mlirConstant Constant
|
|
132 HiLink mlirSpecialComment SpecialComment
|
|
133 HiLink mlirIdentifier Identifier
|
236
|
134 HiLink mlirBlockIdentifier Label
|
|
135 HiLink mlirTypeIdentifier Type
|
|
136 HiLink mlirAttrIdentifier PreProc
|
150
|
137
|
|
138 delcommand HiLink
|
|
139 endif
|
|
140
|
|
141 let b:current_syntax = "mlir"
|