gccrs: Implement adapters for compiling LLVM builtins with GCC builtins
gccrs now adapts LLVM builtin signatures to GCC builtin signatures for certain functions.
gccrs implements 1-to-1 adapters to translate LLVM builtin function signatures into GCC builtin signatures. This commit specifically handles cases involving FORWARD_ARGUMENTS, enabling functions like llvm.addcarryx.u32 and llvm.addcarryx.u64 to be compiled by mapping them to their __builtin_ia32_ equivalents. Adapters for SIMD-related builtins are included but currently unused as gccrs does not yet support SIMD types.
In Details
This change introduces adapter functions within gccrs to bridge the gap between LLVM's intrinsic function signatures and GCC's built-in function signatures. For HIR::ExternalFunctionItem compilation under the UNADJUSTED ABI, a new function compile_x86_forwarding_adapter is introduced. This function generates wrapper code that directly forwards arguments and return values, enabling LLVM builtins like addcarryx to be correctly mapped to GCC's __builtin_ia32_ equivalents. Support for SIMD intrinsics like vcvtph2ps is noted as pending full SIMD type support.
- 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.
- 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_clzor__builtin_popcount. - FORWARD_ARGUMENTS
- A case or classification within gccrs's handling of function signatures, particularly for external functions, where arguments are passed directly from the caller to the callee without modification.
- UNADJUSTED ABI
- Application Binary Interface. Refers to a calling convention that does not perform any adjustments to function arguments or return values, passing them directly as-is.
- SIMD
- Single Instruction, Multiple Data. A type of parallel processing where a single operation is performed on multiple data points simultaneously. SIMD instructions are often used for graphics, multimedia, and scientific computations.