[cfe-dev] Implementing Altivec vector support questions

Jens Ayton mailing-lists.jens at ayton.se
Wed Dec 9 14:05:06 PST 2009

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

More information about the cfe-dev mailing list