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
+5 -2
View File
@@ -133,7 +133,7 @@ auto FunctionContext::MakeSyntheticBlock() -> llvm::BasicBlock* {
auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id,
SemIR::InstId source_id) -> void {
switch (SemIR::GetInitRepr(sem_ir(), type_id).kind) {
switch (SemIR::InitRepr::ForType(sem_ir(), type_id).kind) {
case SemIR::InitRepr::None:
break;
case SemIR::InitRepr::InPlace:
@@ -146,12 +146,15 @@ auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id,
case SemIR::InitRepr::ByCopy:
CopyValue(type_id, source_id, dest_id);
break;
case SemIR::InitRepr::Incomplete:
CARBON_FATAL() << "Lowering aggregate initialization of incomplete type "
<< sem_ir().types().GetAsInst(type_id);
}
}
auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::InstId source_id,
SemIR::InstId dest_id) -> void {
switch (auto rep = SemIR::GetValueRepr(sem_ir(), type_id); rep.kind) {
switch (auto rep = SemIR::ValueRepr::ForType(sem_ir(), type_id); rep.kind) {
case SemIR::ValueRepr::Unknown:
CARBON_FATAL() << "Attempt to copy incomplete type";
case SemIR::ValueRepr::None: