summaryrefslogtreecommitdiffstats
path: root/mlir/utils/vim/syntax
diff options
context:
space:
mode:
authorUday Bondhugula <udayb@iisc.ac.in>2019-08-30 17:38:36 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-08-30 17:39:19 -0700
commit20d3e71c3f429120bfc570d13674eb8a4c881dfe (patch)
treec743d7fe5ef890f304862ef28b75d120d6fa73f4 /mlir/utils/vim/syntax
parent9c8a8a7d0da011f1570733265020a40079127b05 (diff)
downloadbcm5719-llvm-20d3e71c3f429120bfc570d13674eb8a4c881dfe.tar.gz
bcm5719-llvm-20d3e71c3f429120bfc570d13674eb8a4c881dfe.zip
update vim syntax file
- more highlighting: numbers, elemental types inside shaped types - add some more keywords Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#110 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/110 from bondhugula:vim 029777db0ecb95bfc6453c0869af1c233d84d521 PiperOrigin-RevId: 266487768
Diffstat (limited to 'mlir/utils/vim/syntax')
-rw-r--r--mlir/utils/vim/syntax/mlir.vim32
1 files changed, 22 insertions, 10 deletions
diff --git a/mlir/utils/vim/syntax/mlir.vim b/mlir/utils/vim/syntax/mlir.vim
index 41d277a0559..416ef1ade1e 100644
--- a/mlir/utils/vim/syntax/mlir.vim
+++ b/mlir/utils/vim/syntax/mlir.vim
@@ -2,7 +2,7 @@
" Language: mlir
" Maintainer: The MLIR team, http://github.com/tensorflow/mlir/
" Version: $Revision$
-" Adapted from the LLVM vim indent file
+" Some parts adapted from the LLVM vim syntax file.
if version < 600
syntax clear
@@ -16,16 +16,22 @@ syn case match
syn keyword mlirType index f16 f32 f64
" Integer type.
syn match mlirType /\<i\d\+\>/
-" Primitive types inside memref, tensor, or vector.
-syn match mlirType /<.*x\s*\zs\(f16\|f32\|f64\|i\d\+\)/
-syn match mlirType /\<memref\ze<.*>/
-syn match mlirType /\<tensor\ze<.*>/
-syn match mlirType /\<vector\ze<.*>/
+
+" 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/
" Operations.
" Core ops (not exhaustive yet).
" TODO: the list is not exhaustive.
-syn keyword mlirOps alloc addf addi call call_indirect cmpi constant dealloc dma_start dma_wait dim extract_element getTensor load memref_cast mulf muli store select subf subi tensor_cast
+syn keyword mlirOps alloc addf addi call call_indirect cmpi constant dealloc dma_start dma_wait dim extract_element for getTensor if load memref_cast mulf muli store select subf subi tensor_cast
" Affine ops.
syn match mlirOps /\<affine\.apply\>/
@@ -36,6 +42,8 @@ syn match mlirOps /\<affine\.if\>/
syn match mlirOps /\<affine\.load\>/
syn match mlirOps /\<affine\.store\>/
+" TODO: dialect name prefixed ops (llvm or std).
+
" Keywords.
syn keyword mlirKeyword
\ else
@@ -45,15 +53,20 @@ syn keyword mlirKeyword
\ to
" Misc syntax.
-syn match mlirNoName /[%@!]\d\+\>/
+
syn match mlirNumber /-\?\<\d\+\>/
+" Match numbers even in shaped types.
+syn match mlirNumber /-\?\<\d\+\ze\s*x/
+syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
+
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]*:/
-syn match mlirIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/
+syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
+syn match mlirIdentifier /[%@!]\d\+\>/
syn match mlirMapSetOutline "#.*$"
" Syntax-highlight lit test commands and bug numbers.
@@ -84,7 +97,6 @@ if version >= 508 || !exists("did_c_syn_inits")
HiLink mlirKeyword Keyword
HiLink mlirBoolean Boolean
HiLink mlirFloat Float
- HiLink mlirNoName Identifier
HiLink mlirConstant Constant
HiLink mlirSpecialComment SpecialComment
HiLink mlirIdentifier Identifier
OpenPOWER on IntegriCloud