3 " Maintainer: The MLIR team, http://github.com/tensorflow/mlir/
5 " Some parts adapted from the LLVM vim syntax file.
9 elseif exists("b:current_syntax")
17 syn keyword mlirType index f16 f32 f64 bf16
18 " Signless integer types.
19 syn match mlirType /\<i\d\+\>/
20 " Unsigned integer types.
21 syn match mlirType /\<ui\d\+\>/
22 " Signed integer types.
23 syn match mlirType /\<si\d\+\>/
25 " Elemental types inside memref, tensor, or vector types.
26 syn match mlirType /x\s*\zs\(bf16|f16\|f32\|f64\|i\d\+\|ui\d\+\|si\d\+\)/
29 syn match mlirType /\<memref\ze\s*<.*>/
30 syn match mlirType /\<tensor\ze\s*<.*>/
31 syn match mlirType /\<vector\ze\s*<.*>/
33 " vector types inside memref or tensor.
34 syn match mlirType /x\s*\zsvector/
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
46 syn match mlirOps /\<math\.erf\>/
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\>/
55 syn match mlirOps /\<affine\.parallel\>/
56 syn match mlirOps /\<affine\.prefetch\>/
57 syn match mlirOps /\<affine\.store\>/
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\>/
63 " TODO: dialect name prefixed ops (llvm or std).
66 syn keyword mlirKeyword
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/
84 syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
85 syn match mlirFloat /\<0x\x\+\>/
86 syn keyword mlirBoolean true false
87 " Spell checking is enabled only in comments by default.
88 syn match mlirComment /\/\/.*$/ contains=@Spell
89 syn region mlirString start=/"/ skip=/\\"/ end=/"/
90 syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
91 " Prefixed identifiers usually used for ssa values and symbols.
92 syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
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\+\>/
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:.*$/
114 if version >= 508 || !exists("did_c_syn_inits")
116 let did_c_syn_inits = 1
117 command -nargs=+ HiLink hi link <args>
119 command -nargs=+ HiLink hi def link <args>
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
134 HiLink mlirBlockIdentifier Label
135 HiLink mlirTypeIdentifier Type
136 HiLink mlirAttrIdentifier PreProc
141 let b:current_syntax = "mlir"