contrib: introduce Vim addon directory, add match.pd syntax plugin

Message ID alpine.LNX.2.20.13.1806262133380.2272@monopod.intra.ispras.ru
State New
Headers show
Series
  • contrib: introduce Vim addon directory, add match.pd syntax plugin
Related show

Commit Message

Alexander Monakov June 26, 2018, 8:12 p.m.
Hi,

This adds Vim syntax highlighting rules for match.pd and packages them together
with gcc-rtl.vim and gimple.vim, creating contrib/vim-gcc-dev subtree that can
be installed as a common Vim plugin.

Thanks.
Alexander

	* vim-gcc-dev/README: New file.
	* vim-gcc-dev/ftdetect/gcc-dev.vim: New file.
	* vim-gcc-dev/syntax/gcc-match.vim: New file.
	* gimple.vim: Move under vim-gcc-dev/syntax/.
	* gcc-rtl.vim: Likewise.

Comments

Jeff Law June 28, 2018, 2:12 a.m. | #1
On 06/26/2018 02:12 PM, Alexander Monakov wrote:
> Hi,

> 

> This adds Vim syntax highlighting rules for match.pd and packages them together

> with gcc-rtl.vim and gimple.vim, creating contrib/vim-gcc-dev subtree that can

> be installed as a common Vim plugin.

> 

> Thanks.

> Alexander

> 

> 	* vim-gcc-dev/README: New file.

> 	* vim-gcc-dev/ftdetect/gcc-dev.vim: New file.

> 	* vim-gcc-dev/syntax/gcc-match.vim: New file.

> 	* gimple.vim: Move under vim-gcc-dev/syntax/.

> 	* gcc-rtl.vim: Likewise.

OK.
jeff

Patch

diff --git a/contrib/vim-gcc-dev/README b/contrib/vim-gcc-dev/README
new file mode 100644
index 00000000000..29bbf48492f
--- /dev/null
+++ b/contrib/vim-gcc-dev/README
@@ -0,0 +1,13 @@ 
+This directory serves as a simple Vim addon for GCC development.  It can be
+symlinked or copied into Vim plugin directory as any other plugin.  For
+example, if using vim-pathogen plugin manager:
+
+    ln -s /path/to/gcc/contrib/vim-gcc-dev ~/.vim/bundle/
+
+This adds syntax highlighting rules for the match.pd file and GIMPLE/RTL dumps.
+
+You can also use RTL syntax rules for GCC machine desciption files by adding
+
+    autocmd BufRead *.md  setf gcc-rtl
+
+to your ~/.vimrc file.
diff --git a/contrib/vim-gcc-dev/ftdetect/gcc-dev.vim b/contrib/vim-gcc-dev/ftdetect/gcc-dev.vim
new file mode 100644
index 00000000000..ed6989aeacb
--- /dev/null
+++ b/contrib/vim-gcc-dev/ftdetect/gcc-dev.vim
@@ -0,0 +1,20 @@ 
+" Vim file type detection rules for GCC development
+"
+" Copyright (C) 2018 Free Software Foundation, Inc.
+"
+" This script is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 3, or (at your option)
+" any later version
+
+augroup filetypedetect
+
+  au BufRead match.pd                setf gcc-match
+
+  " Match RTL dump file names such as test.c.234r.pass-name
+  au BufRead *.[1-3][0-9][0-9]r.*    setf gcc-rtl
+
+  " Match GIMPLE and IPA dump file names
+  au BufRead *.[0-2][0-9][0-9][ti].* setf gimple
+
+augroup END
diff --git a/contrib/vim-gcc-dev/syntax/gcc-match.vim b/contrib/vim-gcc-dev/syntax/gcc-match.vim
new file mode 100644
index 00000000000..356b07a15b2
--- /dev/null
+++ b/contrib/vim-gcc-dev/syntax/gcc-match.vim
@@ -0,0 +1,71 @@ 
+" Vim syntax highlighting rules for GCC match-and-simplify language.
+"
+" Copyright (C) 2018 Free Software Foundation, Inc.
+"
+" This script is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 3, or (at your option)
+" any later version
+
+if exists("b:current_syntax")
+    finish
+endif
+
+" Some keywords have a question mark, e.g. 'convert?'
+setl isk=@,48-57,_,?
+
+syn keyword pdTodo contained TODO FIXME XXX
+
+syn keyword pdCtrl match simplify
+syn keyword pdCtrl define_predicates define_operator_list
+syn keyword pdCtrl if switch for with
+
+syn keyword pdType type
+
+syn keyword pdOp view_convert view_convert?
+               \ convert convert? convert1 convert2 convert1? convert2?
+               \ realpart imagpart
+               \ cond vec_cond vec_perm
+               \ pointer_plus pointer_diff
+               \ plus minus mult mult_highpart
+               \ trunc_div ceil_div floor_div round_div
+               \ trunc_mod ceil_mod floor_mod round_mod
+               \ rdiv exact_div
+               \ fix_trunc float negate min max abs absu
+               \ lshift rshift lrotate rrotate
+               \ bit_ior bit_xor bit_and bit_not
+               \ truth_andif truth_orif truth_and
+               \ truth_or truth_xor truth_not
+               \ lt le gt ge eq ne unordered ordered
+               \ unlt unle ungt unge uneq ltgt
+               \ addr_space_convert fixed_convert
+               \ bit_insert complex conj
+               \ reduc_max reduc_min reduc_plus
+               \ dot_prod widen_sum sad fma
+               \ widen_mult widen_mult_plus widen_mult_minus widen_lshift
+               \ vec_widen_mult_hi vec_widen_mult_lo
+               \ vec_widen_mult_even vec_widen_mult_odd
+               \ vec_unpack_hi vec_unpack_lo
+               \ vec_unpack_float_hi vec_unpack_float_lo
+               \ vec_pack_trunc vec_pack_sat vec_pack_fix_trunc
+               \ vec_widen_lshift_hi vec_widen_lshift_lo
+
+" Match commutative/single-use specifiers: :C, :c, :s, :cs, etc.
+syn match pdOpSpec  ":[CcSs]\+\>"
+
+syn match pdCapture "@@\?[a-zA-Z0-9_]\+"
+
+syn region pdComment start="/\*" end="\*/" contains=pdTodo
+
+syn region pdPreProc start="^\s*#" skip="\\$" end="$" keepend
+
+hi def link pdCtrl    Statement
+hi def link pdType    Identifier
+hi def link pdOp      Constant
+hi def link pdOpSpec  Operator
+hi def link pdCapture Special
+hi def link pdComment Comment
+hi def link pdTodo    Todo
+hi def link pdPreProc PreProc
+
+let b:current_syntax = "gcc-match"
diff --git a/contrib/gcc-rtl.vim b/contrib/vim-gcc-dev/syntax/gcc-rtl.vim
similarity index 98%
rename from contrib/gcc-rtl.vim
rename to contrib/vim-gcc-dev/syntax/gcc-rtl.vim
index c9070a2493f..6b674e0285b 100644
--- a/contrib/gcc-rtl.vim
+++ b/contrib/vim-gcc-dev/syntax/gcc-rtl.vim
@@ -6,8 +6,6 @@ 
 " it under the terms of the GNU General Public License as published by
 " the Free Software Foundation; either version 3, or (at your option)
 " any later version
-"
-" For more instructions please see gimple.vim file in the same folder.
 
 
 " Do not continue, if syntax is already enabled in current buffer.
diff --git a/contrib/gimple.vim b/contrib/vim-gcc-dev/syntax/gimple.vim
similarity index 93%
rename from contrib/gimple.vim
rename to contrib/vim-gcc-dev/syntax/gimple.vim
index bee1319e575..6a0150d6f4e 100644
--- a/contrib/gimple.vim
+++ b/contrib/vim-gcc-dev/syntax/gimple.vim
@@ -11,17 +11,6 @@ 
 " intermediate representation.  Such dumps are produced by GCC when
 " it is invoked with -fdump-tree-* and/or -fdump-ipa-* switches.  Tested
 " in Vim 7.4 (but should also work with earlier versions).
-"
-" INSTALLATION:
-" 1. Copy the script into $HOME/.vim/syntax directory
-" 2. Create a file gimple.vim in $HOME/.vim/ftdetect directory with the
-"    following command in it:
-"
-" au BufRead,BufNewFile *.[0-2][0-9][0-9][ti].* set filetype=gimple
-"
-" The pattern in this autocommand corresponds to default file names
-" of debug dumps, e.g.:
-" filename.cc.123t.pass-name
 
 
 " Do not continue, if syntax is already enabled in current buffer.
@@ -155,4 +144,3 @@  hi def link gimpleFrequency     Debug
 hi def link gimpleBBCount       Debug
 
 let b:current_syntax = "gimple"
-