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