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 16" Do not continue, if syntax is already enabled in current buffer. 17if exists("b:current_syntax") 18 finish 19endif 20 21" If this variable is set to true, "Unknown tree" in -fdump-tree-original will 22" be highlighted as an error. 23let s:unknown_tree_is_error=0 24 25" Comments for Phi nodes, value ranges, use/def-chains, etc. 26syn match gimpleAnnotation "\v#.*$" 27 \ contains=gimpleAnnotationOp, gimpleAnnotationMark, 28 \ gimpleNumber, gimpleLineNo 29syn match gimpleAnnotationMark "#" contained 30syn keyword gimpleAnnotationOp PHI VUSE VDEF RANGE PT USE CLB 31 \ ALIGN MISALIGN NONZERO contained 32 33" General-purpose comments. 34syn match gimpleComment ";;.*$" 35 36" Types - mostly borrowed from original Vim syntax file for C 37syn 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 55syn keyword gimpleStatement goto return 56syn keyword gimpleConditional if else 57syn keyword gimpleLoop while 58syn keyword gimpleException try catch finally 59 60" Special 'values' 61syn match gimpleConstant "{CLOBBER}" 62syn match gimpleConstant "{ref-all}" 63syn match gimpleConstant "{v}" 64 65" Blocks 66syn region gimpleBlock start="{" end="}" transparent fold 67 68" String literals 69syn region gimpleString start=/\v"/ skip=/\v\\./ end=/\v"/ 70 71" GENERIC AST nodes 72syn 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 77if s:unknown_tree_is_error 78 syn match gimpleUnknownTree "\vUnknown tree: \w+" 79end 80 81" Ignore probability of edges and basic blocks 82" <bb 2> [70.00%]: 83syn match gimpleFrequency " \[\d*\.\d*%\]" 84 85" Ignore basic block with a count 86" <bb 10> [local count: 118111601]: 87syn match gimpleBBCount "\v\[(local )?count: \d+\]" 88 89" Numbers 90syn match gimpleNumber "\v([^.a-zA-Z0-9_])\zs-?\d+B?" 91syn match gimpleFloat "\v\W\zs-?\d*\.\d+(e\+\d+)?" 92 93" Basic block label 94" <bb 123>: 95syn match gimpleLabel "\v^\s*\zs\<bb \d+\>" 96" <D.1234>: 97" <L1>: 98syn match gimpleLabel "\v^\s*\zs\<[DL]\.?\d+\>" 99" label: - user-defined label 100" bb1L.1: 101syn match gimpleLabel "\v^\s*[a-zA-Z0-9._]+\ze:\s*$" 102 103" Match label after goto to suppress highlighting of numbers inside 104syn match gimpleGotoLabel "\v<bb \d+\>[^:]" 105 106" Line numbers, generated with -fdump-tree-*-lineno 107syn match gimpleLineNo "\v\[[^\]]+:\d+:\d+\]" 108 109" DEBUG statements 110syn match gimpleDebug "\v# DEBUG.*" 111 112" GIMPLE predict statement 113syn match gimplePrediction "\v\/\/ predicted.*" 114 115 116" Misc C/C++-like keywords 117syn keyword gimpleStructure struct union enum typedef class 118syn keyword gimpleStorageClass static register auto volatile extern const 119 \ template inline __attribute__ _Alignas alignas _Atomic 120 \ _Thread_local thread_local _Alignof alignof sizeof 121 122hi def link gimpleType Type 123hi def link gimpleNumber Number 124hi def link gimpleFloat Float 125hi def link gimpleConstant Constant 126hi def link gimpleStructure Structure 127hi def link gimpleStorageClass StorageClass 128hi def link gimpleOperator Operator 129hi def link gimpleASTNode Operator 130hi def link gimpleStatement Statement 131hi def link gimpleConditional Conditional 132hi def link gimpleLoop Repeat 133hi def link gimpleException Exception 134hi def link gimpleComment Comment 135hi def link gimpleLineNo Comment 136hi def link gimpleLabel Label 137hi def link gimpleAnnotationOp Debug 138hi def link gimpleAnnotationMark Debug 139hi def link gimpleString String 140hi def link gimpleUnknownTree Error 141hi def link gimpleDebug Debug 142hi def link gimplePrediction Debug 143hi def link gimpleFrequency Debug 144hi def link gimpleBBCount Debug 145 146let b:current_syntax = "gimple" 147