Convert remaining type-value InstId fields to TypeInstId (#5294)

After #5280 there are a few more typed instructions that have an `InstId
type_inst_id` that always holds a type value. These are converted to
`TypeInstId` to encode this fact in the type system. The
`ConvertAggregateElement()` function in convert.cpp is now able to
receive `TypeInstId` for a couple arguments as well.

Additionally, the `type_inst_id` field of `StructTypeField` is made into
a `TypeInstId`.

The `TupleType::elements_id` is renamed to `TupleType::type_elements_id`
to try record the fact that it's an InstBlock of type value
instructions. We don't introduce a TypeInstBlockId at this time, but it
might be nice to make blocks of TypeInstIds in the future.

To assist in working with a block of InstId that are type values, two
additional helpers are added to the TypeStore:
- GetBlockAsTypeInstIds which turns an `ArrayRef<InstId>` into a range
of `TypeInstId`
- GetBlockAsTypeIds which turns an `ArrayRef<InstId>` into a range of
`TypeId`

We use these helpers in places that iterate over the
`TupleType::type_elements_id`.
This commit is contained in:
Dana Jansens
2025-04-11 20:11:03 +00:00
committed by GitHub
parent 8c3fa80691
commit c34a8d0a3a
20 changed files with 116 additions and 71 deletions
+1 -1
View File
@@ -587,7 +587,7 @@ class Stringifier {
}
auto StringifyInst(SemIR::InstId /*inst_id*/, TupleType inst) -> void {
auto refs = sem_ir_->inst_blocks().Get(inst.elements_id);
auto refs = sem_ir_->inst_blocks().Get(inst.type_elements_id);
if (refs.empty()) {
*out_ << "()";
return;