mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:54:41 +01:00
Initial support for builtin functions. (#3803)
For now, a builtin function is defined by specifying a string literal initializer in a function declaration: ```carbon fn MyBuiltin(a: i32) -> i32 = "builtin.name"; ``` End-to-end support is included for a sample `"int.add"` builtin performing integer addition, covering constant evaluation and code generation. The implementation here needs substantial refactoring before we'll be ready to start adding more builtins. That refactoring work will be coming next. This change is aiming to checkpoint some incremental progress.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "toolchain/lower/function_context.h"
|
||||
#include "toolchain/sem_ir/entry_point.h"
|
||||
#include "toolchain/sem_ir/file.h"
|
||||
#include "toolchain/sem_ir/function.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
#include "toolchain/sem_ir/typed_insts.h"
|
||||
|
||||
@@ -95,6 +96,11 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Don't lower builtins.
|
||||
if (function.builtin_kind != SemIR::BuiltinFunctionKind::None) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const bool has_return_slot = function.return_slot_id.is_valid();
|
||||
auto implicit_param_refs =
|
||||
sem_ir().inst_blocks().Get(function.implicit_param_refs_id);
|
||||
|
||||
Reference in New Issue
Block a user