aboutsummaryrefslogtreecommitdiff
path: root/utils/vim
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-02 17:52:33 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-02 17:52:33 +0000
commit009b1c42aa6266385f2c37e227516b24077e6dd7 (patch)
tree64ba909838c23261cace781ece27d106134ea451 /utils/vim
downloadsrc-009b1c42aa6266385f2c37e227516b24077e6dd7.tar.gz
src-009b1c42aa6266385f2c37e227516b24077e6dd7.zip
Notes
Diffstat (limited to 'utils/vim')
-rw-r--r--utils/vim/README43
-rw-r--r--utils/vim/llvm.vim104
-rw-r--r--utils/vim/tablegen.vim54
-rw-r--r--utils/vim/vimrc72
4 files changed, 273 insertions, 0 deletions
diff --git a/utils/vim/README b/utils/vim/README
new file mode 100644
index 000000000000..bca25bfe6127
--- /dev/null
+++ b/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/utils/vim/llvm.vim b/utils/vim/llvm.vim
new file mode 100644
index 000000000000..201d8ddddbeb
--- /dev/null
+++ b/utils/vim/llvm.vim
@@ -0,0 +1,104 @@
+" Vim syntax file
+" Language: llvm
+" Maintainer: The LLVM team, http://llvm.org/
+" Updated: 2003-06-02
+
+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 sub mul 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 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 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
+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
+syn keyword llvmKeyword noinline alwaysinline optsize ssp sspreq
+syn keyword llvmKeyword module asm align tail to
+syn keyword llvmKeyword addrspace section alias sideeffect c gc
+syn keyword llvmKeyword target datalayout triple
+
+" 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\$._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
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = "llvm"
diff --git a/utils/vim/tablegen.vim b/utils/vim/tablegen.vim
new file mode 100644
index 000000000000..ad358728e5f8
--- /dev/null
+++ b/utils/vim/tablegen.vim
@@ -0,0 +1,54 @@
+" Vim syntax file
+" Language: TableGen
+" Maintainer: The LLVM team, http://llvm.org/
+" Updated: 2003-08-11
+
+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/utils/vim/vimrc b/utils/vim/vimrc
new file mode 100644
index 000000000000..7b1fd872b274
--- /dev/null
+++ b/utils/vim/vimrc
@@ -0,0 +1,72 @@
+" LLVM coding guidelines conformance for VIM
+"
+" 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
+
+" Wrap text at 80 cols
+set textwidth=80
+
+" A tab produces a 2-space indentation
+set softtabstop=2
+set shiftwidth=2
+set expandtab
+
+" Highlight trailing whitespace
+highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow
+match WhitespaceEOL /\s\+$/
+
+" 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
+" 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