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 bf16 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\(bf16|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 87" Spell checking is enabled only in comments by default. 88syn match mlirComment /\/\/.*$/ contains=@Spell 89syn region mlirString start=/"/ skip=/\\"/ end=/"/ 90syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ 91" Prefixed identifiers usually used for ssa values and symbols. 92syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/ 93syn match mlirIdentifier /[%@]\d\+\>/ 94" Prefixed identifiers usually used for blocks. 95syn match mlirBlockIdentifier /\^[a-zA-Z$._-][a-zA-Z0-9$._-]*/ 96syn match mlirBlockIdentifier /\^\d\+\>/ 97" Prefixed identifiers usually used for types. 98syn match mlirTypeIdentifier /![a-zA-Z$._-][a-zA-Z0-9$._-]*/ 99syn match mlirTypeIdentifier /!\d\+\>/ 100" Prefixed identifiers usually used for attribute aliases and result numbers. 101syn match mlirAttrIdentifier /#[a-zA-Z$._-][a-zA-Z0-9$._-]*/ 102syn match mlirAttrIdentifier /#\d\+\>/ 103 104" Syntax-highlight lit test commands and bug numbers. 105syn match mlirSpecialComment /\/\/\s*RUN:.*$/ 106syn match mlirSpecialComment /\/\/\s*CHECK:.*$/ 107syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$" 108syn match mlirSpecialComment /\/\/\s*expected-error.*$/ 109syn match mlirSpecialComment /\/\/\s*expected-remark.*$/ 110syn match mlirSpecialComment /;\s*XFAIL:.*$/ 111syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/ 112syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/ 113 114if version >= 508 || !exists("did_c_syn_inits") 115 if version < 508 116 let did_c_syn_inits = 1 117 command -nargs=+ HiLink hi link <args> 118 else 119 command -nargs=+ HiLink hi def link <args> 120 endif 121 122 HiLink mlirType Type 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 137 138 delcommand HiLink 139endif 140 141let b:current_syntax = "mlir" 142