diff mbox series

Add initial version of rtl.vim syntax file.

Message ID 79dbc4bf-8e12-7604-bae9-dcb6f18e78b6@suse.cz
State New
Headers show
Series Add initial version of rtl.vim syntax file. | expand

Commit Message

Martin Liška June 12, 2018, 12:20 p.m. UTC
Hi.

This is equivalent of gimple.vim file. I'm aware of not full coverage of RTL
instructions, but hope it's a good start point.

Screenshots:

https://drive.google.com/open?id=14y-Hca2hf1gyWDfHaht6Wjv-Btf3Bdvl
https://drive.google.com/open?id=1LiqsJq2ng-aeKsvw3PhUnDjLWh54Y1Vc

Ready for trunk?
Thanks,
Martin

contrib/ChangeLog:

2018-06-12  Martin Liska  <mliska@suse.cz>

	* rtl.vim: New file.
---
 contrib/rtl.vim | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 contrib/rtl.vim

Comments

Alexander Monakov June 15, 2018, 5:08 a.m. UTC | #1
On Tue, 12 Jun 2018, Martin Liška wrote:

> This is equivalent of gimple.vim file. I'm aware of not full coverage of RTL
> instructions, but hope it's a good start point.

I think this is nice to have and hope you'll get an OK for both this and
the gimple.vim patch.

One nit-pick: unlike "GIMPLE", "RTL" is not a GCC-specific abbreviation.
I'd prefer to use gcc-rtl.vim to avoid possible clashes.

Do you use it quite literally as described in gimple.vim, i.e. with
editing ftdetect.vim by hand? I made a plugin for gcc/match.pd syntax
highlighting, and I opted to use a common plugin file layout for it.
That way, I only need to symlink the plugin directory under .vim/bundle.

Thanks.
Alexander
Martin Liška June 15, 2018, 2:28 p.m. UTC | #2
On 06/15/2018 07:08 AM, Alexander Monakov wrote:
> On Tue, 12 Jun 2018, Martin Liška wrote:
> 
>> This is equivalent of gimple.vim file. I'm aware of not full coverage of RTL
>> instructions, but hope it's a good start point.
> 
> I think this is nice to have and hope you'll get an OK for both this and
> the gimple.vim patch.

Hi.

Well, it's sitting in contrib, thus I'm planning to install that eventually
if there will be not response.


> 
> One nit-pick: unlike "GIMPLE", "RTL" is not a GCC-specific abbreviation.
> I'd prefer to use gcc-rtl.vim to avoid possible clashes.

Good idea, let me fix that.

> 
> Do you use it quite literally as described in gimple.vim, i.e. with
> editing ftdetect.vim by hand? I made a plugin for gcc/match.pd syntax
> highlighting, and I opted to use a common plugin file layout for it.
> That way, I only need to symlink the plugin directory under .vim/bundle.

I use it as follows:

vimrc:

au BufRead,BufNewFile *.[0-2][0-9][0-9][ti].* set filetype=gimple
au BufRead,BufNewFile *.[2-3][0-9][0-9]r.* set filetype=rtl

Then I copied these .vim files into syntax folder. I know it's not ideal.
For all other vim extensions I use plugin system (Dein) that installs plugins
from github repos.

So you prefer to come up with a plugin folder with the *.vim files?

Thanks,
Martin

> 
> Thanks.
> Alexander
>
Alexander Monakov June 15, 2018, 4:18 p.m. UTC | #3
On Fri, 15 Jun 2018, Martin Liška wrote:
> So you prefer to come up with a plugin folder with the *.vim files?

Yes, the main reason being very simple installation if already using a
plugin manager. A plugin folder may contain a custom ftdetect/foo.vim,
so there's no need to edit .vimrc by hand.

If you prefer I can post patches to that effect after yours are applied.

Alexander
Martin Liška June 15, 2018, 7:31 p.m. UTC | #4
On 06/15/2018 06:18 PM, Alexander Monakov wrote:
> On Fri, 15 Jun 2018, Martin Liška wrote:
>> So you prefer to come up with a plugin folder with the *.vim files?
> 
> Yes, the main reason being very simple installation if already using a
> plugin manager. A plugin folder may contain a custom ftdetect/foo.vim,
> so there's no need to edit .vimrc by hand.
> 
> If you prefer I can post patches to that effect after yours are applied.

That would be great.

Martin

> 
> Alexander
>
Jeff Law June 18, 2018, 3:47 p.m. UTC | #5
On 06/15/2018 08:28 AM, Martin Liška wrote:
> On 06/15/2018 07:08 AM, Alexander Monakov wrote:
>> On Tue, 12 Jun 2018, Martin Liška wrote:
>>
>>> This is equivalent of gimple.vim file. I'm aware of not full coverage of RTL
>>> instructions, but hope it's a good start point.
>>
>> I think this is nice to have and hope you'll get an OK for both this and
>> the gimple.vim patch.
> 
> Hi.
> 
> Well, it's sitting in contrib, thus I'm planning to install that eventually
> if there will be not response.
> 
> 
>>
>> One nit-pick: unlike "GIMPLE", "RTL" is not a GCC-specific abbreviation.
>> I'd prefer to use gcc-rtl.vim to avoid possible clashes.
> 
> Good idea, let me fix that.
> 
>>
>> Do you use it quite literally as described in gimple.vim, i.e. with
>> editing ftdetect.vim by hand? I made a plugin for gcc/match.pd syntax
>> highlighting, and I opted to use a common plugin file layout for it.
>> That way, I only need to symlink the plugin directory under .vim/bundle.
> 
> I use it as follows:
> 
> vimrc:
> 
> au BufRead,BufNewFile *.[0-2][0-9][0-9][ti].* set filetype=gimple
> au BufRead,BufNewFile *.[2-3][0-9][0-9]r.* set filetype=rtl
> 
> Then I copied these .vim files into syntax folder. I know it's not ideal.
> For all other vim extensions I use plugin system (Dein) that installs plugins
> from github repos.
> 
> So you prefer to come up with a plugin folder with the *.vim files?
Whatever works best in terms of ease of use for someone that wants to
use the RTL (or gimple) modes.  If that means they need to be in a
subdir, that's fine with me.

jeff
Martin Liška June 19, 2018, 12:41 p.m. UTC | #6
On 06/15/2018 06:18 PM, Alexander Monakov wrote:
> On Fri, 15 Jun 2018, Martin Liška wrote:
>> So you prefer to come up with a plugin folder with the *.vim files?
> 
> Yes, the main reason being very simple installation if already using a
> plugin manager. A plugin folder may contain a custom ftdetect/foo.vim,
> so there's no need to edit .vimrc by hand.
> 
> If you prefer I can post patches to that effect after yours are applied.
> 
> Alexander
> 

Hi.

This is final version I'm going to install. Updates since last version:
- RTL modes added
- rtlInstruction should cover most of instructions we have (done via grepping
of DEF_RTL_EXPR).
- renamed to gcc-rtl.vim

Martin
From a0ee70489145ac20071452ac6e7f00066fdc0b7e Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 12 Jun 2018 13:38:27 +0200
Subject: [PATCH 1/2] Add initial version of rtl.vim syntax file.

contrib/ChangeLog:

2018-06-12  Martin Liska  <mliska@suse.cz>

	* gcc-rtl.vim: New file.
---
 contrib/gcc-rtl.vim | 79 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 contrib/gcc-rtl.vim

diff --git a/contrib/gcc-rtl.vim b/contrib/gcc-rtl.vim
new file mode 100644
index 00000000000..a325fafebbf
--- /dev/null
+++ b/contrib/gcc-rtl.vim
@@ -0,0 +1,79 @@
+" Syntax highlighting rules for RTL dump files (for Vim).
+"
+" 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
+"
+" For more instructions please see gimple.vim file in the same folder.
+
+
+" Do not continue, if syntax is already enabled in current buffer.
+if exists("b:current_syntax")
+    finish
+endif
+
+" General-purpose comments.
+syn match   rtlComment          ";;.*$"
+
+syn keyword rtlInstruction      debug_expr insn_list int_list sequence
+                                \ address debug_insn insn expr_list
+                                \ jump_table_data barrier code_label
+                                \ cond_exec parallel asm_input asm_operands
+                                \ unspec unspec_volatile addr_vec
+                                \ addr_diff_vec prefetch set use clobber
+                                \ call return simple_return eh_return
+                                \ trap_if scratch strict_low_part concat concatn
+                                \ mem label_ref symbol_ref cc0 compare plus minus
+                                \ neg mult ss_mult us_mult div ss_div us_div mod
+                                \ udiv umod and ior xor not ashift rotate ashiftrt
+                                \ lshiftrt rotatert smin smax umin umax pre_dec
+                                \ pre_inc post_dec post_inc pre_modify post_modify
+                                \ unordered ordered uneq unge ungt unle unlt ltgt sign_extend
+                                \ zero_extend truncate float_extend float_truncate
+                                \ float fix unsigned_float unsigned_fix fract_convert
+                                \ unsigned_fract_convert sat_fract unsigned_sat_fract
+                                \ abs sqrt bswap ffs clrsb clz ctz popcount parity
+                                \ sign_extract zero_extract high lo_sum vec_merge
+                                \ vec_select vec_concat vec_duplicate vec_series ss_plus
+                                \ us_plus ss_minus ss_neg us_neg ss_abs ss_ashift
+                                \ us_ashift us_minus ss_truncate us_truncate fma
+                                \ entry_value exclusion_set presence_set final_presence_set
+                                \ absence_set final_absence_set automata_option attr set_attr
+                                \ set_attr_alternative eq_attr eq_attr_alt attr_flag cond
+syn keyword rtlConditional      call_insn jump_insn if_then_else
+                                \ eq ne gt gtu lt ltu ge geu le leu
+syn keyword rtlNote             note barrier code_label
+syn keyword rtlVariableLoation  var_location
+syn keyword rtlPcRegister       pc
+
+syn keyword rtlModes		        VOID BLK BI QI HI SI DI TI SF DF CC QQ HQ SQ
+                                \ DQ TQ UQQ UHQ USQ UDQ UTQ HA SA DA TA UHA
+                                \ USA UDA UTA SD DD TD
+
+" String literals
+syn region  rtlString           start=/\v"/ skip=/\v\\./ end=/\v"/
+
+syn match   rtlNoteInsn         "NOTE_INSN_[A-Z_]*"
+syn match   rtlIntegerConstant  "\vconst_int -?\d+"
+syn match   rtlFloatConstant    "\vconst_double:[A-Z]+ -?\d*\.\d+(e\+\d+)?"
+syn match   rtlRegister         "\vreg(\/[a-z])?:[A-Z0-9]+ \d+ [a-z0-9]+"
+syn match   rtlLocation         /\v"[^"]*":\d+/
+
+hi def link rtlInstruction      Statement
+hi def link rtlConditional      Conditional
+hi def link rtlNote             Debug
+hi def link rtlNoteInsn         Debug
+hi def link rtlIntegerConstant  Number
+hi def link rtlFloatConstant    Number
+hi def link rtlRegister         Type
+hi def link rtlPcRegister       Type
+hi def link rtlModes            Type
+hi def link rtlVariableLoation  Debug
+hi def link rtlComment          Comment
+hi def link rtlLocation         Debug
+hi def link rtlString           String
+
+let b:current_syntax = "rtl"
diff mbox series

Patch

diff --git a/contrib/rtl.vim b/contrib/rtl.vim
new file mode 100644
index 00000000000..c584b56e3f3
--- /dev/null
+++ b/contrib/rtl.vim
@@ -0,0 +1,55 @@ 
+" Syntax highlighting rules for RTL dump files (for Vim).
+"
+" 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
+"
+" For more instructions please see gimple.vim file in the same folder.
+
+
+" Do not continue, if syntax is already enabled in current buffer.
+if exists("b:current_syntax")
+    finish
+endif
+
+" General-purpose comments.
+syn match   rtlComment          ";;.*$"
+
+syn keyword rtlInstruction      insn parallel_insn set mem simple_return plus
+                                \ clobber parallel compare minus xor subreg
+                                \ ashift ashiftrt lshiftrt symbol_reg
+                                \ zero_extend symbol_ref label_ref call
+                                \ vec_merge vec_duplicate vec_concat
+syn keyword rtlConditional      jump_insn  if_then_else call_insn eq
+syn keyword rtlNote             note barrier code_label
+syn keyword rtlVariableLoation  var_location
+syn keyword rtlExpressionList   expr_list
+syn keyword rtlPcRegister       pc
+
+" String literals
+syn region  rtlString           start=/\v"/ skip=/\v\\./ end=/\v"/
+
+syn match   rtlNoteInsn         "NOTE_INSN_[A-Z_]*"
+syn match   rtlIntegerConstant  "\vconst_int -?\d+"
+syn match   rtlFloatConstant    "\vconst_double:[A-Z]+ -?\d*\.\d+(e\+\d+)?"
+syn match   rtlRegister         "\vreg(\/[a-z])?:[A-Z0-9]+ \d+ [a-z0-9]+"
+syn match   rtlLocation         /\v"[^"]*":\d+/
+
+hi def link rtlInstruction      Statement
+hi def link rtlConditional      Conditional
+hi def link rtlNote             Debug
+hi def link rtlNoteInsn         Debug
+hi def link rtlIntegerConstant  Number
+hi def link rtlFloatConstant    Number
+hi def link rtlRegister         Type
+hi def link rtlPcRegister       Type
+hi def link rtlVariableLoation  Debug
+hi def link rtlExpressionList   Debug
+hi def link rtlComment          Comment
+hi def link rtlLocation         Debug
+hi def link rtlString           String
+
+let b:current_syntax = "rtl"