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. 28if exists("b:current_syntax") 29 finish 30endif 31 32" If this variable is set to true, "Unknown tree" in -fdump-tree-original will 33" be highlighted as an error. 34let s:unknown_tree_is_error=0 35 36" Comments for Phi nodes, value ranges, use/def-chains, etc. 37syn match gimpleAnnotation "\v#.*$" 38 \ contains=gimpleAnnotationOp, gimpleAnnotationMark, 39 \ gimpleNumber, gimpleLineNo 40syn match gimpleAnnotationMark "#" contained 41syn keyword gimpleAnnotationOp PHI VUSE VDEF RANGE PT USE CLB 42 \ ALIGN MISALIGN NONZERO contained 43 44" General-purpose comments. 45syn match gimpleComment ";;.*$" 46 47" Types - mostly borrowed from original Vim syntax file for C 48syn 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 66syn keyword gimpleStatement goto return 67syn keyword gimpleConditional if else 68syn keyword gimpleLoop while 69syn keyword gimpleException try catch finally 70 71" Special 'values' 72syn match gimpleConstant "{CLOBBER}" 73syn match gimpleConstant "{ref-all}" 74syn match gimpleConstant "{v}" 75 76" Blocks 77syn region gimpleBlock start="{" end="}" transparent fold 78 79" String literals 80syn region gimpleString start=/\v"/ skip=/\v\\./ end=/\v"/ 81 82" GENERIC AST nodes 83syn 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 88if s:unknown_tree_is_error 89 syn match gimpleUnknownTree "\vUnknown tree: \w+" 90end 91 92" Numbers 93syn match gimpleNumber "\v([^.a-zA-Z0-9_])\zs-?\d+B?" 94syn match gimpleFloat "\v\W\zs-?\d*\.\d+(e\+\d+)?" 95 96" Basic block label 97" <bb 123>: 98syn match gimpleLabel "\v^\s*\zs\<bb \d+\>" 99" <D.1234>: 100" <L1>: 101syn match gimpleLabel "\v^\s*\zs\<[DL]\.?\d+\>" 102" label: - user-defined label 103" bb1L.1: 104syn match gimpleLabel "\v^\s*[a-zA-Z0-9._]+\ze:\s*$" 105 106" Match label after goto to suppress highlighting of numbers inside 107syn match gimpleGotoLabel "\v<bb \d+\>[^:]" 108 109" Line numbers, generated with -fdump-tree-*-lineno 110syn match gimpleLineNo "\v\[[^\]]+:\d+:\d+\]" 111 112" Misc C/C++-like keywords 113syn keyword gimpleStructure struct union enum typedef class 114syn keyword gimpleStorageClass static register auto volatile extern const 115 \ template inline __attribute__ _Alignas alignas _Atomic 116 \ _Thread_local thread_local _Alignof alignof sizeof 117 118hi def link gimpleType Type 119hi def link gimpleNumber Number 120hi def link gimpleFloat Float 121hi def link gimpleConstant Constant 122hi def link gimpleStructure Structure 123hi def link gimpleStorageClass StorageClass 124hi def link gimpleOperator Operator 125hi def link gimpleASTNode Operator 126hi def link gimpleStatement Statement 127hi def link gimpleConditional Conditional 128hi def link gimpleLoop Repeat 129hi def link gimpleException Exception 130hi def link gimpleComment Comment 131hi def link gimpleLineNo Comment 132hi def link gimpleLabel Label 133hi def link gimpleAnnotationOp Debug 134hi def link gimpleAnnotationMark Debug 135hi def link gimpleString String 136hi def link gimpleUnknownTree Error 137 138let b:current_syntax = "gimple" 139 140