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 "
|
150
|
17 syn keyword mlirType index f16 f32 f64
|
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.
|
221
|
26 syn match mlirType /x\s*\zs\(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 " Standard dialect ops.
|
|
38 " TODO: this list is not exhaustive.
|
|
39 syn keyword mlirOps alloc alloca addf addi and call call_indirect cmpf cmpi
|
|
40 syn keyword mlirOps constant dealloc divf dma_start dma_wait dim exp
|
|
41 syn keyword mlirOps getTensor index_cast load log memref_cast
|
|
42 syn keyword mlirOps memref_shape_cast mulf muli negf powf prefetch rsqrt sitofp
|
|
43 syn keyword mlirOps splat store select sqrt subf subi subview tanh
|
|
44 syn keyword mlirOps view
|
150
|
45
|
|
46 " Affine ops.
|
|
47 syn match mlirOps /\<affine\.apply\>/
|
|
48 syn match mlirOps /\<affine\.dma_start\>/
|
|
49 syn match mlirOps /\<affine\.dma_wait\>/
|
|
50 syn match mlirOps /\<affine\.for\>/
|
|
51 syn match mlirOps /\<affine\.if\>/
|
|
52 syn match mlirOps /\<affine\.load\>/
|
221
|
53 syn match mlirOps /\<affine\.parallel\>/
|
150
|
54 syn match mlirOps /\<affine\.prefetch\>/
|
|
55 syn match mlirOps /\<affine\.store\>/
|
|
56 syn match mlirOps /\<loop\.for\>/
|
|
57 syn match mlirOps /\<loop\.if\>/
|
|
58
|
|
59 " TODO: dialect name prefixed ops (llvm or std).
|
|
60
|
|
61 " Keywords.
|
|
62 syn keyword mlirKeyword
|
221
|
63 \ affine_map
|
|
64 \ affine_set
|
150
|
65 \ dense
|
|
66 \ else
|
|
67 \ func
|
|
68 \ module
|
|
69 \ return
|
|
70 \ step
|
|
71 \ to
|
|
72
|
|
73 " Misc syntax.
|
|
74
|
|
75 syn match mlirNumber /-\?\<\d\+\>/
|
|
76 " Match numbers even in shaped types.
|
|
77 syn match mlirNumber /-\?\<\d\+\ze\s*x/
|
|
78 syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
|
|
79
|
|
80 syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
|
|
81 syn match mlirFloat /\<0x\x\+\>/
|
|
82 syn keyword mlirBoolean true false
|
|
83 syn match mlirComment /\/\/.*$/
|
|
84 syn region mlirString start=/"/ skip=/\\"/ end=/"/
|
|
85 syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
|
|
86 syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
|
|
87 syn match mlirIdentifier /[%@!]\d\+\>/
|
|
88 syn match mlirMapSetOutline "#.*$"
|
|
89
|
|
90 " Syntax-highlight lit test commands and bug numbers.
|
|
91 syn match mlirSpecialComment /\/\/\s*RUN:.*$/
|
|
92 syn match mlirSpecialComment /\/\/\s*CHECK:.*$/
|
|
93 syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
|
|
94 syn match mlirSpecialComment /\/\/\s*expected-error.*$/
|
|
95 syn match mlirSpecialComment /\/\/\s*expected-remark.*$/
|
|
96 syn match mlirSpecialComment /;\s*XFAIL:.*$/
|
|
97 syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/
|
|
98 syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/
|
|
99
|
|
100 if version >= 508 || !exists("did_c_syn_inits")
|
|
101 if version < 508
|
|
102 let did_c_syn_inits = 1
|
|
103 command -nargs=+ HiLink hi link <args>
|
|
104 else
|
|
105 command -nargs=+ HiLink hi def link <args>
|
|
106 endif
|
|
107
|
|
108 HiLink mlirType Type
|
|
109 HiLink mlirOps Statement
|
|
110 HiLink mlirMapSetOutline PreProc
|
|
111 HiLink mlirNumber Number
|
|
112 HiLink mlirComment Comment
|
|
113 HiLink mlirString String
|
|
114 HiLink mlirLabel Label
|
|
115 HiLink mlirKeyword Keyword
|
|
116 HiLink mlirBoolean Boolean
|
|
117 HiLink mlirFloat Float
|
|
118 HiLink mlirConstant Constant
|
|
119 HiLink mlirSpecialComment SpecialComment
|
|
120 HiLink mlirIdentifier Identifier
|
|
121
|
|
122 delcommand HiLink
|
|
123 endif
|
|
124
|
|
125 let b:current_syntax = "mlir"
|