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