diff options
Diffstat (limited to 'contrib/llvm/utils/vim')
-rw-r--r-- | contrib/llvm/utils/vim/README | 43 | ||||
-rw-r--r-- | contrib/llvm/utils/vim/llvm.vim | 111 | ||||
-rw-r--r-- | contrib/llvm/utils/vim/tablegen.vim | 54 | ||||
-rw-r--r-- | contrib/llvm/utils/vim/vimrc | 93 |
4 files changed, 301 insertions, 0 deletions
diff --git a/contrib/llvm/utils/vim/README b/contrib/llvm/utils/vim/README new file mode 100644 index 0000000..bca25bf --- /dev/null +++ b/contrib/llvm/utils/vim/README @@ -0,0 +1,43 @@ +-*- llvm/utils/vim/README -*- + +These are syntax highlighting files for the VIM editor. Included are: + +* llvm.vim + + Syntax highlighting mode for LLVM assembly files. To use, copy `llvm.vim' to + ~/.vim/syntax and add this code to your ~/.vimrc : + + augroup filetype + au! BufRead,BufNewFile *.ll set filetype=llvm + augroup END + +* tablegen.vim + + Syntax highlighting mode for TableGen description files. To use, copy + `tablegen.vim' to ~/.vim/syntax and add this code to your ~/.vimrc : + + augroup filetype + au! BufRead,BufNewFile *.td set filetype=tablegen + augroup END + + +If you prefer, instead of making copies you can make symlinks from +~/.vim/syntax/... to the syntax files in your LLVM source tree. Apparently +this did not work with older versions of vim however, so if this doesn't +work you may need to make actual copies of the files. + +Another option, if you do not already have a ~/.vim/syntax directory, is +to symlink ~/.vim/syntax itself to llvm/utils/vim . + +Note: If you notice missing or incorrect syntax highlighting, please contact +<llvmbugs [at] cs.uiuc.edu>; if you wish to provide a patch to improve the +functionality, it will be most appreciated. Thank you. + +If you find yourself working with LLVM Makefiles often, but you don't get syntax +highlighting (because the files have names such as Makefile.rules or +TEST.nightly.Makefile), add the following to your ~/.vimrc: + + " LLVM Makefile highlighting mode + augroup filetype + au! BufRead,BufNewFile *Makefile* set filetype=make + augroup END diff --git a/contrib/llvm/utils/vim/llvm.vim b/contrib/llvm/utils/vim/llvm.vim new file mode 100644 index 0000000..518aa04 --- /dev/null +++ b/contrib/llvm/utils/vim/llvm.vim @@ -0,0 +1,111 @@ +" Vim syntax file +" Language: llvm +" Maintainer: The LLVM team, http://llvm.org/ +" Version: $Revision: 97271 $ + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn case match + +" Types. +" Types also include struct, array, vector, etc. but these don't +" benefit as much from having dedicated highlighting rules. +syn keyword llvmType void float double +syn keyword llvmType x86_fp80 fp128 ppc_fp128 +syn keyword llvmType type label opaque +syn match llvmType /\<i\d\+\>/ + +" Instructions. +" The true and false tokens can be used for comparison opcodes, but it's +" much more common for these tokens to be used for boolean constants. +syn keyword llvmStatement add fadd sub fsub mul fmul +syn keyword llvmStatement sdiv udiv fdiv srem urem frem +syn keyword llvmStatement and or xor +syn keyword llvmStatement icmp fcmp +syn keyword llvmStatement eq ne ugt uge ult ule sgt sge slt sle +syn keyword llvmStatement oeq ogt oge olt ole one ord ueq ugt uge +syn keyword llvmStatement ult ule une uno +syn keyword llvmStatement nuw nsw exact inbounds +syn keyword llvmStatement phi call select shl lshr ashr va_arg +syn keyword llvmStatement trunc zext sext +syn keyword llvmStatement fptrunc fpext fptoui fptosi uitofp sitofp +syn keyword llvmStatement ptrtoint inttoptr bitcast +syn keyword llvmStatement ret br indirectbr switch invoke unwind unreachable +syn keyword llvmStatement malloc alloca free load store getelementptr +syn keyword llvmStatement extractelement insertelement shufflevector +syn keyword llvmStatement extractvalue insertvalue + +" Keywords. +syn keyword llvmKeyword define declare global constant +syn keyword llvmKeyword internal external private +syn keyword llvmKeyword linkonce linkonce_odr weak weak_odr appending +syn keyword llvmKeyword common extern_weak +syn keyword llvmKeyword thread_local dllimport dllexport +syn keyword llvmKeyword hidden protected default +syn keyword llvmKeyword except deplibs +syn keyword llvmKeyword volatile fastcc coldcc cc ccc +syn keyword llvmKeyword x86_stdcallcc x86_fastcallcc +syn keyword llvmKeyword signext zeroext inreg sret nounwind noreturn +syn keyword llvmKeyword nocapture byval nest readnone readonly noalias +syn keyword llvmKeyword inlinehint noinline alwaysinline optsize ssp sspreq +syn keyword llvmKeyword noredzone noimplicitfloat naked alignstack +syn keyword llvmKeyword module asm align tail to +syn keyword llvmKeyword addrspace section alias sideeffect c gc +syn keyword llvmKeyword target datalayout triple +syn keyword llvmKeyword blockaddress +syn keyword llvmKeyword union + +" Obsolete keywords. +syn keyword llvmError uninitialized implementation +syn keyword llvmError getresult big little endian begin end + +" Misc syntax. +syn match llvmIgnore /[%@]\d\+\>/ +syn match llvmNumber /-\?\<\d\+\>/ +syn match llvmFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ +syn match llvmFloat /\<0x\x\+\>/ +syn keyword llvmBoolean true false +syn keyword llvmConstant zeroinitializer undef null +syn match llvmComment /;.*$/ +syn region llvmString start=/"/ skip=/\\"/ end=/"/ +syn match llvmLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ +syn match llvmIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/ + +" Syntax-highlight dejagnu test commands. +syn match llvmSpecialComment /;\s*RUN:.*$/ +syn match llvmSpecialComment /;\s*PR\d*\s*$/ +syn match llvmSpecialComment /;\s*END\.\s*$/ +syn match llvmSpecialComment /;\s*XFAIL:.*$/ +syn match llvmSpecialComment /;\s*XTARGET:.*$/ + +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 llvmType Type + HiLink llvmStatement Statement + HiLink llvmNumber Number + HiLink llvmComment Comment + HiLink llvmString String + HiLink llvmLabel Label + HiLink llvmKeyword Keyword + HiLink llvmBoolean Boolean + HiLink llvmFloat Float + HiLink llvmIgnore Ignore + HiLink llvmConstant Constant + HiLink llvmSpecialComment SpecialComment + HiLink llvmError Error + HiLink llvmIdentifier Identifier + + delcommand HiLink +endif + +let b:current_syntax = "llvm" diff --git a/contrib/llvm/utils/vim/tablegen.vim b/contrib/llvm/utils/vim/tablegen.vim new file mode 100644 index 0000000..11a4d80 --- /dev/null +++ b/contrib/llvm/utils/vim/tablegen.vim @@ -0,0 +1,54 @@ +" Vim syntax file +" Language: TableGen +" Maintainer: The LLVM team, http://llvm.org/ +" Version: $Revision: 97271 $ + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" May be changed if you have a really slow machine +syntax sync minlines=100 + +syn case match + +syn keyword tgKeyword def let in code dag field include defm +syn keyword tgType class int string list bit bits multiclass + +syn match tgNumber /\<\d\+\>/ +syn match tgNumber /\<\d\+\.\d*\>/ +syn match tgNumber /\<0b[01]\+\>/ +syn match tgNumber /\<0x[0-9a-fA-F]\+\>/ +syn region tgString start=/"/ skip=/\\"/ end=/"/ oneline + +syn region tgCode start=/\[{/ end=/}\]/ + +syn keyword tgTodo contained TODO FIXME +syn match tgComment /\/\/.*$/ contains=tgTodo +" Handle correctly imbricated comment +syn region tgComment2 matchgroup=tgComment2 start=+/\*+ end=+\*/+ contains=tgTodo,tgComment2 + +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 tgKeyword Statement + HiLink tgType Type + HiLink tgNumber Number + HiLink tgComment Comment + HiLink tgComment2 Comment + HiLink tgString String + " May find a better Hilight group... + HiLink tgCode Special + HiLink tgTodo Todo + + delcommand HiLink +endif + +let b:current_syntax = "tablegen" diff --git a/contrib/llvm/utils/vim/vimrc b/contrib/llvm/utils/vim/vimrc new file mode 100644 index 0000000..63108f2 --- /dev/null +++ b/contrib/llvm/utils/vim/vimrc @@ -0,0 +1,93 @@ +" LLVM coding guidelines conformance for VIM +" $Revision: 97273 $ +" +" Maintainer: The LLVM Team, http://llvm.org +" WARNING: Read before you source in all these commands and macros! Some +" of them may change VIM behavior that you depend on. +" +" You can run VIM with these settings without changing your current setup with: +" $ vim -u /path/to/llvm/utils/vim/vimrc + +" It's VIM, not VI +set nocompatible + +" A tab produces a 2-space indentation +set softtabstop=2 +set shiftwidth=2 +set expandtab + +" Highlight trailing whitespace and lines longer than 80 columns. +highlight LongLine ctermbg=DarkYellow guibg=DarkYellow +highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow +if v:version >= 702 + " Lines longer than 80 columns. + au BufWinEnter * let w:m0=matchadd('LongLine', '\%>80v.\+', -1) + + " Whitespace at the end of a line. This little dance suppresses + " whitespace that has just been typed. + au BufWinEnter * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1) + au InsertEnter * call matchdelete(w:m1) + au InsertEnter * let w:m2=matchadd('WhitespaceEOL', '\s\+\%#\@<!$', -1) + au InsertLeave * call matchdelete(w:m2) + au InsertLeave * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1) +else + au BufRead,BufNewFile * syntax match LongLine /\%>80v.\+/ + au InsertEnter * syntax match WhitespaceEOL /\s\+\%#\@<!$/ + au InsertLeave * syntax match WhitespaceEOL /\s\+$/ +endif + +" Enable filetype detection +filetype on + +" Optional +" C/C++ programming helpers +augroup csrc + au! + autocmd FileType * set nocindent smartindent + autocmd FileType c,cpp set cindent +augroup END +" Set a few indentation parameters. See the VIM help for cinoptions-values for +" details. These aren't absolute rules; they're just an approximation of +" common style in LLVM source. +set cinoptions=:0,g0,(0,Ws,l1 +" Add and delete spaces in increments of `shiftwidth' for tabs +set smarttab + +" Highlight syntax in programming languages +syntax on + +" LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile, +" so it's important to categorize them as such. +augroup filetype + au! BufRead,BufNewFile *Makefile* set filetype=make +augroup END + +" In Makefiles, don't expand tabs to spaces, since we need the actual tabs +autocmd FileType make set noexpandtab + +" Useful macros for cleaning up code to conform to LLVM coding guidelines + +" Delete trailing whitespace and tabs at the end of each line +command! DeleteTrailingWs :%s/\s\+$// + +" Convert all tab characters to two spaces +command! Untab :%s/\t/ /g + +" Enable syntax highlighting for LLVM files. To use, copy +" utils/vim/llvm.vim to ~/.vim/syntax . +augroup filetype + au! BufRead,BufNewFile *.ll set filetype=llvm +augroup END + +" Enable syntax highlighting for tablegen files. To use, copy +" utils/vim/tablegen.vim to ~/.vim/syntax . +augroup filetype + au! BufRead,BufNewFile *.td set filetype=tablegen +augroup END + +" Additional vim features to optionally uncomment. +"set showcmd +"set showmatch +"set showmode +"set incsearch +"set ruler |