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