GCC (GNU Toolchain)

Jeremy Bennett

Tutorial: How to add a builtin function to the GCC backend

Saturday 14:55-15:20 | K.3.201

A common first step to adding full code-generation functionality for a new instruction, or set of instructions is to add them to the back-end as a builtin function. This is particularly common with RISC-V where custom ISA extensions are common place.

In this tutorial I will take you through the steps to add a builtin-function to the back-end, using a case study from the OpenHW CV32E4Pv2 RISC-V core. This has 8 ISA extensions, with a total of more than 300 instructions.

I will conclude by looking at some of the things we got wrong. In particular unexpected consequences when the new compiler started being used more widely.