mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:51:12 +01:00
Add a no-op builtin function which shouldn't generate code. (#5306)
This is part of a broader plan to have noop destructor functions for trivial destruction. Note this emits a SemIR call (`%no_op: init %empty_tuple.type = call %NoOp.ref() [concrete = constants.%empty_tuple]`), but not LLVM IR. My thought was this was probably okay, since even though it'll be a little spammy with destructor calls, the flipside is there'll probably already be a fair amount for the name reference, and this at least shows when the call is injected (and discarded). --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Chandler Carruth
parent
da83b65aa2
commit
b49e89e97e
@@ -1379,6 +1379,16 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context,
|
||||
case SemIR::BuiltinFunctionKind::None:
|
||||
CARBON_FATAL("Not a builtin function.");
|
||||
|
||||
case SemIR::BuiltinFunctionKind::NoOp: {
|
||||
// Return an empty tuple value.
|
||||
auto type_id = GetTupleType(eval_context.context(), {});
|
||||
return MakeConstantResult(
|
||||
eval_context.context(),
|
||||
SemIR::TupleValue{.type_id = type_id,
|
||||
.elements_id = SemIR::InstBlockId::Empty},
|
||||
phase);
|
||||
}
|
||||
|
||||
case SemIR::BuiltinFunctionKind::PrintChar:
|
||||
case SemIR::BuiltinFunctionKind::PrintInt:
|
||||
case SemIR::BuiltinFunctionKind::ReadChar: {
|
||||
|
||||
Reference in New Issue
Block a user