GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Initial implementation of LLVM builtin to GCC adapter

gccrs begins adapting LLVM builtins like rdrand, rdseed, and addcarry to GCC builtins.

This commit lays the groundwork for integrating LLVM builtins into gccrs by implementing initial adapter functions. Currently, it supports specific x86 builtins such as rdrand, rdseed, addcarry, and subborrow for various data sizes. These adapters translate LLVM’s intrinsic calls into equivalent GCC __builtin_ia32_ calls, allowing Rust code using these functions to compile correctly.

In Details

The gccrs frontend now includes an initial implementation for compiling LLVM intrinsics by mapping them to GCC's __builtin_ia32_ equivalents. This commit focuses on a set of x86-specific builtins (rdrand, rdseed, addcarryx, sbb_u32, addcarryx_u64, sbb_u64) that return structures containing both a result and a status flag. Adapter functions are generated to handle these return types and correctly invoke the corresponding GCC builtins. This is a significant step towards enabling a wider range of low-level hardware intrinsics within gccrs.

For Context
LLVM builtins
Intrinsic functions provided by the LLVM compiler infrastructure that map to specific hardware instructions or provide optimized low-level operations. gccrs aims to support these for compatibility and performance.
GCC builtins
Intrinsic functions provided by the GCC compiler that map to specific hardware instructions or provide optimized low-level operations. Examples include __builtin_clz or __builtin_popcount.
Adapter
A piece of code that translates between two different interfaces or representations. In this case, it translates LLVM builtin signatures to GCC builtin signatures.
rdrand
A CPU instruction that generates a random number. It's often used for cryptographic purposes.
rdseed
A CPU instruction similar to RDRAND but intended for higher-quality random numbers, often used for seeding cryptographic generators.
addcarry
A CPU instruction that performs addition with carry detection, commonly used in arithmetic operations involving large numbers or in cryptography.
subborrow
A CPU instruction that performs subtraction with borrow detection, similar to ADD CARRY but for subtraction.
x86
A family of instruction set architectures (ISAs) commonly used in desktop and server computers. Many built-in functions are architecture-specific.
Filed Under: gccrsrustbuiltinscompilerx86