Hi! rs6000/powerpc port maintainer copied.
On Tue, 6 Oct 2015 11:38:04 -0500, James Norris <jnor...@codesourcery.com> wrote: > The attached patch adds the -foffload-abi option support for PPC. > Only support for the 64-bit ABI has been added. (Yes, only powerpc64le-linux-gnu configurations can be supported.) > Committed after regtesting with x86_64 and powerpc64le. Such a patch needs to go into trunk. (It's of course OK to test-drive it on gomp-4_0-branch first.) However: > + * common.opt (OFFLOAD_ABI_PPC64): New enum. > + * config/nvptx/mkoffload.c (compile_native): Handle new enum. > + (main): Handle new option. > + * config/rs6000/rs6000.c (rs6000_offload_options): New hook. > + * gcc/coretypes.h (OFFLOAD_ABI_PPC64): New enum. > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -1730,6 +1730,9 @@ Enum(offload_abi) String(ilp32) Value(OFFLOAD_ABI_ILP32) > EnumValue > Enum(offload_abi) String(lp64) Value(OFFLOAD_ABI_LP64) > > +EnumValue > +Enum(offload_abi) String(ppc64) Value(OFFLOAD_ABI_PPC64) > --- a/gcc/config/nvptx/mkoffload.c > +++ b/gcc/config/nvptx/mkoffload.c > @@ -367,6 +367,8 @@ compile_native (const char *infile, const char *outfile, > const char *compiler) > case OFFLOAD_ABI_ILP32: > obstack_ptr_grow (&argv_obstack, "-m32"); > break; > + case OFFLOAD_ABI_PPC64: > + break; > default: > gcc_unreachable (); > } > @@ -458,6 +460,8 @@ main (int argc, char **argv) > offload_abi = OFFLOAD_ABI_LP64; > else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0) > offload_abi = OFFLOAD_ABI_ILP32; > + else if (strcmp (argv[i] + strlen (STR), "ppc64") == 0) > + offload_abi = OFFLOAD_ABI_PPC64; > else > fatal_error (input_location, > "unrecognizable argument of option " STR); > @@ -485,6 +489,8 @@ main (int argc, char **argv) > case OFFLOAD_ABI_ILP32: > obstack_ptr_grow (&argv_obstack, "-m32"); > break; > + case OFFLOAD_ABI_PPC64: > + break; > default: > gcc_unreachable (); > } > @@ -518,7 +524,8 @@ main (int argc, char **argv) > > /* PR libgomp/65099: Currently, we only support offloading in 64-bit > configurations, and only for OpenACC offloading. */ > - if (offload_abi == OFFLOAD_ABI_LP64 && fopenacc) > + if ((offload_abi == OFFLOAD_ABI_LP64 > + || (offload_abi == OFFLOAD_ABI_PPC64)) && fopenacc) > { > ptx_name = make_temp_file (".mkoffload"); > obstack_ptr_grow (&argv_obstack, "-o"); > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > +#undef TARGET_OFFLOAD_OPTIONS > +#define TARGET_OFFLOAD_OPTIONS rs6000_offload_options > +/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ > +static char * > +rs6000_offload_options (void) > +{ > + return xstrdup ("-foffload-abi=ppc64"); > +} > --- a/gcc/coretypes.h > +++ b/gcc/coretypes.h > @@ -170,7 +170,8 @@ enum tls_model { > enum offload_abi { > OFFLOAD_ABI_UNSET, > OFFLOAD_ABI_LP64, > - OFFLOAD_ABI_ILP32 > + OFFLOAD_ABI_ILP32, > + OFFLOAD_ABI_PPC64 > }; No, that's not how I meant it to be done; I wrote: | On Mon, 5 Oct 2015 07:06:55 -0500, James Norris <james_nor...@mentor.com> wrote: | > [The -foffload-abi parameter] is not passed [to mkoffload] when using the | > ppc compiler, and as a result the 'unreachable' assertion [in mkoffload] | > went off. | | That's the bug: you need to pass this parameter: the target (a.k.a. host) | and offload target (a.k.a. device) compilers need to agree on the ABI to | use. This should be straightforward to do; see here: | | $ git grep -i offload.options -- gcc/config/i386/ | gcc/config/i386/i386.c:/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ | gcc/config/i386/i386.c:ix86_offload_options (void) | gcc/config/i386/i386.c:#undef TARGET_OFFLOAD_OPTIONS | gcc/config/i386/i386.c:#define TARGET_OFFLOAD_OPTIONS \ | gcc/config/i386/i386.c: ix86_offload_options | | gcc/config/i386/i386.c:ix86_offload_options: | | /* Implement the TARGET_OFFLOAD_OPTIONS hook. */ | static char * | ix86_offload_options (void) | { | if (TARGET_LP64) | return xstrdup ("-foffload-abi=lp64"); | return xstrdup ("-foffload-abi=ilp32"); | } | | In case that PowerPC supports additional ABIs, you need to add these to | gcc/coretypes.h:enum offload_abi, and adjust the parsing in the | mkoffloads (I can easily test the IntelMIC mkoffload patch for you); of | course we don't need to support anything but the 64-bit ABI (that you're | currently already using, I suppose). From a quick look at the *_TYPE_SIZE definitions in gcc/config/rs6000/rs6000.h as well as <http://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf>, "3-1 Fundamental Types", and <http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUND-TYPE>, I gather we're dealing with regular ilp32/lp64 here. Then, I assume the right thing is to use the 64BIT flag from gcc/config/rs6000/sysv4.opt (which, per gcc/config.gcc I suppose is used for the relevant powerpc64le-linux-gnu configuration). (David?) I'm not sure where to place the TARGET_OFFLOAD_OPTIONS #define and the function definition in rs6000.c. (David?) So, please revert your patch and instead try the following. --- gcc/config/rs6000/rs6000.c +++ gcc/config/rs6000/rs6000.c @@ -1688,6 +1688,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #define TARGET_LIBGCC_SHIFT_COUNT_MODE rs6000_abi_word_mode #undef TARGET_UNWIND_WORD_MODE #define TARGET_UNWIND_WORD_MODE rs6000_abi_word_mode + +#undef TARGET_OFFLOAD_OPTIONS +#define TARGET_OFFLOAD_OPTIONS rs6000_offload_options /* Processor table. */ @@ -9532,6 +9535,16 @@ rs6000_abi_word_mode (void) return TARGET_32BIT ? SImode : DImode; } +/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ +static char * +rs6000_offload_options (void) +{ + if (TARGET_64BIT) + return xstrdup ("-foffload-abi=lp64"); + else + return xstrdup ("-foffload-abi=ilp32"); +} + /* On rs6000, function arguments are promoted, as are function return values. */ Grüße, Thomas
signature.asc
Description: PGP signature