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