1 # Copyright
(C
) 2020-2023 Free Software Foundation
, Inc.
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.
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.
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
/>.
17 # Utility
for scanning offloading dump output
, used by libgomp.exp.
19 # Format an offload dump suffix given the offload target
name in
20 # OFFTGT and
any suffix
, probably empty
, in SUFFIX.
21 proc scoff
-format
{ offtgt suffix
} {
22 return ".x$offtgt.mkoffload$suffix"
25 # Adjust an offload dump TESTNAME
for offload TARGET.
26 proc scoff
-testname
{ target testname
} {
27 return "$target-$testname"
30 # Adjust the arglist
ARGS, so that
argument IDX gets scoff
-formatted
,
31 # and
argument 0 (the test
name) gets scoff
-testnamed.
32 proc scoff
-adjust
{ args idx target
} {
33 lset
args $idx
"[scoff-format $target [lindex $args $idx]]"
34 lset
args 0 "[scoff-testname $target [lindex $args 0]]"
38 # Wrapper
for scan procs.
39 #
Argument 0 is the index of the
argument to replace when calling
40 #
argument 1 with the remaining arguments. Use end
-1 or end or so.
41 #
If set, the
'global offload_target' specifies one specific offload target to
42 # test
, otherwise iterate over all
'global offload_targets'.
44 set idx
[lindex $
args 0]
45 set prc
[lindex $
args 1]
46 set args [lreplace $
args 0 1]
49 if [info exists offload_target
] {
50 set target $offload_target
51 if { "$target" != "disable" } {
52 eval $prc
[scoff
-adjust $
args $idx $target
]
55 global offload_targets
56 foreach target
[split $offload_targets
","] {
57 # HSA offloading is doing things differently
, doesn
't use 'mkoffload
'.
58 if { "$target" == "hsa" } continue
60 eval $prc [scoff-adjust $args $idx $target]
65 # Wrapper so that only for a specific offload target (first argument) we
66 # execute a 'dg
-final
' command (remaining arguments).
67 proc only_for_offload_target { args } {
68 set override_offload_target [lindex $args 0]
69 set cmd [lreplace $args 0 0]
72 if [info exists offload_target] {
73 set original_offload_target $offload_target
75 set offload_target $override_offload_target
77 if [info exists original_offload_target] {
78 set offload_target $original_offload_target