Vector types
XL C/C++ supports vector processing technologies through language extensions. XL C/C++ implements and extends the AltiVec Programming Interface
specification. In the extended syntax, type qualifiers and storage
class specifiers can precede the keyword vector
(or its alternative spelling, __vector
) in a declaration.
Most of the legal forms of the syntax are captured in the following
diagram. Some variations have been omitted from the diagram for the
sake of clarity: type qualifiers such as const
and
storage class specifiers such as static
can appear
in any order within the declaration, as long as neither immediately
follows the keyword vector
(or __vector
).
- The keyword
vector
is recognized in a declaration context only when used as a type specifier and when vector support is enabled. The keywordspixel
,__pixel
andbool
are recognized as valid type specifiers only when preceded by the keywordvector
or__vector
. - Duplicate type specifiers are ignored in a vector declaration context.
The following table lists the supported vector data types, the size and possible values for each type.
Type | Interpretation of content | Range of values |
---|---|---|
vector unsigned char | 16 unsigned char | 0..255 |
vector signed char | 16 signed char | -128..127 |
vector bool char | 16 unsigned char | 0, 255 |
vector unsigned short | 8 unsigned short | 0..65535 |
vector unsigned short int | ||
vector signed short | 8 signed short | -32768..32767 |
vector signed short int | ||
vector bool short | 8 unsigned short | 0, 65535 |
vector bool short int | ||
vector unsigned int | 4 unsigned int | 0..232-1 |
vector signed int | 4 signed int | -231..231-1 |
vector bool int | 4 unsigned int | 0, 232-1 |
vector unsigned long long | 2 unsigned long long | 0..264-1 |
vector bool long long | 0, 264-1 | |
vector signed long long | 2 signed long long | -263..263-1 |
vector float | 4 float | IEEE-754 single (32 bit) precision floating-point values |
vector double | 2 double | IEEE-754 double (64 bit) precision floating-point values |
vector pixel | 8 unsigned short | 1/5/5/5 pixel |
All vector types are aligned on a 16-byte boundary. An aggregate that contains one or more vector types is aligned on a 16-byte boundary, and padded, if necessary, so that each member of vector type is also 16-byte aligned.