SPU C/C++ language extensions (intrinsics)

A large set of SPU C/C++ language extensions (intrinsics) make the underlying SPU Instruction Set Architecture and hardware features conveniently available to C programmers. These intrinsics can be used in place of assembly-language code when writing in the C or C++ languages.

The intrinsics are essentially in-line assembly-language instructions in the form of C-language function calls. They provide the programmer with explicit control of the SPE SIMD instructions without directly managing registers. A well-written compiler that supports these intrinsics will emit efficient code for the SPE architecture. The techniques used by compilers to generate efficient code include:

For example, an SPU compiler provides the intrinsic t = spu_add(a, b) as a substitute for the assembly-language instruction fa rt,ra,rb . The compiler will generate a floating-point add instruction (fa rt, ra, rb) for the SPU intrinsic t = spu_add(a, b), assuming t , a , and b are vector float variables. The system header file (spu_intrinsics.h) defines the SPU language extension intrinsics.

The intrinsics are defined fully in the C/C++ Language Extensions for Cell Broadband Engine Architecture specification. The PPU and the SPU instruction sets have similar, but distinct, SIMD intrinsics. It is important to understand the mapping between the PPU and SPU SIMD intrinsics when developing applications on the PPE that will eventually be ported to the SPEs.