]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/lib/scanoffload.exp
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / lib / scanoffload.exp
1 # Copyright (C) 2020-2023 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 # Utility for scanning offloading dump output, used by libgomp.exp.
18
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"
23 }
24
25 # Adjust an offload dump TESTNAME for offload TARGET.
26 proc scoff-testname { target testname } {
27 return "$target-$testname"
28 }
29
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]]"
35 return $args
36 }
37
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 proc scoff { args } {
42 set idx [lindex $args 0]
43 set prc [lindex $args 1]
44 set args [lreplace $args 0 1]
45
46 global offload_target
47 if [info exists offload_target] {
48 set target $offload_target
49 if { "$target" != "disable" } {
50 eval $prc [scoff-adjust $args $idx $target]
51 }
52 } else {
53 global offload_targets
54 foreach target [split $offload_targets ","] {
55 # HSA offloading is doing things differently, doesn't use 'mkoffload'.
56 if { "$target" == "hsa" } continue
57
58 eval $prc [scoff-adjust $args $idx $target]
59 }
60 }
61 }