This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch: Re: rfc: auto-casted vector types



On Wednesday, February 19, 2003, at 01:12 PM, Aldy Hernandez wrote:


Sounds reasonable, but what I thought your last set of changes removes the need to do any casts between the various V... modes. Is this not true? If so, why are the casts required at all?

For opaque types, yes. The problem is that the builtins return V2SI, not an opaque type. So, if we remove the line Geoff suggested you would not be able to do this:


#define __ev_addw(a,b) __builtin_spe_evaddw((__v2si) (a), (__v2si) (b))
vector float foo;
foo = __ev_addw(x,y);

...because __builtin_spe_evaddw returns a V2SI, no a type with an underlying name of __ev64_opaque__. That __ev64_opaque__ is a V2SI is purely coincidential, what we're interested in is if the type name is actually called "__ev64_opaque__". If you look at the current definition for rs6000_spe_vector_types_compatible(), you will see:

static bool
rs6000_spe_vector_types_compatible (t1, t2)
tree t1;
tree t2;
{
if (!TARGET_SPE
|| TREE_CODE (t1) != VECTOR_TYPE || TREE_CODE (t2) != VECTOR_TYPE)
return 0;


  if (TYPE_NAME (t1) || TYPE_NAME (t2))
    return is_ev64_opaque_type (t1) || is_ev64_opaque_type (t2);

  /* FIXME: We assume V2SI is the opaque type, so we accidentally
     allow inter conversion to and from V2SI modes.  We could use
     V1D1, and rewrite <spe.h> accordingly.  */
  return t1 == V2SI_type_node || t2 == V2SI_type_node;
}

is_ev64_opaque_type returns true if the underlying type is a typedef actually named "__ev64_opaque__". Geoff has suggested we remove the last check for V2SI_type_node. So I'm suggesting we do as Geoff said, and then cast the return arguments from the builtins to __ev64_opaque__.

I hope this makes it clearer.

Aldy

Ok, I know see the light. Can we do something about what we call the type in spe.h then. It would seem nicer of it looked like


#define __ev_addw(a,b) (__ev64_opaque__)__builtin_spe_evaddw((__ev64_opaque__) (a), (__ev64_opaque__) (b))

So if we want to change the defn of __ev64_opaque__ to V2SI or V1SI or whatever later we only change how __ev64_opaque__ is defined not every entry.

- kumar


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]