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 7if version < 600 8 syntax clear 9elseif exists("b:current_syntax") 10 finish 11endif 12 13syn case match 14 15" Types. 16" 17syn keyword mlirType index f16 f32 f64 18" Signless integer types. 19syn match mlirType /\<i\d\+\>/ 20" Unsigned integer types. 21syn match mlirType /\<ui\d\+\>/ 22" Signed integer types. 23syn match mlirType /\<si\d\+\>/ 24 25" Elemental types inside memref, tensor, or vector types. 26syn match mlirType /x\s*\zs\(f16\|f32\|f64\|i\d\+\|ui\d\+\|si\d\+\)/ 27 28" Shaped types. 29syn match mlirType /\<memref\ze\s*<.*>/ 30syn match mlirType /\<tensor\ze\s*<.*>/ 31syn match mlirType /\<vector\ze\s*<.*>/ 32 33" vector types inside memref or tensor. 34syn match mlirType /x\s*\zsvector/ 35 36" Operations. 37" Standard dialect ops. 38" TODO: this list is not exhaustive. 39syn keyword mlirOps alloc alloca addf addi and call call_indirect cmpf cmpi 40syn keyword mlirOps constant dealloc divf dma_start dma_wait dim exp 41syn keyword mlirOps getTensor index_cast load log memref_cast 42syn keyword mlirOps memref_shape_cast mulf muli negf powf prefetch rsqrt sitofp 43syn keyword mlirOps splat store select sqrt subf subi subview tanh 44syn keyword mlirOps view 45 46" Affine ops. 47syn match mlirOps /\<affine\.apply\>/ 48syn match mlirOps /\<affine\.dma_start\>/ 49syn match mlirOps /\<affine\.dma_wait\>/ 50syn match mlirOps /\<affine\.for\>/ 51syn match mlirOps /\<affine\.if\>/ 52syn match mlirOps /\<affine\.load\>/ 53syn match mlirOps /\<affine\.parallel\>/ 54syn match mlirOps /\<affine\.prefetch\>/ 55syn match mlirOps /\<affine\.store\>/ 56syn match mlirOps /\<loop\.for\>/ 57syn match mlirOps /\<loop\.if\>/ 58 59" TODO: dialect name prefixed ops (llvm or std). 60 61" Keywords. 62syn keyword mlirKeyword 63 \ affine_map 64 \ affine_set 65 \ dense 66 \ else 67 \ func 68 \ module 69 \ return 70 \ step 71 \ to 72 73" Misc syntax. 74 75syn match mlirNumber /-\?\<\d\+\>/ 76" Match numbers even in shaped types. 77syn match mlirNumber /-\?\<\d\+\ze\s*x/ 78syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/ 79 80syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ 81syn match mlirFloat /\<0x\x\+\>/ 82syn keyword mlirBoolean true false 83syn match mlirComment /\/\/.*$/ 84syn region mlirString start=/"/ skip=/\\"/ end=/"/ 85syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ 86syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/ 87syn match mlirIdentifier /[%@!]\d\+\>/ 88syn match mlirMapSetOutline "#.*$" 89 90" Syntax-highlight lit test commands and bug numbers. 91syn match mlirSpecialComment /\/\/\s*RUN:.*$/ 92syn match mlirSpecialComment /\/\/\s*CHECK:.*$/ 93syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$" 94syn match mlirSpecialComment /\/\/\s*expected-error.*$/ 95syn match mlirSpecialComment /\/\/\s*expected-remark.*$/ 96syn match mlirSpecialComment /;\s*XFAIL:.*$/ 97syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/ 98syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/ 99 100if 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 123endif 124 125let b:current_syntax = "mlir" 126