Plange


indicates that the following block of code enclosed in curly braces is assembler instructions, and creates a nullary void function object

Example

<Float32x3 * Float32x3 -> Float32x3> crossMultiply := (lhs, rhs) => {
    <Float32x4> result;
    implementation := asm sse4 {
        //where (a, b, c) = lhs
        //where (d, e, f) = rhs

        //xmm0 = b * f, c * d, a * e, _ * _
        shufps xmm0, lhs, 0x06 // b c a _ -> 01 10 00 00 -> 00000110
        shufps xmm1, rhs, 0x12 // f d e _ -> 10 00 01 00 -> 00010010
        mulps xmm0, xmm1

        //xmm1 = c * e, a * f, b * d, _ * _
        shufps xmm1, lhs, 0x12 // c a b _ -> 10 00 01 00 -> 00010010
        shufps xmm2, rhs, 0x06 // e f d _ -> 01 10 00 00 -> 00000110
        mulps xmm1, xmm2

        //xmm0 = b*f - c*e, c*d - a*f, a*e - b*d
        subps xmm0, xmm1
        movps result, xmm0
    } | {
        result <- (
            lhs(1)*rhs(2)-lhs(2)*rhs(1),
            lhs(2)*rhs(0)-lhs(0)*rhs(2),
            lhs(0)*rhs(1)-lhs(1)*rhs(0)
        );
    };
    implementation();
    return reinterpret_cast<Float32x3>(result);
}
            

Notes

Zero or more symbols may be listed after the asm keyword as options. The asm keyword creates an opaque function object that may be or'd together to make a single function object with different implementations for different target platforms. It may also be or'd with a conventional nullary void function so that an implementation is available for platforms that have not been explicitly targeted.

Built in target symbols include:

This list may be expanded.