Brussels / 4 & 5 February 2023


How to add an GCC builtin to the RISC-V compiler

Many low level features of architectures are implemented in GCC as builtin functions. Builtin functions look superficially like any C function, but are in fact intrinsic to the compiler and represented as patterns to be matched in the machine description.

Builtin functions are often used to access unique functionality of individual machine instructions. Being integrated within the compiler, they are more efficient than using simple inline assembly code. For RISC-V, they offer an excellent way to expose the functionality of instruction set extensions to the C/C++ programmer.

Adding a builtin function to GCC is not that difficult, but neither is it completely trivial. In this talk we will show you how to add builtin functions using examples from the OpenHW Group's CV32E40Pv2 processor core.


Nandni Jamnadas