1# Copyright (C) 2018-2021 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with GCC; see the file COPYING3. If not see 15# <http://www.gnu.org/licenses/>. 16 17# Various utilities for scanning ipa dump output, used by gcc-dg.exp and 18# g++-dg.exp. 19 20load_lib scandump.exp 21 22# Utility for scanning compiler result, invoked via dg-final. 23# Call pass if pattern is present, otherwise fail. 24# 25# Argument 0 is the regexp to match 26# Argument 1 is the name of the dumped ipa pass 27# Argument 2 handles expected failures and the like 28proc scan-wpa-ipa-dump { args } { 29 30 if { [llength $args] < 2 } { 31 error "scan-wpa-ipa-dump: too few arguments" 32 return 33 } 34 if { [llength $args] > 3 } { 35 error "scan-wpa-ipa-dump: too many arguments" 36 return 37 } 38 if { [llength $args] >= 3 } { 39 scan-dump "wpa-ipa" [lindex $args 0] \ 40 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" \ 41 [lindex $args 2] 42 } else { 43 scan-dump "wpa-ipa" [lindex $args 0] \ 44 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" 45 } 46} 47 48# Argument 0 is the regexp to match 49# Argument 1 is the name of the dumped ipa pass 50# Argument 2 handles expected failures and the like 51proc scan-pgo-wpa-ipa-dump { args } { 52 53 if { [llength $args] < 2 } { 54 error "scan-pgo-wpa-ipa-dump: too few arguments" 55 return 56 } 57 if { [llength $args] > 3 } { 58 error "scan-pgo-wpa-ipa-dump: too many arguments" 59 return 60 } 61 if { [llength $args] >= 3 } { 62 scan-dump "pgo-wpa-ipa" [lindex $args 0] \ 63 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" \ 64 [lindex $args 2] 65 } else { 66 scan-dump "pgo-wpa-ipa" [lindex $args 0] \ 67 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" 68 } 69} 70 71# Call pass if pattern is present given number of times, otherwise fail. 72# Argument 0 is the regexp to match 73# Argument 1 is number of times the regexp must be found 74# Argument 2 is the name of the dumped ipa pass 75# Argument 3 handles expected failures and the like 76proc scan-wpa-ipa-dump-times { args } { 77 78 if { [llength $args] < 3 } { 79 error "scan-wpa-ipa-dump-times: too few arguments" 80 return 81 } 82 if { [llength $args] > 4 } { 83 error "scan-wpa-ipa-dump-times: too many arguments" 84 return 85 } 86 if { [llength $args] >= 4 } { 87 scan-dump-times "wpa-ipa" [lindex $args 0] [lindex $args 1] \ 88 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 2]" ".wpa" \ 89 [lindex $args 3] 90 } else { 91 scan-dump-times "wpa-ipa" [lindex $args 0] [lindex $args 1] \ 92 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 2]" ".wpa" 93 } 94} 95 96# Call pass if pattern is not present, otherwise fail. 97# 98# Argument 0 is the regexp to match 99# Argument 1 is the name of the dumped ipa pass 100# Argument 2 handles expected failures and the like 101proc scan-wpa-ipa-dump-not { args } { 102 103 if { [llength $args] < 2 } { 104 error "scan-wpa-ipa-dump-not: too few arguments" 105 return 106 } 107 if { [llength $args] > 3 } { 108 error "scan-wpa-ipa-dump-not: too many arguments" 109 return 110 } 111 if { [llength $args] >= 3 } { 112 scan-dump-not "wpa-ipa" [lindex $args 0] \ 113 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" \ 114 [lindex $args 2] 115 } else { 116 scan-dump-not "wpa-ipa" [lindex $args 0] \ 117 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" 118 } 119} 120 121# Utility for scanning demangled compiler result, invoked via dg-final. 122# Call pass if pattern is present, otherwise fail. 123# 124# Argument 0 is the regexp to match 125# Argument 1 is the name of the dumped ipa pass 126# Argument 2 handles expected failures and the like 127proc scan-wpa-ipa-dump-dem { args } { 128 129 if { [llength $args] < 2 } { 130 error "scan-wpa-ipa-dump-dem: too few arguments" 131 return 132 } 133 if { [llength $args] > 3 } { 134 error "scan-wpa-ipa-dump-dem: too many arguments" 135 return 136 } 137 if { [llength $args] >= 3 } { 138 scan-dump-dem "wpa-ipa" [lindex $args 0] \ 139 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" \ 140 [lindex $args 2] 141 } else { 142 scan-dump-dem "wpa-ipa" [lindex $args 0] \ 143 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" 144 } 145} 146 147# Call pass if demangled pattern is not present, otherwise fail. 148# 149# Argument 0 is the regexp to match 150# Argument 1 is the name of the dumped ipa pass 151# Argument 2 handles expected failures and the like 152proc scan-wpa-ipa-dump-dem-not { args } { 153 154 if { [llength $args] < 2 } { 155 error "scan-wpa-ipa-dump-dem-not: too few arguments" 156 return 157 } 158 if { [llength $args] > 3 } { 159 error "scan-wpa-ipa-dump-dem-not: too many arguments" 160 return 161 } 162 if { [llength $args] >= 3 } { 163 scan-dump-dem-not "wpa-ipa" [lindex $args 0] \ 164 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" \ 165 [lindex $args 2] 166 } else { 167 scan-dump-dem-not "wpa-ipa" [lindex $args 0] \ 168 "\[0-9\]\[0-9\]\[0-9\]i.[lindex $args 1]" ".wpa" 169 } 170} 171