Next: PowerPC Hardware Transactional Memory Built-in Functions, Previous: Basic PowerPC Built-in Functions, Up: Target Builtins [Contents][Index]
GCC provides an interface for the PowerPC family of processors to access
the AltiVec operations described in Motorola’s AltiVec Programming
Interface Manual. The interface is made available by including
<altivec.h>
and using -maltivec and
-mabi=altivec. The interface supports the following vector
types.
vector unsigned char vector signed char vector bool char vector unsigned short vector signed short vector bool short vector pixel vector unsigned int vector signed int vector bool int vector float
GCC’s implementation of the high-level language interface available from C and C++ code differs from Motorola’s documentation in several ways.
signed
or unsigned
is omitted, the signedness of the
vector type is the default signedness of the base type. The default
varies depending on the operating system, so a portable program should
always specify the signedness.
__vector
,
vector
, __pixel
, pixel
, __bool
and
bool
. When compiling ISO C, the context-sensitive substitution
of the keywords vector
, pixel
and bool
is
disabled. To use them, you must include <altivec.h>
instead.
typedef
name as the type specifier for a
vector type, but only under the following circumstances:
__vector
instead of vector
; for example,
typedef signed short int16; __vector int16 data;
vector
in keyword-and-predefine mode; for example,
typedef signed short int16; vector int16 data;
Note that keyword-and-predefine mode is enabled by disabling GNU
extensions (e.g., by using -std=c11
) and including
<altivec.h>
.
vec_add ((vector signed int){1, 2, 3, 4}, foo);
Since vec_add
is a macro, the vector constant in the example
is treated as four separate arguments. Wrap the entire argument in
parentheses for this to work.
Note: Only the <altivec.h>
interface is supported.
Internally, GCC uses built-in functions to achieve the functionality in
the aforementioned header file, but they are not supported and are
subject to change without notice.
GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification, which may be found at https://openpowerfoundation.org/?resource_lib=64-bit-elf-v2-abi-specification-power-architecture. Appendix A of this document lists the vector API interfaces that must be provided by compliant compilers. Programmers should preferentially use the interfaces described therein. However, historically GCC has provided additional interfaces for access to vector instructions. These are briefly described below.
Next: PowerPC Hardware Transactional Memory Built-in Functions, Previous: Basic PowerPC Built-in Functions, Up: Target Builtins [Contents][Index]