143 lines · plain
1" Vim syntax file2" Language: mlir3" 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 < 6008 syntax clear9elseif exists("b:current_syntax")10 finish11endif12 13syn case match14 15" Types.16"17syn keyword mlirType index f16 f32 f64 bf1618" 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 cmpi39syn keyword mlirOps constant dealloc divf dma_start dma_wait dim exp40syn keyword mlirOps getTensor index_cast load log memref_cast41syn keyword mlirOps memref_shape_cast mulf muli negf powf prefetch rsqrt sitofp42syn keyword mlirOps splat store select sqrt subf subi subview tanh43syn keyword mlirOps view44 45" Math ops.46syn match mlirOps /\<math\.erf\>/47syn match mlirOps /\<math\.erfc\>/48 49" Affine ops.50syn match mlirOps /\<affine\.apply\>/51syn match mlirOps /\<affine\.dma_start\>/52syn match mlirOps /\<affine\.dma_wait\>/53syn match mlirOps /\<affine\.for\>/54syn match mlirOps /\<affine\.if\>/55syn match mlirOps /\<affine\.load\>/56syn match mlirOps /\<affine\.parallel\>/57syn match mlirOps /\<affine\.prefetch\>/58syn match mlirOps /\<affine\.store\>/59syn match mlirOps /\<scf\.execute_region\>/60syn match mlirOps /\<scf\.for\>/61syn match mlirOps /\<scf\.if\>/62syn match mlirOps /\<scf\.yield\>/63 64" TODO: dialect name prefixed ops (llvm or std).65 66" Keywords.67syn keyword mlirKeyword68 \ affine_map69 \ affine_set70 \ dense71 \ else72 \ func73 \ module74 \ return75 \ step76 \ to77 78" Misc syntax.79 80syn match mlirNumber /-\?\<\d\+\>/81" Match numbers even in shaped types.82syn match mlirNumber /-\?\<\d\+\ze\s*x/83syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/84 85syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/86syn match mlirFloat /\<0x\x\+\>/87syn keyword mlirBoolean true false88" Spell checking is enabled only in comments by default.89syn match mlirComment /\/\/.*$/ contains=@Spell90syn region mlirString start=/"/ skip=/\\"/ end=/"/91syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/92" Prefixed identifiers usually used for ssa values and symbols.93syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/94syn match mlirIdentifier /[%@]\d\+\>/95" Prefixed identifiers usually used for blocks.96syn match mlirBlockIdentifier /\^[a-zA-Z$._-][a-zA-Z0-9$._-]*/97syn match mlirBlockIdentifier /\^\d\+\>/98" Prefixed identifiers usually used for types.99syn match mlirTypeIdentifier /![a-zA-Z$._-][a-zA-Z0-9$._-]*/100syn match mlirTypeIdentifier /!\d\+\>/101" Prefixed identifiers usually used for attribute aliases and result numbers.102syn match mlirAttrIdentifier /#[a-zA-Z$._-][a-zA-Z0-9$._-]*/103syn match mlirAttrIdentifier /#\d\+\>/104 105" Syntax-highlight lit test commands and bug numbers.106syn match mlirSpecialComment /\/\/\s*RUN:.*$/107syn match mlirSpecialComment /\/\/\s*CHECK:.*$/108syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"109syn match mlirSpecialComment /\/\/\s*expected-error.*$/110syn match mlirSpecialComment /\/\/\s*expected-remark.*$/111syn match mlirSpecialComment /;\s*XFAIL:.*$/112syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/113syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/114 115if version >= 508 || !exists("did_c_syn_inits")116 if version < 508117 let did_c_syn_inits = 1118 command -nargs=+ HiLink hi link <args>119 else120 command -nargs=+ HiLink hi def link <args>121 endif122 123 HiLink mlirType Type124 HiLink mlirOps Statement125 HiLink mlirNumber Number126 HiLink mlirComment Comment127 HiLink mlirString String128 HiLink mlirLabel Label129 HiLink mlirKeyword Keyword130 HiLink mlirBoolean Boolean131 HiLink mlirFloat Float132 HiLink mlirConstant Constant133 HiLink mlirSpecialComment SpecialComment134 HiLink mlirIdentifier Identifier135 HiLink mlirBlockIdentifier Label136 HiLink mlirTypeIdentifier Type137 HiLink mlirAttrIdentifier PreProc138 139 delcommand HiLink140endif141 142let b:current_syntax = "mlir"143