github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/mlir/utils/vim/syntax/mlir.vim (about)

     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  
     7  if version < 600
     8    syntax clear
     9  elseif exists("b:current_syntax")
    10    finish
    11  endif
    12  
    13  syn case match
    14  
    15  " Types.
    16  syn keyword mlirType index f16 f32 f64
    17  " Integer type.
    18  syn match mlirType /\<i\d\+\>/
    19  
    20  " Elemental types inside memref, tensor, or vector types.
    21  syn match mlirType /x\s*\zs\(f16\|f32\|f64\|i\d\+\)/
    22  
    23  " Shaped types.
    24  syn match mlirType /\<memref\ze\s*<.*>/
    25  syn match mlirType /\<tensor\ze\s*<.*>/
    26  syn match mlirType /\<vector\ze\s*<.*>/
    27  
    28  " vector types inside memref or tensor.
    29  syn match mlirType /x\s*\zsvector/
    30  
    31  " Operations.
    32  " Core ops (not exhaustive yet).
    33  " TODO: the list is not exhaustive.
    34  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
    35  
    36  " Affine ops.
    37  syn match mlirOps /\<affine\.apply\>/
    38  syn match mlirOps /\<affine\.dma_start\>/
    39  syn match mlirOps /\<affine\.dma_wait\>/
    40  syn match mlirOps /\<affine\.for\>/
    41  syn match mlirOps /\<affine\.if\>/
    42  syn match mlirOps /\<affine\.load\>/
    43  syn match mlirOps /\<affine\.store\>/
    44  
    45  " TODO: dialect name prefixed ops (llvm or std).
    46  
    47  " Keywords.
    48  syn keyword mlirKeyword
    49        \ else
    50        \ func
    51        \ return
    52        \ step
    53        \ to
    54  
    55  " Misc syntax.
    56  
    57  syn match   mlirNumber /-\?\<\d\+\>/
    58  " Match numbers even in shaped types.
    59  syn match   mlirNumber /-\?\<\d\+\ze\s*x/
    60  syn match   mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
    61  
    62  syn match   mlirFloat  /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
    63  syn match   mlirFloat  /\<0x\x\+\>/
    64  syn keyword mlirBoolean true false
    65  syn match   mlirComment /\/\/.*$/
    66  syn region  mlirString start=/"/ skip=/\\"/ end=/"/
    67  syn match   mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
    68  syn match   mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
    69  syn match   mlirIdentifier /[%@!]\d\+\>/
    70  syn match mlirMapSetOutline "#.*$"
    71  
    72  " Syntax-highlight lit test commands and bug numbers.
    73  syn match  mlirSpecialComment /\/\/\s*RUN:.*$/
    74  syn match  mlirSpecialComment /\/\/\s*CHECK:.*$/
    75  syn match  mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
    76  syn match  mlirSpecialComment /\/\/\s*expected-error.*$/
    77  syn match  mlirSpecialComment /\/\/\s*expected-remark.*$/
    78  syn match  mlirSpecialComment /;\s*XFAIL:.*$/
    79  syn match  mlirSpecialComment /\/\/\s*PR\d*\s*$/
    80  syn match  mlirSpecialComment /\/\/\s*REQUIRES:.*$/
    81  
    82  if version >= 508 || !exists("did_c_syn_inits")
    83    if version < 508
    84      let did_c_syn_inits = 1
    85      command -nargs=+ HiLink hi link <args>
    86    else
    87      command -nargs=+ HiLink hi def link <args>
    88    endif
    89  
    90    HiLink mlirType Type
    91    HiLink mlirOps Statement
    92    HiLink mlirMapSetOutline PreProc
    93    HiLink mlirNumber Number
    94    HiLink mlirComment Comment
    95    HiLink mlirString String
    96    HiLink mlirLabel Label
    97    HiLink mlirKeyword Keyword
    98    HiLink mlirBoolean Boolean
    99    HiLink mlirFloat Float
   100    HiLink mlirConstant Constant
   101    HiLink mlirSpecialComment SpecialComment
   102    HiLink mlirIdentifier Identifier
   103  
   104    delcommand HiLink
   105  endif
   106  
   107  let b:current_syntax = "mlir"