gccrs: Make GCC target builtins available to the Rust front end
gccrs can now access GCC's target-specific built-in functions.
This commit makes GCC’s target-specific built-in functions accessible to the gccrs frontend. By ensuring the BuiltinsContext is initialized and calling targetm.init_builtins(), gccrs can now leverage intrinsics like __builtin_clz or __builtin_popcount provided by the GCC target machine. This is a foundational step for supporting LLVM builtins and other low-level operations within gccrs.
In Details
The BuiltinsContext in gccrs is now eagerly initialized, and its setup method calls targetm.init_builtins(). This allows the Rust frontend to discover and utilize GCC's target-specific built-in functions, which are registered via the target machine's (targetm) backend implementation. This capability is crucial for implementing adapters that map LLVM intrinsics to GCC builtins and for directly using hardware intrinsics supported by the target architecture.
- Built-in functions
- Functions provided by the compiler that are not part of the standard language but offer direct access to hardware instructions or optimized low-level operations. Examples include
__builtin_popcountfor counting set bits. - Target machine (`targetm`)
- In GCC, this refers to the specific hardware architecture and operating system combination for which the code is being compiled. The
targetmobject provides information and functions specific to that target. - BuiltinsContext
- A component within gccrs responsible for managing the availability and access to built-in functions, both those intrinsic to Rust and those provided by the underlying GCC compiler.
- 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.