xref: /netbsd-src/external/gpl3/gcc.old/dist/contrib/vim-gcc-dev/syntax/gimple.vim (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1*627f7eb2Smrg" Syntax highlighting rules for GIMPLE dump files (for Vim).
2*627f7eb2Smrg"
3*627f7eb2Smrg" Copyright (C) 2015 Free Software Foundation, Inc.
4*627f7eb2Smrg"
5*627f7eb2Smrg" This script is free software; you can redistribute it and/or modify
6*627f7eb2Smrg" it under the terms of the GNU General Public License as published by
7*627f7eb2Smrg" the Free Software Foundation; either version 3, or (at your option)
8*627f7eb2Smrg" any later version
9*627f7eb2Smrg"
10*627f7eb2Smrg" This Vim script highlights syntax in debug dumps containing GIMPLE
11*627f7eb2Smrg" intermediate representation.  Such dumps are produced by GCC when
12*627f7eb2Smrg" it is invoked with -fdump-tree-* and/or -fdump-ipa-* switches.  Tested
13*627f7eb2Smrg" in Vim 7.4 (but should also work with earlier versions).
14*627f7eb2Smrg
15*627f7eb2Smrg
16*627f7eb2Smrg" Do not continue, if syntax is already enabled in current buffer.
17*627f7eb2Smrgif exists("b:current_syntax")
18*627f7eb2Smrg    finish
19*627f7eb2Smrgendif
20*627f7eb2Smrg
21*627f7eb2Smrg" If this variable is set to true, "Unknown tree" in -fdump-tree-original will
22*627f7eb2Smrg" be highlighted as an error.
23*627f7eb2Smrglet s:unknown_tree_is_error=0
24*627f7eb2Smrg
25*627f7eb2Smrg" Comments for Phi nodes, value ranges, use/def-chains, etc.
26*627f7eb2Smrgsyn match   gimpleAnnotation    "\v#.*$"
27*627f7eb2Smrg            \ contains=gimpleAnnotationOp, gimpleAnnotationMark,
28*627f7eb2Smrg            \ gimpleNumber, gimpleLineNo
29*627f7eb2Smrgsyn match   gimpleAnnotationMark    "#" contained
30*627f7eb2Smrgsyn keyword gimpleAnnotationOp    PHI VUSE VDEF RANGE PT USE CLB
31*627f7eb2Smrg            \ ALIGN MISALIGN NONZERO contained
32*627f7eb2Smrg
33*627f7eb2Smrg" General-purpose comments.
34*627f7eb2Smrgsyn match   gimpleComment       ";;.*$"
35*627f7eb2Smrg
36*627f7eb2Smrg" Types - mostly borrowed from original Vim syntax file for C
37*627f7eb2Smrgsyn keyword     gimpleType  int long short char void
38*627f7eb2Smrg            \ signed unsigned float double
39*627f7eb2Smrg            \ size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t
40*627f7eb2Smrg            \ clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t
41*627f7eb2Smrg            \ mbstate_t wctrans_t wint_t wctype_t
42*627f7eb2Smrg            \ _Bool bool _Complex complex _Imaginary imaginary
43*627f7eb2Smrg            \ int8_t int16_t int32_t int64_t
44*627f7eb2Smrg            \ uint8_t uint16_t uint32_t uint64_t
45*627f7eb2Smrg            \ int_least8_t int_least16_t int_least32_t int_least64_t
46*627f7eb2Smrg            \ uint_least8_t uint_least16_t uint_least32_t uint_least64_t
47*627f7eb2Smrg            \ int_fast8_t int_fast16_t int_fast32_t int_fast64_t
48*627f7eb2Smrg            \ uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
49*627f7eb2Smrg            \ intptr_t uintptr_t
50*627f7eb2Smrg            \ intmax_t uintmax_t
51*627f7eb2Smrg            \ __label__ __complex__ __volatile__
52*627f7eb2Smrg            \ char16_t char32_t sizetype __vtbl_ptr_type
53*627f7eb2Smrg
54*627f7eb2Smrg" C/C++-like control structures
55*627f7eb2Smrgsyn keyword gimpleStatement     goto return
56*627f7eb2Smrgsyn keyword gimpleConditional   if else
57*627f7eb2Smrgsyn keyword gimpleLoop          while
58*627f7eb2Smrgsyn keyword gimpleException     try catch finally
59*627f7eb2Smrg
60*627f7eb2Smrg" Special 'values'
61*627f7eb2Smrgsyn match   gimpleConstant      "{CLOBBER}"
62*627f7eb2Smrgsyn match   gimpleConstant      "{ref-all}"
63*627f7eb2Smrgsyn match   gimpleConstant      "{v}"
64*627f7eb2Smrg
65*627f7eb2Smrg" Blocks
66*627f7eb2Smrgsyn region  gimpleBlock         start="{" end="}" transparent fold
67*627f7eb2Smrg
68*627f7eb2Smrg" String literals
69*627f7eb2Smrgsyn region  gimpleString        start=/\v"/ skip=/\v\\./ end=/\v"/
70*627f7eb2Smrg
71*627f7eb2Smrg" GENERIC AST nodes
72*627f7eb2Smrgsyn keyword gimpleASTNode       BIT_FIELD_REF TARGET_EXPR expr_stmt
73*627f7eb2Smrg            \ NON_LVALUE_EXPR
74*627f7eb2Smrg            \ must_not_throw_expr eh_spec_block eh_filter
75*627f7eb2Smrg            \ eh_must_not_throw aggr_init_expr cleanup_point
76*627f7eb2Smrg
77*627f7eb2Smrgif s:unknown_tree_is_error
78*627f7eb2Smrg    syn match   gimpleUnknownTree   "\vUnknown tree: \w+"
79*627f7eb2Smrgend
80*627f7eb2Smrg
81*627f7eb2Smrg" Ignore probability of edges and basic blocks
82*627f7eb2Smrg"  <bb 2> [70.00%]:
83*627f7eb2Smrgsyn match   gimpleFrequency     " \[\d*\.\d*%\]"
84*627f7eb2Smrg
85*627f7eb2Smrg" Ignore basic block with a count
86*627f7eb2Smrg"  <bb 10> [local count: 118111601]:
87*627f7eb2Smrgsyn match   gimpleBBCount       "\v\[(local )?count: \d+\]"
88*627f7eb2Smrg
89*627f7eb2Smrg" Numbers
90*627f7eb2Smrgsyn match   gimpleNumber        "\v([^.a-zA-Z0-9_])\zs-?\d+B?"
91*627f7eb2Smrgsyn match   gimpleFloat         "\v\W\zs-?\d*\.\d+(e\+\d+)?"
92*627f7eb2Smrg
93*627f7eb2Smrg" Basic block label
94*627f7eb2Smrg" <bb 123>:
95*627f7eb2Smrgsyn match   gimpleLabel         "\v^\s*\zs\<bb \d+\>"
96*627f7eb2Smrg" <D.1234>:
97*627f7eb2Smrg" <L1>:
98*627f7eb2Smrgsyn match   gimpleLabel         "\v^\s*\zs\<[DL]\.?\d+\>"
99*627f7eb2Smrg" label: - user-defined label
100*627f7eb2Smrg" bb1L.1:
101*627f7eb2Smrgsyn match   gimpleLabel         "\v^\s*[a-zA-Z0-9._]+\ze:\s*$"
102*627f7eb2Smrg
103*627f7eb2Smrg" Match label after goto to suppress highlighting of numbers inside
104*627f7eb2Smrgsyn match   gimpleGotoLabel     "\v<bb \d+\>[^:]"
105*627f7eb2Smrg
106*627f7eb2Smrg" Line numbers, generated with -fdump-tree-*-lineno
107*627f7eb2Smrgsyn match   gimpleLineNo        "\v\[[^\]]+:\d+:\d+\]"
108*627f7eb2Smrg
109*627f7eb2Smrg" DEBUG statements
110*627f7eb2Smrgsyn match   gimpleDebug         "\v# DEBUG.*"
111*627f7eb2Smrg
112*627f7eb2Smrg" GIMPLE predict statement
113*627f7eb2Smrgsyn match   gimplePrediction    "\v\/\/ predicted.*"
114*627f7eb2Smrg
115*627f7eb2Smrg
116*627f7eb2Smrg" Misc C/C++-like keywords
117*627f7eb2Smrgsyn keyword gimpleStructure     struct union enum typedef class
118*627f7eb2Smrgsyn keyword gimpleStorageClass  static register auto volatile extern const
119*627f7eb2Smrg            \ template inline __attribute__ _Alignas alignas _Atomic
120*627f7eb2Smrg            \ _Thread_local thread_local _Alignof alignof sizeof
121*627f7eb2Smrg
122*627f7eb2Smrghi def link gimpleType          Type
123*627f7eb2Smrghi def link gimpleNumber        Number
124*627f7eb2Smrghi def link gimpleFloat         Float
125*627f7eb2Smrghi def link gimpleConstant      Constant
126*627f7eb2Smrghi def link gimpleStructure     Structure
127*627f7eb2Smrghi def link gimpleStorageClass  StorageClass
128*627f7eb2Smrghi def link gimpleOperator      Operator
129*627f7eb2Smrghi def link gimpleASTNode       Operator
130*627f7eb2Smrghi def link gimpleStatement     Statement
131*627f7eb2Smrghi def link gimpleConditional   Conditional
132*627f7eb2Smrghi def link gimpleLoop          Repeat
133*627f7eb2Smrghi def link gimpleException     Exception
134*627f7eb2Smrghi def link gimpleComment       Comment
135*627f7eb2Smrghi def link gimpleLineNo        Comment
136*627f7eb2Smrghi def link gimpleLabel         Label
137*627f7eb2Smrghi def link gimpleAnnotationOp  Debug
138*627f7eb2Smrghi def link gimpleAnnotationMark Debug
139*627f7eb2Smrghi def link gimpleString        String
140*627f7eb2Smrghi def link gimpleUnknownTree   Error
141*627f7eb2Smrghi def link gimpleDebug         Debug
142*627f7eb2Smrghi def link gimplePrediction    Debug
143*627f7eb2Smrghi def link gimpleFrequency     Debug
144*627f7eb2Smrghi def link gimpleBBCount       Debug
145*627f7eb2Smrg
146*627f7eb2Smrglet b:current_syntax = "gimple"
147