# Generic intrinsics

Generic intrinsics map to one or more assembly-language instructions, as a function of the type of its input parameters. Generic intrinsics are often implemented as compiler built-ins.

All of the generic intrinsics are prefixed by the string spu_. For example, the intrinsic that implements the stop assembly instruction is named spu_stop.

Generic intrinsics are provided for all SPU instructions, except for the following:

• branch
• branch hint
• interrupt return
• generate control for insertion (used for scalar stores)
• constant formation
• no-op
• stop and signal with dependencies (stopd)

Many generic intrinsics accept scalars as one of their operands. These correspond to intrinsics that map to instructions with immediate values.

Table 1 lists the generic intrinsics.
Table 1. Generic SPU Intrinsics
Intrinsic Description
Constant Formation Intrinsics
d = spu_splats(a) Replicate scalar a into all elements of vector d
Conversion Intrinsics
d = spu_convtf(a, scale) Convert integer vector to float vector
d = spu_convts(a, scale) Convert float vector to signed int vector
d = spu_convtu(a, scale) Convert float vector to unsigned float vector
d = spu_extend(a) Sign extend vector
d = spu_rountf(a) Round double vector to float vector
Arithmetic Intrinsics
d = spu_genb(a, b) Vector generate borrow
d = spu_genbx(a, b, c) Vector generate borrow extended
d = spu_genc(a, b) Vector generate carry
d = spu_gencx(a, b, c) Vector generate carry extended
d = spu_msub(a, b, c) Vector multiply and subtract
d = spu_mul(a, b) Vector multiply
d = spu_mulh(a, b) Vector multiply high
d = spu_mulhh(a, b) Vector multiply high high
d = spu_mulo(a, b) Vector multiply odd
d = spu_mulsr(a, b) Vector multiply and shift right
d = spu_nmsub(a, b, c) Negative vector multiply and subtract
d = spu_re(a) Vector floating-point reciprocal estimate
d = spu_rsqrte(a) Vector floating-point reciprocal square root estimate
d = spu_sub(a, b) Vector subtract
d = spu_subx(a, b, c) Vector subtract extended
Byte Operation Intrinsics
d = spu_absd(a, b) Vector absolute difference
d = spu_avg(a, b) Vector average
d = spu_sumb(a, b) Vector sum bytes into shorts
Compare, Branch, and Halt Intrinsics
d = spu_bisled(func) Branch indirect and set link if external data
d = spu_cmpabseq(a, b) Vector compare absolute equal
d = spu_cmpabsgt(a, b) Vector compare absolute greater than
d = spu_cmpeq(a, b) Vector compare equal
d = spu_cmpgt(a, b) Vector compare greater than
(void) spu_hcmpeq(a, b) Halt if compare equal
(void) spu_hcmpgt(a, b) Halt if compare greater than
d = spu_testsv(a, values) Element-wise test for special value
d = spu_cntb(a) Vector count ones for bytes
d = spu_cntlz(a) Vector count leading zeros
d = spu_gather(a) Gather bits from elements
d = spu_sel(a, b, pattern) Select bits
d = spu_shuffle(a, b, pattern) Shuffle bytes of a vector
Logical Intrinsics
d = spu_and(a, b) Vector bit-wise AND
d = spu_andc(a, b) Vector bit-wise AND with complement
d = spu_eqv(a, b) Vector bit-wise equivalent
d = spu_nand(a, b) Vector bit-wise complement of AND
d = spu_nor(a, b) Vector bit-wise complement of OR
d = spu_or(a, b) Vector bit-wise OR
d = spu_orc(a, b) Vector bit-wise OR with complement
d = spu_orx(a) Bit-wise OR word elements
d = spu_xor(a, b) Vector bit-wise exclusive OR
Rotate Intrinsics
d = spu_rl(a, count) Element-wise bit rotate left
d = spu_rlqw(a, count) Bit rotate quadword left
d = spu_rlqwbyte(a, count) Byte rotate quadword left
d = spu_rlqwbytebc(a, count) Byte rotate quadword left using bit rotate count
Shift Intrinsics
d = spu_sl(a, count) Element-wise bit shift left
d = spu_slqw(a, count) Bit shift quadword left
d = spu_slqwbyte(a, count) Byte shift quadword left
d = spu_slqwbytebc(a, count) Byte shift quadword left using bit shift count
Control Intrinsics
(void) spu_idisable() Disable interrupts
(void) spu_ienable() Enable interrupts
(void) spu_mffpscr() Move from floating-point status and control register
(void) spu_mfspr(register) Move from special-purpose register
(void) spu_mtfpscr(a) Move to floating-point status and control register
(void) spu_mtspr(register, a) Move to special-purpose register
(void) spu_dsync() Synchronize data
(void) spu_stop(type) Stop and signal
(void) spu_sync() Synchronize
Scalar Intrinsics
d = spu_extract(a, element) Extract vector element from vector
d = spu_insert(a, b, element) Insert scalar into specified vector element
d = spu_promote(a, element) Promote scalar to vector
Channel Control Intrinsics