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 -2
View File
@@ -67,8 +67,7 @@ auto HandleParseNode(Context& context, Parse::StructLiteralFieldId node_id)
auto HandleParseNode(Context& context,
Parse::StructTypeLiteralFieldId /*node_id*/) -> bool {
auto [type_node, type_id] = context.node_stack().PopExprWithNodeId();
SemIR::InstId cast_type_inst_id =
ExprAsType(context, type_node, type_id).inst_id;
auto cast_type_inst_id = ExprAsType(context, type_node, type_id).inst_id;
// Get the name while leaving it on the stack.
auto name_id = context.node_stack().Peek<Parse::NodeCategory::MemberName>();