[cfe-dev] Implementing Altivec vector support questions

John Thompson john.thompson.jtsoftware at gmail.com
Wed Dec 9 15:37:49 PST 2009


The Altivec standard specifies that __vector comes first as a type
specifier, and is a keyword.  It also says that vector can be either a macro
or a context-sensitive keyword.  Having it be a macro, of course, is not a
good idea.  Which is probably why gcc (at least the PS3 version) does it the
context-sensitive way.  Thus __vector cannot be a declaration name, but
vector can.

On Wed, Dec 9, 2009 at 2:05 PM, Jens Ayton <mailing-lists.jens at ayton.se>wrote:

> On Dec 8, 2009, at 20:36, Chris Lattner wrote:
> > On Dec 8, 2009, at 11:30 AM, John Thompson wrote:
> >>
> >>
> >> My understanding is that "__vector" (or "vector") in this context is
> always followed by a numeric type, i.e. "_vector unsigned int".  My guess
> was that this would be effecticvely equivalent to
> "__attribute__((vector_size(16))) unsigned int", so the plan would then be
> to have the resulting type for these two be the same after the semantic
> action.
> >
> > so 'vector' doesn't work as a type qualifier?  For others type
> qualifiers, you can arrange them, e.g. "const int" == "int const" etc.
>
> In GCC with -faltivec, vector does not work as a type qualifier, but
> __vector does.
>
> #include <altivec.h>   // warning: ignoring <altivec.h> because "-faltivec"
> specified
>
> int main (int argc, const char * argv[])
> {
>    vector int a;      // warning: unused variable 'a'
>    int vector;        // warning: unused variable 'vector'
>    int vector b;      // error: nested functions are disabled (thanks, gcc)
>
>    __vector int c;    // warning: unused variable 'c'
>    int __vector;      // warning: useless type name in empty declaration
>    int __vector d;    // warning: unused variable 'd'
>
>    return 0;
> }
>
>
> Without -faltivec, vector is defined as __vector and acts as a qualifier
> (so the above code compiles with six warnings).
>
>
> --
> Jens Ayton
>
>


-- 
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091209/402f29fc/attachment.html>


More information about the cfe-dev mailing list