This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] Altivec ABI as default for powerpc64 linux
- From: Hartmut Penner <HPENNER at de dot ibm dot com>
- To: Geoff Keating <geoffk at geoffk dot org>
- Cc: Aldy Hernandez <aldyh at redhat dot com>, amodra at bigpond dot net dot au, dje at watson dot ibm dot com, gcc-patches at gcc dot gnu dot org, geoffk at desire dot geoffk dot org, segher at kernel dot crashing dot org
- Date: Tue, 3 Feb 2004 09:22:01 +0100
- Subject: Re: [Patch] Altivec ABI as default for powerpc64 linux
Geoff wrote:
> > > > For starters, try this with powerpc-linux-gnu and -mabi=altivec
(but
> > > > no -maltivec), and fix it :).
> > > >
> > > > typedef int vec __attribute__((mode(V4SI)));
> > > > vec poo, bar;
> > > > extern void funk(vec);
> > > > f(){
> > > > funk(poo);
> > > > }
> > >
> > > How can this work? "funk" expects its parameter in v1, but without
> > > -maltivec there are no instructions that can put it there.
> >
> > Exactly. It won't. If they want one ABI, they need to fix all these
> > places. I haven't looked in this particular case, but the test should
> > probably be TARGET_ALTIVEC_ABI *and* TARGET_ALTIVEC, otherwise stuff
> > should go in GPRs.
> So how does "funk" know whether or not it was called by something that
> was compiled with -maltivec?
Yes, there is no way to solve this. I would propose an error message,
if somebody wants pass vector register values, but has none available.
To have abi=altivec as default prevents that altivec applications and
non altivec shared libraries don't work together. To have a clean error
message rather than a ICE helps developer to find out, if their
executable only run on altivec hardware or not.
Hartmut
Index: rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.587
diff -u -p -r1.587 rs6000.c
--- rs6000.c 2 Feb 2004 06:31:05 -0000 1.587
+++ rs6000.c 3 Feb 2004 08:06:32 -0000
@@ -840,6 +840,13 @@ rs6000_override_options (const char *def
rs6000_long_double_type_size = size;
}
+ /* Set Altivec ABI as default for powerpc64 linux. */
+ if (TARGET_ELF && TARGET_64BIT)
+ {
+ rs6000_altivec_abi = 1;
+ rs6000_altivec_vrsave = 1;
+ }
+
/* Handle -mabi= options. */
rs6000_parse_abi_options ();
@@ -3980,6 +3987,8 @@ function_arg_advance (CUMULATIVE_ARGS *c
{
if (USE_ALTIVEC_FOR_ARG_P (cum, mode, type, named))
cum->vregno++;
+ if (!TARGET_ALTIVEC)
+ error ("Sorry, no altivec registers available to pass argument");
/* PowerPC64 Linux and AIX allocates GPRs for a vector argument
even if it is going to be passed in a vector register.
@@ -4296,6 +4305,10 @@ function_arg (CUMULATIVE_ARGS *cum, enum
and also in GPRs or memory, in absence of prototype. */
int align_words;
rtx slot;
+
+ if (!TARGET_ALTIVEC)
+ error ("Sorry, no altivec registers available to pass argument");
+
align_words = (cum->words + 1) & ~1;
if (align_words >= GP_ARG_NUM_REG)