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