]> 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-2024 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 # If set, the 'global offload_target' specifies one specific offload target to
42 # test, otherwise iterate over all 'global offload_targets'.
43 proc scoff { args } {
44 set idx [lindex $args 0]
45 set prc [lindex $args 1]
46 set args [lreplace $args 0 1]
47
48 global offload_target
49 if [info exists offload_target] {
50 set target $offload_target
51 if { "$target" != "disable" } {
52 eval $prc [scoff-adjust $args $idx $target]
53 }
54 } else {
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
59
60 eval $prc [scoff-adjust $args $idx $target]
61 }
62 }
63 }
64
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]
70
71 global offload_target
72 if [info exists offload_target] {
73 set original_offload_target $offload_target
74 }
75 set offload_target $override_offload_target
76 eval $cmd
77 if [info exists original_offload_target] {
78 set offload_target $original_offload_target
79 } else {
80 unset offload_target
81 }
82 }