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 cmpf 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 negf 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 \ affine_map 57 \ affine_set 58 \ dense 59 \ else 60 \ func 61 \ module 62 \ return 63 \ step 64 \ to 65 66" Misc syntax. 67 68syn match mlirNumber /-\?\<\d\+\>/ 69" Match numbers even in shaped types. 70syn match mlirNumber /-\?\<\d\+\ze\s*x/ 71syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/ 72 73syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ 74syn match mlirFloat /\<0x\x\+\>/ 75syn keyword mlirBoolean true false 76syn match mlirComment /\/\/.*$/ 77syn region mlirString start=/"/ skip=/\\"/ end=/"/ 78syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ 79syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/ 80syn match mlirIdentifier /[%@!]\d\+\>/ 81syn match mlirMapSetOutline "#.*$" 82 83" Syntax-highlight lit test commands and bug numbers. 84syn match mlirSpecialComment /\/\/\s*RUN:.*$/ 85syn match mlirSpecialComment /\/\/\s*CHECK:.*$/ 86syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$" 87syn match mlirSpecialComment /\/\/\s*expected-error.*$/ 88syn match mlirSpecialComment /\/\/\s*expected-remark.*$/ 89syn match mlirSpecialComment /;\s*XFAIL:.*$/ 90syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/ 91syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/ 92 93if version >= 508 || !exists("did_c_syn_inits") 94 if version < 508 95 let did_c_syn_inits = 1 96 command -nargs=+ HiLink hi link <args> 97 else 98 command -nargs=+ HiLink hi def link <args> 99 endif 100 101 HiLink mlirType Type 102 HiLink mlirOps Statement 103 HiLink mlirMapSetOutline PreProc 104 HiLink mlirNumber Number 105 HiLink mlirComment Comment 106 HiLink mlirString String 107 HiLink mlirLabel Label 108 HiLink mlirKeyword Keyword 109 HiLink mlirBoolean Boolean 110 HiLink mlirFloat Float 111 HiLink mlirConstant Constant 112 HiLink mlirSpecialComment SpecialComment 113 HiLink mlirIdentifier Identifier 114 115 delcommand HiLink 116endif 117 118let b:current_syntax = "mlir" 119