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:
Richard Smith authored and GitHub committed 2024-03-21 20:46:34 +00:00
1 parent 8907948242
commit f0e940ddfd
43 files changed
+1588 -86

No files matched your search

+2
View File
@@ -424,6 +424,7 @@ class NodeStack {
case Parse::NodeKind::WhileConditionStart:
return Id::KindFor<SemIR::InstBlockId>();
case Parse::NodeKind::FunctionDefinitionStart:
case Parse::NodeKind::BuiltinFunctionDefinitionStart:
return Id::KindFor<SemIR::FunctionId>();
case Parse::NodeKind::ClassDefinitionStart:
return Id::KindFor<SemIR::ClassId>();
@@ -434,6 +435,7 @@ class NodeStack {
case Parse::NodeKind::SelfValueName:
return Id::KindFor<SemIR::NameId>();
case Parse::NodeKind::ArrayExprSemi:
case Parse::NodeKind::BuiltinName:
case Parse::NodeKind::ClassIntroducer:
case Parse::NodeKind::CodeBlockStart:
case Parse::NodeKind::ExprOpenParen: