2019-08-29 14:22:39 +08:00
|
|
|
" Vim syntax file
|
|
|
|
" Language: mlir
|
|
|
|
" Maintainer: The MLIR team, http://github.com/tensorflow/mlir/
|
|
|
|
" Version: $Revision$
|
2019-08-31 08:38:36 +08:00
|
|
|
" Some parts adapted from the LLVM vim syntax file.
|
2019-08-29 14:22:39 +08:00
|
|
|
|
|
|
|
if version < 600
|
|
|
|
syntax clear
|
|
|
|
elseif exists("b:current_syntax")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
syn case match
|
|
|
|
|
|
|
|
" Types.
|
|
|
|
syn keyword mlirType index f16 f32 f64
|
|
|
|
" Integer type.
|
|
|
|
syn match mlirType /\<i\d\+\>/
|
2019-08-31 08:38:36 +08:00
|
|
|
|
|
|
|
" Elemental types inside memref, tensor, or vector types.
|
|
|
|
syn match mlirType /x\s*\zs\(f16\|f32\|f64\|i\d\+\)/
|
|
|
|
|
|
|
|
" Shaped types.
|
|
|
|
syn match mlirType /\<memref\ze\s*<.*>/
|
|
|
|
syn match mlirType /\<tensor\ze\s*<.*>/
|
|
|
|
syn match mlirType /\<vector\ze\s*<.*>/
|
|
|
|
|
|
|
|
" vector types inside memref or tensor.
|
|
|
|
syn match mlirType /x\s*\zsvector/
|
2019-08-29 14:22:39 +08:00
|
|
|
|
|
|
|
" Operations.
|
|
|
|
" Core ops (not exhaustive yet).
|
|
|
|
" TODO: the list is not exhaustive.
|
2019-12-07 08:16:32 +08:00
|
|
|
syn keyword mlirOps alloc alloca addf addi call call_indirect cmpi constant
|
|
|
|
syn keyword mlirOps dealloc divf dma_start dma_wait dim extract_element
|
2019-12-20 23:02:11 +08:00
|
|
|
syn keyword mlirOps getTensor index_cast load memref_cast memref_shape_cast
|
|
|
|
syn keyword mlirOps mulf muli prefetch sitofp splat store select subf subi
|
|
|
|
syn keyword mlirOps subview tensor_cast view
|
2019-08-29 14:22:39 +08:00
|
|
|
|
|
|
|
" Affine ops.
|
|
|
|
syn match mlirOps /\<affine\.apply\>/
|
|
|
|
syn match mlirOps /\<affine\.dma_start\>/
|
|
|
|
syn match mlirOps /\<affine\.dma_wait\>/
|
|
|
|
syn match mlirOps /\<affine\.for\>/
|
|
|
|
syn match mlirOps /\<affine\.if\>/
|
|
|
|
syn match mlirOps /\<affine\.load\>/
|
2019-12-19 01:59:37 +08:00
|
|
|
syn match mlirOps /\<affine\.prefetch\>/
|
2019-08-29 14:22:39 +08:00
|
|
|
syn match mlirOps /\<affine\.store\>/
|
2019-12-07 08:16:32 +08:00
|
|
|
syn match mlirOps /\<loop\.for\>/
|
|
|
|
syn match mlirOps /\<loop\.if\>/
|
2019-08-29 14:22:39 +08:00
|
|
|
|
2019-08-31 08:38:36 +08:00
|
|
|
" TODO: dialect name prefixed ops (llvm or std).
|
|
|
|
|
2019-08-29 14:22:39 +08:00
|
|
|
" Keywords.
|
|
|
|
syn keyword mlirKeyword
|
2019-12-07 08:16:32 +08:00
|
|
|
\ dense
|
2019-08-29 14:22:39 +08:00
|
|
|
\ else
|
|
|
|
\ func
|
2019-12-07 08:16:32 +08:00
|
|
|
\ module
|
2019-08-29 14:22:39 +08:00
|
|
|
\ return
|
|
|
|
\ step
|
|
|
|
\ to
|
|
|
|
|
|
|
|
" Misc syntax.
|
2019-08-31 08:38:36 +08:00
|
|
|
|
2019-08-29 14:22:39 +08:00
|
|
|
syn match mlirNumber /-\?\<\d\+\>/
|
2019-08-31 08:38:36 +08:00
|
|
|
" Match numbers even in shaped types.
|
|
|
|
syn match mlirNumber /-\?\<\d\+\ze\s*x/
|
|
|
|
syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
|
|
|
|
|
2019-08-29 14:22:39 +08:00
|
|
|
syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
|
|
|
|
syn match mlirFloat /\<0x\x\+\>/
|
|
|
|
syn keyword mlirBoolean true false
|
|
|
|
syn match mlirComment /\/\/.*$/
|
|
|
|
syn region mlirString start=/"/ skip=/\\"/ end=/"/
|
|
|
|
syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
|
2019-08-31 08:38:36 +08:00
|
|
|
syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
|
|
|
|
syn match mlirIdentifier /[%@!]\d\+\>/
|
2019-08-29 14:22:39 +08:00
|
|
|
syn match mlirMapSetOutline "#.*$"
|
|
|
|
|
|
|
|
" Syntax-highlight lit test commands and bug numbers.
|
|
|
|
syn match mlirSpecialComment /\/\/\s*RUN:.*$/
|
|
|
|
syn match mlirSpecialComment /\/\/\s*CHECK:.*$/
|
|
|
|
syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
|
|
|
|
syn match mlirSpecialComment /\/\/\s*expected-error.*$/
|
|
|
|
syn match mlirSpecialComment /\/\/\s*expected-remark.*$/
|
|
|
|
syn match mlirSpecialComment /;\s*XFAIL:.*$/
|
|
|
|
syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/
|
|
|
|
syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/
|
|
|
|
|
|
|
|
if version >= 508 || !exists("did_c_syn_inits")
|
|
|
|
if version < 508
|
|
|
|
let did_c_syn_inits = 1
|
|
|
|
command -nargs=+ HiLink hi link <args>
|
|
|
|
else
|
|
|
|
command -nargs=+ HiLink hi def link <args>
|
|
|
|
endif
|
|
|
|
|
|
|
|
HiLink mlirType Type
|
|
|
|
HiLink mlirOps Statement
|
|
|
|
HiLink mlirMapSetOutline PreProc
|
|
|
|
HiLink mlirNumber Number
|
|
|
|
HiLink mlirComment Comment
|
|
|
|
HiLink mlirString String
|
|
|
|
HiLink mlirLabel Label
|
|
|
|
HiLink mlirKeyword Keyword
|
|
|
|
HiLink mlirBoolean Boolean
|
|
|
|
HiLink mlirFloat Float
|
|
|
|
HiLink mlirConstant Constant
|
|
|
|
HiLink mlirSpecialComment SpecialComment
|
|
|
|
HiLink mlirIdentifier Identifier
|
|
|
|
|
|
|
|
delcommand HiLink
|
|
|
|
endif
|
|
|
|
|
|
|
|
let b:current_syntax = "mlir"
|