What problem does it solve?
Adding a new builtin function to the Carbon compiler requires coordinated changes across five separate toolchain areas (kind registration, signature validation, constant evaluation, LLVM lowering, and prelude bindings), and missing any step causes build or runtime failures. This Skill provides the complete workflow and C++ patterns to implement builtins correctly.
Core Features & Use Cases
- Five-Step Integration Workflow: Register the builtin kind in builtin_function_kind.def, declare signature constraints in builtin_function_kind.cpp, wire constant evaluation in eval.cpp, map LLVM lowering in handle_call.cpp, and bind prelude interfaces under core/prelude/.
- Constant Evaluation & Diagnostics: Implement compile-time execution with llvm::APInt/APFloat, emit typed diagnostics from kind.def, and enforce fast-path range limits to prevent compile-time memory exhaustion.
- Testing Conventions: Author checker and lowering test splits under toolchain/check/testdata/builtins/ and toolchain/lower/testdata/builtins/ using minimal preludes and direct builtin calls.
- Use Case: When adding an int-to-float conversion builtin, follow the guide to register IntConvertFloat, validate its signature with AnyInt/AnyFloat constraints, implement compile-time conversion, lower it to SIToFP/UIToFP LLVM instructions, and bind it in the prelude.
Quick Start
Ask the AI to walk you through adding a new builtin function to the Carbon compiler, from kind registration through LLVM lowering and prelude binding.