Refactor ReturnTypeInfo and InitRepr. (#4169)

Rename `ReturnInfo` to `ReturnTypeInfo`. Move it and `InitRepr` into
`type_info.h` alongside `ValueRepr`. Replace `ReturnSlot` with
`InitRepr`, and extend `InitRepr` to be able to represent the
incomplete-type case instead of CHECK-failing. Remove `has_return_slot`
from `InitRepr` and instead only provide that as part of
`ReturnTypeInfo`.
This commit is contained in:
Richard Smith
2024-07-25 21:41:33 +00:00
committed by GitHub
parent 2ef1d1f8b9
commit 37a8bfa488
19 changed files with 194 additions and 194 deletions
+4 -1
View File
@@ -194,7 +194,7 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/,
auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/,
SemIR::ReturnExpr inst) -> void {
auto result_type_id = context.sem_ir().insts().Get(inst.expr_id).type_id();
switch (SemIR::GetInitRepr(context.sem_ir(), result_type_id).kind) {
switch (SemIR::InitRepr::ForType(context.sem_ir(), result_type_id).kind) {
case SemIR::InitRepr::None:
// Nothing to return.
context.builder().CreateRetVoid();
@@ -207,6 +207,9 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/,
// The expression produces the value representation for the type.
context.builder().CreateRet(context.GetValue(inst.expr_id));
return;
case SemIR::InitRepr::Incomplete:
CARBON_FATAL() << "Lowering return of incomplete type "
<< context.sem_ir().types().GetAsInst(result_type_id);
}
}