diff mbox

Add -foffload-abi support for PPC

Message ID 56169779.5040903@codesourcery.com
State New
Headers show

Commit Message

James Norris Oct. 8, 2015, 4:19 p.m. UTC
Hi!

On 10/07/2015 08:51 AM, David Edelsohn wrote:
> On Wed, Oct 7, 2015 at 4:02 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>
>>  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?)
>
> TARGET_64BIT is the appropriate macro to test.
>
>>
>> I'm not sure where to place the TARGET_OFFLOAD_OPTIONS #define and the
>> function definition in rs6000.c.  (David?)
>
> As mentioned earlier, only PPC64LE is supported.
>
> I'm not sure if it really matters if this is defined in ELF-specific
> portion of the file or a general place, although it never will be
> called by other configurations.
>
> Thanks, David
>

I've revised the patch from the review comments (thank you) and
is attached.

Regtested on x86_64 and powerpcle64.

OK for trunk?

Thanks!
Jim

Comments

David Edelsohn Oct. 8, 2015, 4:53 p.m. UTC | #1
On Thu, Oct 8, 2015 at 12:19 PM, James Norris <jnorris@codesourcery.com> wrote:

> I've revised the patch from the review comments (thank you) and
> is attached.
>
> Regtested on x86_64 and powerpcle64.
>
> OK for trunk?

What is the goal? Do you want this to return the correct value or only
the value for the supported 64 bit PPC64LE system?

Thanks, David
Thomas Schwinge Oct. 8, 2015, 4:55 p.m. UTC | #2
Hi!

On Thu, 8 Oct 2015 11:19:05 -0500, James Norris <jnorris@codesourcery.com> wrote:
> On 10/07/2015 08:51 AM, David Edelsohn wrote:
> > On Wed, Oct 7, 2015 at 4:02 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
> >
> >>  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?)
> >
> > TARGET_64BIT is the appropriate macro to test.
> >
> >>
> >> I'm not sure where to place the TARGET_OFFLOAD_OPTIONS #define and the
> >> function definition in rs6000.c.  (David?)
> >
> > As mentioned earlier, only PPC64LE is supported.
> >
> > I'm not sure if it really matters if this is defined in ELF-specific
> > portion of the file or a general place, although it never will be
> > called by other configurations.
> >
> > Thanks, David
> >
> 
> I've revised the patch from the review comments (thank you) and
> is attached.
> 
> Regtested on x86_64 and powerpcle64.
> 
> OK for trunk?

> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c

> +/* Implement the TARGET_OFFLOAD_OPTIONS hook.  */
> +static char *
> +rs6000_offload_options (void)
> +{
> +  return xstrdup ("-foffload-abi=lp64");
> +}

Well, that's a stripped-down variant of what I had suggested:

    static char *
    rs6000_offload_options (void)
    {
      if (TARGET_64BIT)
        return xstrdup ("-foffload-abi=lp64");
      else
        return xstrdup ("-foffload-abi=ilp32");
    }

If you return -foffload-abi=lp64 unconditionally, strange things will
happen for -m32 compilation (ABI mismatch).


Grüße,
 Thomas
diff mbox

Patch

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index e095f03..e775e9a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1690,6 +1690,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.  */
@@ -9530,6 +9533,13 @@  rs6000_abi_word_mode (void)
   return TARGET_32BIT ? SImode : DImode;
 }
 
+/* Implement the TARGET_OFFLOAD_OPTIONS hook.  */
+static char *
+rs6000_offload_options (void)
+{
+  return xstrdup ("-foffload-abi=lp64");
+}
+
 /* On rs6000, function arguments are promoted, as are function return
    values.  */