Skip to content

Builtins

The compiler offers builtin constants and functions. Some are only available on certain targets. All builtins use the $$ name prefix.

These constants are generated by the compiler and can safely be used by the user.

An array of names of the benchmark functions.

An array of addresses to the benchmark functions.

The current date.

The current file name.

The current file with path.

The current function name, will return "" on the global level.

The current function as an expression.

The current line as an integer.

Usually the same as $$LINE, but in case of a macro inclusion it returns the line in the macro rather than the line where the macro was included.

The current module name.

The current time.

The $$ namespace defines compiler builtin functions. These special functions are not guaranteed to exist on all platforms, and are ways to wrap compiler implemented, optimized implementations of some particular functionality. They are mainly intended for standard library internal use. The standard library have macros that wrap these builtins, so they should normally not be used on their own.

Emits a trap instruction.

Inserts an “unreachable” annotation.

Returns the current “callstack” reference if available. OS and compiler dependent.

Takes a variable and a value and stores the value as a volatile store.

Takes a variable and returns the value using a volatile load.

Builtin memcpy instruction.

Builtin memset instruction.

Prefetch a memory location.

Access to the cycle counter register (or similar low latency clock) on supported architectures (e.g. RDTSC on x86), otherwise $$sysclock will yield 0.

Makes a syscall according to the platform convention on platforms where it is supported.

Functions $$ceil, $$trunc, $$sin, $$cos, $$log, $$log2, $$log10, $$rint, $$round $$sqrt, $$roundeven, $$floor, $$sqrt, $$pow, $$exp, $$fma and $$fabs, $$copysign, $$round, $$nearbyint.

Can be applied to float vectors or numbers. Returns the same type.

Functions $$min, $$abs and $$max can be applied to any integer or float number or vector.

Function $pow_int takes a float or floating vector + an integer and returns the same type as the first parameter.

Saturated addition, subtraction and left shift for integers and integer vectors: $$sat_add, $$sat_shl, $$sat_sub.

Funnel shift left and right, takes either two integers or two integer vectors.

$$ctz, $$clz, $$bitreverse, $$bswap, $$popcount

Section titled “$$ctz, $$clz, $$bitreverse, $$bswap, $$popcount”

Bit functions work on an integer or an integer vector.

$$reduce_add, $$reduce_mul, $$reduce_and, $$reduce_or, $$reduce_xor work on integer vectors.

$$reduce_fadd, $$reduce_fmul works on float vectors.

$$reduce_max, $$reduce_min works on any vector.

$$reverse reverses the values in any vector.

$$shufflevector rearranges the values of two vectors using a fixed mask into a resulting vector.