Hi! On Mon, 28 Sep 2015 12:19:41 +0200, Bernd Schmidt <bschm...@redhat.com> wrote: > > Use gcc/coretypes.h:enum offload_abi in mkoffloads
> > + abort (); > > Can we have gcc_unreachable() in these tools? Good suggestion, thanks! > Other than that, it looks ok but it also doesn't seem to do anything. Thanks for the review. This refactoring patch happend to come into existance when I worked on the other mkoffload patches that I recently posted, and as I considered it an improvement in its own right, I posted it. > Are you intending to add more ABIs? As I had quoted in my previous email, H.J. Lu expressed an interest in supporting the x32 ABI, <http://news.gmane.org/find-root.php?message_id=%3CCAMe9rOoG5e2NHusRggT-5BN4O_kszixEduK-S%2BU72JPjNv4LPA%40mail.gmail.com%3E>, which is now more easy to do than before. With the abort calls replaced with gcc_unreachable, committed in r228283: commit dc0452858cb0d7f56fada1bb2f795f92cd551795 Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed Sep 30 08:58:04 2015 +0000 Use gcc/coretypes.h:enum offload_abi in mkoffloads gcc/ * config/i386/intelmic-mkoffload.c (target_ilp32): Remove variable, replacing it with... (offload_abi): ... this new variable. Adjust all users. * config/nvptx/mkoffload.c (target_ilp32, offload_abi): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228283 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++ gcc/config/i386/intelmic-mkoffload.c | 90 ++++++++++++++++++++++++------------ gcc/config/nvptx/mkoffload.c | 56 +++++++++++++++------- 3 files changed, 108 insertions(+), 45 deletions(-) diff --git gcc/ChangeLog gcc/ChangeLog index e24c7bc..d29e5d9 100644 --- gcc/ChangeLog +++ gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-09-30 Thomas Schwinge <tho...@codesourcery.com> + + * config/i386/intelmic-mkoffload.c (target_ilp32): Remove + variable, replacing it with... + (offload_abi): ... this new variable. Adjust all users. + * config/nvptx/mkoffload.c (target_ilp32, offload_abi): Likewise. + 2015-09-30 Matthias Klose <d...@ubuntu.com> * configure.ac: Remove extraneous ;;. diff --git gcc/config/i386/intelmic-mkoffload.c gcc/config/i386/intelmic-mkoffload.c index 4a7812c..065d408 100644 --- gcc/config/i386/intelmic-mkoffload.c +++ gcc/config/i386/intelmic-mkoffload.c @@ -42,8 +42,7 @@ int num_temps = 0; const int MAX_NUM_TEMPS = 10; const char *temp_files[MAX_NUM_TEMPS]; -/* Shows if we should compile binaries for i386 instead of x86-64. */ -bool target_ilp32 = false; +enum offload_abi offload_abi = OFFLOAD_ABI_UNSET; /* Delete tempfiles and exit function. */ void @@ -200,10 +199,17 @@ out: static void compile_for_target (struct obstack *argv_obstack) { - if (target_ilp32) - obstack_ptr_grow (argv_obstack, "-m32"); - else - obstack_ptr_grow (argv_obstack, "-m64"); + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + obstack_ptr_grow (argv_obstack, "-m64"); + break; + case OFFLOAD_ABI_ILP32: + obstack_ptr_grow (argv_obstack, "-m32"); + break; + default: + gcc_unreachable (); + } obstack_ptr_grow (argv_obstack, NULL); char **argv = XOBFINISH (argv_obstack, char **); @@ -379,10 +385,17 @@ generate_host_descr_file (const char *host_compiler) new_argv[new_argc++] = "-c"; new_argv[new_argc++] = "-fPIC"; new_argv[new_argc++] = "-shared"; - if (target_ilp32) - new_argv[new_argc++] = "-m32"; - else - new_argv[new_argc++] = "-m64"; + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + new_argv[new_argc++] = "-m64"; + break; + case OFFLOAD_ABI_ILP32: + new_argv[new_argc++] = "-m32"; + break; + default: + gcc_unreachable (); + } new_argv[new_argc++] = src_filename; new_argv[new_argc++] = "-o"; new_argv[new_argc++] = obj_filename; @@ -442,10 +455,17 @@ prepare_target_image (const char *target_compiler, int argc, char **argv) objcopy_argv[3] = "-I"; objcopy_argv[4] = "binary"; objcopy_argv[5] = "-O"; - if (target_ilp32) - objcopy_argv[6] = "elf32-i386"; - else - objcopy_argv[6] = "elf64-x86-64"; + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + objcopy_argv[6] = "elf64-x86-64"; + break; + case OFFLOAD_ABI_ILP32: + objcopy_argv[6] = "elf32-i386"; + break; + default: + gcc_unreachable (); + } objcopy_argv[7] = target_so_filename; objcopy_argv[8] = "--rename-section"; objcopy_argv[9] = rename_section_opt; @@ -518,17 +538,22 @@ main (int argc, char **argv) passed with @file. Expand them into argv before processing. */ expandargv (&argc, &argv); - /* Find out whether we should compile binaries for i386 or x86-64. */ - for (int i = argc - 1; i > 0; i--) - if (strncmp (argv[i], "-foffload-abi=", sizeof ("-foffload-abi=") - 1) == 0) - { - if (strstr (argv[i], "ilp32")) - target_ilp32 = true; - else if (!strstr (argv[i], "lp64")) - fatal_error (input_location, - "unrecognizable argument of option -foffload-abi"); - break; - } + /* Scan the argument vector. */ + for (int i = 1; i < argc; i++) + { +#define STR "-foffload-abi=" + if (strncmp (argv[i], STR, strlen (STR)) == 0) + { + if (strcmp (argv[i] + strlen (STR), "lp64") == 0) + offload_abi = OFFLOAD_ABI_LP64; + else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0) + offload_abi = OFFLOAD_ABI_ILP32; + else + fatal_error (input_location, + "unrecognizable argument of option " STR); + } +#undef STR + } const char *target_so_filename = prepare_target_image (target_compiler, argc, argv); @@ -541,10 +566,17 @@ main (int argc, char **argv) const char *new_argv[9]; new_argv[new_argc++] = "ld"; new_argv[new_argc++] = "-m"; - if (target_ilp32) - new_argv[new_argc++] = "elf_i386"; - else - new_argv[new_argc++] = "elf_x86_64"; + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + new_argv[new_argc++] = "elf_x86_64"; + break; + case OFFLOAD_ABI_ILP32: + new_argv[new_argc++] = "elf_i386"; + break; + default: + gcc_unreachable (); + } new_argv[new_argc++] = "--relocatable"; new_argv[new_argc++] = host_descr_filename; new_argv[new_argc++] = target_so_filename; diff --git gcc/config/nvptx/mkoffload.c gcc/config/nvptx/mkoffload.c index e0ff8fc..fe0e8cd 100644 --- gcc/config/nvptx/mkoffload.c +++ gcc/config/nvptx/mkoffload.c @@ -126,8 +126,7 @@ static id_map *var_ids, **vars_tail = &var_ids; static const char *ptx_name; static const char *ptx_cfile_name; -/* Shows if we should compile binaries for i386 instead of x86-64. */ -bool target_ilp32 = false; +enum offload_abi offload_abi = OFFLOAD_ABI_UNSET; /* Delete tempfiles. */ @@ -926,7 +925,17 @@ compile_native (const char *infile, const char *outfile, const char *compiler) struct obstack argv_obstack; obstack_init (&argv_obstack); obstack_ptr_grow (&argv_obstack, compiler); - obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + obstack_ptr_grow (&argv_obstack, "-m64"); + break; + case OFFLOAD_ABI_ILP32: + obstack_ptr_grow (&argv_obstack, "-m32"); + break; + default: + gcc_unreachable (); + } obstack_ptr_grow (&argv_obstack, infile); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-o"); @@ -1004,23 +1013,38 @@ main (int argc, char **argv) passed with @file. Expand them into argv before processing. */ expandargv (&argc, &argv); - /* Find out whether we should compile binaries for i386 or x86-64. */ - for (int i = argc - 1; i > 0; i--) - if (strncmp (argv[i], "-foffload-abi=", sizeof ("-foffload-abi=") - 1) == 0) - { - if (strstr (argv[i], "ilp32")) - target_ilp32 = true; - else if (!strstr (argv[i], "lp64")) - fatal_error (input_location, - "unrecognizable argument of option -foffload-abi"); - break; - } + /* Scan the argument vector. */ + for (int i = 1; i < argc; i++) + { +#define STR "-foffload-abi=" + if (strncmp (argv[i], STR, strlen (STR)) == 0) + { + if (strcmp (argv[i] + strlen (STR), "lp64") == 0) + offload_abi = OFFLOAD_ABI_LP64; + else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0) + offload_abi = OFFLOAD_ABI_ILP32; + else + fatal_error (input_location, + "unrecognizable argument of option " STR); + } +#undef STR + } struct obstack argv_obstack; obstack_init (&argv_obstack); obstack_ptr_grow (&argv_obstack, driver); obstack_ptr_grow (&argv_obstack, "-xlto"); - obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + obstack_ptr_grow (&argv_obstack, "-m64"); + break; + case OFFLOAD_ABI_ILP32: + obstack_ptr_grow (&argv_obstack, "-m32"); + break; + default: + gcc_unreachable (); + } obstack_ptr_grow (&argv_obstack, "-S"); for (int ix = 1; ix != argc; ix++) @@ -1039,7 +1063,7 @@ main (int argc, char **argv) /* PR libgomp/65099: Currently, we only support offloading in 64-bit configurations. */ - if (!target_ilp32) + if (offload_abi == OFFLOAD_ABI_LP64) { ptx_name = make_temp_file (".mkoffload"); obstack_ptr_grow (&argv_obstack, "-o"); Grüße, Thomas
signature.asc
Description: PGP signature