bool debug;
bool verbose;
bool save_temps;
+const char *dumppfx;
/* Notify user of a non-error. */
extern bool debug;
extern bool verbose;
extern bool save_temps;
+extern const char *dumppfx;
/* Provided by the tool itself. */
static const char *gcn_s2_name;
static const char *gcn_o_name;
static const char *gcn_cfile_name;
+static const char *gcn_dumpbase;
enum offload_abi offload_abi = OFFLOAD_ABI_UNSET;
obstack_ptr_grow (&argv_obstack, "-save-temps");
if (verbose)
obstack_ptr_grow (&argv_obstack, "-v");
+ obstack_ptr_grow (&argv_obstack, "-dumpdir");
+ obstack_ptr_grow (&argv_obstack, "");
+ obstack_ptr_grow (&argv_obstack, "-dumpbase");
+ obstack_ptr_grow (&argv_obstack, gcn_dumpbase);
+ obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
+ obstack_ptr_grow (&argv_obstack, ".c");
switch (offload_abi)
{
case OFFLOAD_ABI_LP64:
save_temps = true;
else if (strcmp (argv[i], "-v") == 0)
verbose = true;
+ else if (strcmp (argv[i], "-dumpbase") == 0
+ && i + 1 < argc)
+ dumppfx = argv[++i];
}
if (!(fopenacc ^ fopenmp))
fatal_error (input_location, "either -fopenacc or -fopenmp must be set");
gcc_unreachable ();
}
- gcn_s1_name = make_temp_file (".mkoffload.1.s");
- gcn_s2_name = make_temp_file (".mkoffload.2.s");
- gcn_o_name = make_temp_file (".mkoffload.hsaco");
- gcn_cfile_name = make_temp_file (".c");
-
/* Build arguments for compiler pass. */
struct obstack cc_argv_obstack;
obstack_init (&cc_argv_obstack);
obstack_ptr_grow (&cc_argv_obstack, argv[ix]);
}
+ if (!dumppfx)
+ dumppfx = outname;
+
+ const char *mko_dumpbase = concat (dumppfx, ".mkoffload", NULL);
+ const char *hsaco_dumpbase = concat (dumppfx, ".mkoffload.hsaco", NULL);
+ gcn_dumpbase = concat (dumppfx, ".c", NULL);
+
+ if (save_temps)
+ {
+ gcn_s1_name = concat (mko_dumpbase, ".1.s", NULL);
+ gcn_s2_name = concat (mko_dumpbase, ".2.s", NULL);
+ gcn_o_name = hsaco_dumpbase;
+ gcn_cfile_name = gcn_dumpbase;
+ }
+ else
+ {
+ gcn_s1_name = make_temp_file (".mkoffload.1.s");
+ gcn_s2_name = make_temp_file (".mkoffload.2.s");
+ gcn_o_name = make_temp_file (".mkoffload.hsaco");
+ gcn_cfile_name = make_temp_file (".c");
+ }
+
+ obstack_ptr_grow (&cc_argv_obstack, "-dumpdir");
+ obstack_ptr_grow (&cc_argv_obstack, "");
+ obstack_ptr_grow (&cc_argv_obstack, "-dumpbase");
+ obstack_ptr_grow (&cc_argv_obstack, mko_dumpbase);
+ obstack_ptr_grow (&cc_argv_obstack, "-dumpbase-ext");
+ obstack_ptr_grow (&cc_argv_obstack, "");
+
obstack_ptr_grow (&cc_argv_obstack, "-o");
obstack_ptr_grow (&cc_argv_obstack, gcn_s1_name);
obstack_ptr_grow (&cc_argv_obstack, NULL);
|| strncmp (argv[i], "-march", 6) == 0)
obstack_ptr_grow (&ld_argv_obstack, argv[i]);
+ obstack_ptr_grow (&cc_argv_obstack, "-dumpdir");
+ obstack_ptr_grow (&cc_argv_obstack, "");
+ obstack_ptr_grow (&cc_argv_obstack, "-dumpbase");
+ obstack_ptr_grow (&cc_argv_obstack, hsaco_dumpbase);
+ obstack_ptr_grow (&cc_argv_obstack, "-dumpbase-ext");
+ obstack_ptr_grow (&cc_argv_obstack, "");
+
obstack_ptr_grow (&ld_argv_obstack, "-o");
obstack_ptr_grow (&ld_argv_obstack, gcn_o_name);
obstack_ptr_grow (&ld_argv_obstack, NULL);
/* Files to unlink. */
static const char *ptx_name;
static const char *ptx_cfile_name;
+static const char *ptx_dumpbase;
enum offload_abi offload_abi = OFFLOAD_ABI_UNSET;
obstack_ptr_grow (&argv_obstack, "-save-temps");
if (verbose)
obstack_ptr_grow (&argv_obstack, "-v");
+ obstack_ptr_grow (&argv_obstack, "-dumpdir");
+ obstack_ptr_grow (&argv_obstack, "");
+ obstack_ptr_grow (&argv_obstack, "-dumpbase");
+ obstack_ptr_grow (&argv_obstack, ptx_dumpbase);
+ obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
+ obstack_ptr_grow (&argv_obstack, ".c");
switch (offload_abi)
{
case OFFLOAD_ABI_LP64:
save_temps = true;
else if (strcmp (argv[i], "-v") == 0)
verbose = true;
+ else if (strcmp (argv[i], "-dumpbase") == 0
+ && i + 1 < argc)
+ dumppfx = argv[++i];
}
if (!(fopenacc ^ fopenmp))
fatal_error (input_location, "either %<-fopenacc%> or %<-fopenmp%> "
obstack_ptr_grow (&argv_obstack, argv[ix]);
}
- ptx_cfile_name = make_temp_file (".c");
+ if (!dumppfx)
+ dumppfx = outname;
+
+ ptx_dumpbase = concat (dumppfx, ".c", NULL);
+ if (save_temps)
+ ptx_cfile_name = ptx_dumpbase;
+ else
+ ptx_cfile_name = make_temp_file (".c");
out = fopen (ptx_cfile_name, "w");
if (!out)
configurations. */
if (offload_abi == OFFLOAD_ABI_LP64)
{
- ptx_name = make_temp_file (".mkoffload");
+ char *mko_dumpbase = concat (dumppfx, ".mkoffload", NULL);
+ if (save_temps)
+ ptx_name = mko_dumpbase;
+ else
+ ptx_name = make_temp_file (".mkoffload");
+ obstack_ptr_grow (&argv_obstack, "-dumpdir");
+ obstack_ptr_grow (&argv_obstack, "");
+ obstack_ptr_grow (&argv_obstack, "-dumpbase");
+ obstack_ptr_grow (&argv_obstack, mko_dumpbase);
+ obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
+ obstack_ptr_grow (&argv_obstack, "");
obstack_ptr_grow (&argv_obstack, "-o");
obstack_ptr_grow (&argv_obstack, ptx_name);
obstack_ptr_grow (&argv_obstack, NULL);
unsigned int linker_opt_count)
{
char *filename = NULL;
+ char *dumpbase;
char **argv;
char *suffix
= XALLOCAVEC (char, sizeof ("/accel//mkoffload") + strlen (target));
"could not find %s in %s (consider using %<-B%>)",
suffix + 1, compiler_path);
+ dumpbase = concat (dumppfx, "x", target, NULL);
+
/* Generate temporary output file name. */
- filename = make_temp_file (".target.o");
+ if (save_temps)
+ filename = concat (dumpbase, ".o", NULL);
+ else
+ filename = make_temp_file (".target.o");
struct obstack argv_obstack;
obstack_init (&argv_obstack);
compiler_opt_count);
append_diag_options (&argv_obstack, linker_opts, linker_opt_count);
+ obstack_ptr_grow (&argv_obstack, "-dumpbase");
+ obstack_ptr_grow (&argv_obstack, dumpbase);
+
/* Append options specified by -foffload last. In case of conflicting
options we expect offload compiler to choose the latest. */
append_offload_options (&argv_obstack, target, compiler_opts,
bool linker_output_rel = false;
bool skip_debug = false;
unsigned n_debugobj;
- const char *dumppfx = NULL, *incoming_dumppfx = NULL;
+ const char *incoming_dumppfx = dumppfx = NULL;
static char current_dir[] = { '.', DIR_SEPARATOR, '\0' };
/* Get the driver and options. */
--- /dev/null
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Utility for scanning offloading dump output, used by libgomp.exp.
+
+# Format an offload dump suffix given the offload target name in
+# OFFTGT and any suffix, probably empty, in SUFFIX.
+proc scoff-format { offtgt suffix } {
+ return ".x$offtgt.mkoffload$suffix"
+}
+
+# Wrapper for scan procs.
+# Argument 0 is the index of the argument to replace when calling
+# argument 1 with the remaining arguments. Use end-1 or end or so.
+proc scoff { args } {
+ set idx [lindex $args 0]
+ set prc [lindex $args 1]
+ set args [lreplace $args 0 1]
+
+ global offload_target
+ if [info exists offload_target] {
+ set target $offload_target
+ if { "$target" != "disable" } {
+ eval $prc [lreplace $args $idx $idx "[scoff-format $target [lindex $args $idx]]"]
+ }
+ } else {
+ global offload_targets
+ foreach target [split $offload_targets ","] {
+ eval $prc [lreplace $args $idx $idx "[scoff-format $target [lindex $args $idx]]"]
+ }
+ }
+}
# libgomp.exp.
load_lib scandump.exp
+load_lib scanoffload.exp
# Utility for scanning compiler result, invoked via dg-final.
# Call pass if pattern is present, otherwise fail.
return
}
if { [llength $args] >= 3 } {
- scan-dump "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o"
+ scoff end scan-dump "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
}
}
return
}
if { [llength $args] >= 4 } {
- scan-dump-times "offload-rtl" [lindex $args 0] [lindex $args 1] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" ".o" \
+ scoff end-1 scan-dump-times "offload-rtl" [lindex $args 0] \
+ [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" "" \
[lindex $args 3]
} else {
- scan-dump-times "offload-rtl" [lindex $args 0] [lindex $args 1] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" ".o"
+ scoff end scan-dump-times "offload-rtl" [lindex $args 0] \
+ [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" ""
}
}
return
}
if { [llength $args] >= 3 } {
- scan-dump-not "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump-not "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump-not "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o"
+ scoff end scan-dump-not "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
}
}
return
}
if { [llength $args] >= 3 } {
- scan-dump-dem "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump-dem "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump-dem "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o"
+ scoff end scan-dump-dem "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
}
}
return
}
if { [llength $args] >= 3 } {
- scan-dump-dem-not "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump-dem-not "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump-dem-not "offload-rtl" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".o"
+ scoff end scan-dump-dem-not "offload-rtl" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
}
}
# libgomp.exp.
load_lib scandump.exp
+load_lib scanoffload.exp
# Utility for scanning compiler result, invoked via dg-final.
# Call pass if pattern is present, otherwise fail.
return
}
if { [llength $args] >= 3 } {
- scan-dump "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o"
+ scoff end scan-dump "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
}
}
return
}
if { [llength $args] >= 4 } {
- scan-dump-times "offload-tree" [lindex $args 0] [lindex $args 1] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" ".o" \
- [lindex $args 3]
+ scoff end-1 scan-dump-times "offload-tree" [lindex $args 0] \
+ [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" "" \
+ [lindex $args 3]
} else {
- scan-dump-times "offload-tree" [lindex $args 0] [lindex $args 1] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" ".o"
+ scoff end scan-dump-times "offload-tree" [lindex $args 0] \
+ [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" ""
}
}
return
}
if { [llength $args] >= 3 } {
- scan-dump-not "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump-not "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump-not "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o"
+ scoff end scan-dump-not "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
}
}
return
}
if { [llength $args] >= 3 } {
- scan-dump-dem "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump-dem "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump-dem "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o"
+ scoff end scan-dump-dem "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
}
}
return
}
if { [llength $args] >= 3 } {
- scan-dump-dem-not "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o" \
- [lindex $args 2]
+ scoff end-1 scan-dump-dem-not "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
+ [lindex $args 2]
} else {
- scan-dump-dem-not "offload-tree" [lindex $args 0] \
- "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".o"
+ scoff end scan-dump-dem-not "offload-tree" [lindex $args 0] \
+ "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
}
}
proc libgomp-dg-test { prog do_what extra_tool_flags } {
- # Force the dumpbase for test.c to test.o, such that scan-offload-*-dump
- # will work.
- foreach opt $extra_tool_flags {
- if { [regexp ^-foffload=-fdump- $opt] } {
- lappend extra_tool_flags "-save-temps"
- }
- }
-
return [gcc-dg-test-1 libgomp_target_compile $prog $do_what $extra_tool_flags]
}
load_gcc_lib scanrtl.exp
load_gcc_lib scantree.exp
load_gcc_lib scanltranstree.exp
+load_gcc_lib scanoffload.exp
load_gcc_lib scanoffloadtree.exp
load_gcc_lib scanoffloadrtl.exp
load_gcc_lib scanipa.exp