Skip to content

Commit

Permalink
Remove Parse::Node, add ElementIndex in docs for typed insts
Browse files Browse the repository at this point in the history
The documentation still referred to typed instructions having a
Parse::Node field, however that was removed and moved to the InstStore
in f197219.

Then GetParseNode() was renamed to GetNodeId() in 86a7c9f and
then GetLocationId() in b079acd and finally GetLocId() in
b5d28f2.

The comment in typed_inst.h mentions only three fields now, but some
types still have four, thanks to the unmentioned `ElementIndex index`
field. Normally this field comes last, after the `[...]Id` fields except
for in one case, AssociatedEntity. Rather than write ambiguously ordered
documentation, update the comment to and docs to say that the
ElementIndex comes last, and move it to the last position in
AssociatedEntity. Tests are rebased accordingly.
  • Loading branch information
danakj committed Nov 28, 2024
1 parent b894d4e commit 8256f89
Show file tree
Hide file tree
Showing 66 changed files with 386 additions and 378 deletions.
4 changes: 2 additions & 2 deletions toolchain/check/import_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
return ResolveAs<SemIR::AssociatedEntity>(
resolver, {.type_id = resolver.local_context().GetTypeIdForTypeConstant(
type_const_id),
.index = inst.index,
.decl_id = decl_id});
.decl_id = decl_id,
.index = inst.index});
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
self_type_id, context.insts().Get(decl_id).type_id());
return context.AddInst<SemIR::AssociatedEntity>(
context.insts().GetLocId(decl_id),
{.type_id = type_id, .index = index, .decl_id = decl_id});
{.type_id = type_id, .decl_id = decl_id, .index = index});
}

} // namespace Carbon::Check
34 changes: 17 additions & 17 deletions toolchain/check/testdata/class/generic/import.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
// CHECK:STDOUT: %.1: type = facet_access_type %Self.2 [symbolic]
// CHECK:STDOUT: %.2: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
// CHECK:STDOUT: %.3: %.2 = assoc_entity element0, imports.%import_ref.10 [symbolic]
// CHECK:STDOUT: %.3: %.2 = assoc_entity imports.%import_ref.10, element0 [symbolic]
// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.2, @impl.1(%N) [symbolic]
// CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [symbolic]
// CHECK:STDOUT: %.4: <witness> = interface_witness (%Convert.2) [symbolic]
Expand All @@ -284,7 +284,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type.5: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
// CHECK:STDOUT: %Convert.5: %Convert.type.5 = struct_value () [template]
// CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.5, %Convert.type.5 [template]
// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.17 [template]
// CHECK:STDOUT: %.9: %.8 = assoc_entity imports.%import_ref.17, element0 [template]
// CHECK:STDOUT: %Convert.type.6: type = fn_type @Convert.5, @impl.4(%N) [symbolic]
// CHECK:STDOUT: %Convert.6: %Convert.type.6 = struct_value () [symbolic]
// CHECK:STDOUT: %.10: <witness> = interface_witness (%Convert.6) [symbolic]
Expand All @@ -296,7 +296,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.7: %Convert.type.7 = struct_value () [symbolic]
// CHECK:STDOUT: %.11: type = facet_access_type %Self.4 [symbolic]
// CHECK:STDOUT: %.12: type = assoc_entity_type %As.type.2, %Convert.type.7 [symbolic]
// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.27 [symbolic]
// CHECK:STDOUT: %.13: %.12 = assoc_entity imports.%import_ref.27, element0 [symbolic]
// CHECK:STDOUT: %Convert.type.8: type = fn_type @Convert.7, @impl.5(%N) [symbolic]
// CHECK:STDOUT: %Convert.8: %Convert.type.8 = struct_value () [symbolic]
// CHECK:STDOUT: %.14: <witness> = interface_witness (%Convert.8) [symbolic]
Expand All @@ -312,7 +312,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type.11: type = fn_type @Convert.6, @As(Core.IntLiteral) [template]
// CHECK:STDOUT: %Convert.11: %Convert.type.11 = struct_value () [template]
// CHECK:STDOUT: %.18: type = assoc_entity_type %As.type.5, %Convert.type.11 [template]
// CHECK:STDOUT: %.19: %.18 = assoc_entity element0, imports.%import_ref.34 [template]
// CHECK:STDOUT: %.19: %.18 = assoc_entity imports.%import_ref.34, element0 [template]
// CHECK:STDOUT: %Convert.type.12: type = fn_type @Convert.10, @impl.8(%N) [symbolic]
// CHECK:STDOUT: %Convert.12: %Convert.type.12 = struct_value () [symbolic]
// CHECK:STDOUT: %.20: <witness> = interface_witness (%Convert.12) [symbolic]
Expand Down Expand Up @@ -346,8 +346,8 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type.13: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
// CHECK:STDOUT: %Convert.13: %Convert.type.13 = struct_value () [template]
// CHECK:STDOUT: %.32: type = assoc_entity_type %ImplicitAs.type.6, %Convert.type.13 [template]
// CHECK:STDOUT: %.33: %.32 = assoc_entity element0, imports.%import_ref.10 [template]
// CHECK:STDOUT: %.34: %.2 = assoc_entity element0, imports.%import_ref.43 [symbolic]
// CHECK:STDOUT: %.33: %.32 = assoc_entity imports.%import_ref.10, element0 [template]
// CHECK:STDOUT: %.34: %.2 = assoc_entity imports.%import_ref.43, element0 [symbolic]
// CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.24) [template]
// CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
// CHECK:STDOUT: %.35: <witness> = interface_witness (%Convert.14) [template]
Expand Down Expand Up @@ -444,7 +444,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.1, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
// CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
// CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.2)]
// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.2) = assoc_entity element0, imports.%import_ref.10 [symbolic = %.2 (constants.%.3)]
// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.2) = assoc_entity imports.%import_ref.10, element0 [symbolic = %.2 (constants.%.3)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: !members:
Expand All @@ -464,7 +464,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.6, @As(%Dest) [symbolic = %Convert.type (constants.%Convert.type.7)]
// CHECK:STDOUT: %Convert: @As.%Convert.type (%Convert.type.7) = struct_value () [symbolic = %Convert (constants.%Convert.7)]
// CHECK:STDOUT: %.1: type = assoc_entity_type @As.%As.type (%As.type.2), @As.%Convert.type (%Convert.type.7) [symbolic = %.1 (constants.%.12)]
// CHECK:STDOUT: %.2: @As.%.1 (%.12) = assoc_entity element0, imports.%import_ref.27 [symbolic = %.2 (constants.%.13)]
// CHECK:STDOUT: %.2: @As.%.1 (%.12) = assoc_entity imports.%import_ref.27, element0 [symbolic = %.2 (constants.%.13)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: !members:
Expand Down Expand Up @@ -1320,7 +1320,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.8: %Convert.type.8 = struct_value () [symbolic]
// CHECK:STDOUT: %.22: type = facet_access_type %Self.4 [symbolic]
// CHECK:STDOUT: %.23: type = assoc_entity_type %As.type.2, %Convert.type.8 [symbolic]
// CHECK:STDOUT: %.24: %.23 = assoc_entity element0, imports.%import_ref.33 [symbolic]
// CHECK:STDOUT: %.24: %.23 = assoc_entity imports.%import_ref.33, element0 [symbolic]
// CHECK:STDOUT: %Convert.type.9: type = fn_type @Convert.7, @impl.5(%N) [symbolic]
// CHECK:STDOUT: %Convert.9: %Convert.type.9 = struct_value () [symbolic]
// CHECK:STDOUT: %.25: <witness> = interface_witness (%Convert.9) [symbolic]
Expand All @@ -1336,7 +1336,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type.12: type = fn_type @Convert.6, @As(Core.IntLiteral) [template]
// CHECK:STDOUT: %Convert.12: %Convert.type.12 = struct_value () [template]
// CHECK:STDOUT: %.29: type = assoc_entity_type %As.type.5, %Convert.type.12 [template]
// CHECK:STDOUT: %.30: %.29 = assoc_entity element0, imports.%import_ref.40 [template]
// CHECK:STDOUT: %.30: %.29 = assoc_entity imports.%import_ref.40, element0 [template]
// CHECK:STDOUT: %Convert.type.13: type = fn_type @Convert.10, @impl.8(%N) [symbolic]
// CHECK:STDOUT: %Convert.13: %Convert.type.13 = struct_value () [symbolic]
// CHECK:STDOUT: %.31: <witness> = interface_witness (%Convert.13) [symbolic]
Expand Down Expand Up @@ -1408,7 +1408,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.6, @As(%Dest) [symbolic = %Convert.type (constants.%Convert.type.8)]
// CHECK:STDOUT: %Convert: @As.%Convert.type (%Convert.type.8) = struct_value () [symbolic = %Convert (constants.%Convert.8)]
// CHECK:STDOUT: %.1: type = assoc_entity_type @As.%As.type (%As.type.2), @As.%Convert.type (%Convert.type.8) [symbolic = %.1 (constants.%.23)]
// CHECK:STDOUT: %.2: @As.%.1 (%.23) = assoc_entity element0, imports.%import_ref.33 [symbolic = %.2 (constants.%.24)]
// CHECK:STDOUT: %.2: @As.%.1 (%.23) = assoc_entity imports.%import_ref.33, element0 [symbolic = %.2 (constants.%.24)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: !members:
Expand Down Expand Up @@ -1931,7 +1931,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
// CHECK:STDOUT: %.1: type = facet_access_type %Self.2 [symbolic]
// CHECK:STDOUT: %.2: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
// CHECK:STDOUT: %.3: %.2 = assoc_entity element0, imports.%import_ref.10 [symbolic]
// CHECK:STDOUT: %.3: %.2 = assoc_entity imports.%import_ref.10, element0 [symbolic]
// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.2, @impl.1(%N) [symbolic]
// CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [symbolic]
// CHECK:STDOUT: %.4: <witness> = interface_witness (%Convert.2) [symbolic]
Expand All @@ -1948,7 +1948,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type.5: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
// CHECK:STDOUT: %Convert.5: %Convert.type.5 = struct_value () [template]
// CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.5, %Convert.type.5 [template]
// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.17 [template]
// CHECK:STDOUT: %.9: %.8 = assoc_entity imports.%import_ref.17, element0 [template]
// CHECK:STDOUT: %Convert.type.6: type = fn_type @Convert.5, @impl.4(%N) [symbolic]
// CHECK:STDOUT: %Convert.6: %Convert.type.6 = struct_value () [symbolic]
// CHECK:STDOUT: %.10: <witness> = interface_witness (%Convert.6) [symbolic]
Expand All @@ -1960,7 +1960,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.7: %Convert.type.7 = struct_value () [symbolic]
// CHECK:STDOUT: %.11: type = facet_access_type %Self.4 [symbolic]
// CHECK:STDOUT: %.12: type = assoc_entity_type %As.type.2, %Convert.type.7 [symbolic]
// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.27 [symbolic]
// CHECK:STDOUT: %.13: %.12 = assoc_entity imports.%import_ref.27, element0 [symbolic]
// CHECK:STDOUT: %Convert.type.8: type = fn_type @Convert.7, @impl.5(%N) [symbolic]
// CHECK:STDOUT: %Convert.8: %Convert.type.8 = struct_value () [symbolic]
// CHECK:STDOUT: %.14: <witness> = interface_witness (%Convert.8) [symbolic]
Expand All @@ -1976,7 +1976,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type.11: type = fn_type @Convert.6, @As(Core.IntLiteral) [template]
// CHECK:STDOUT: %Convert.11: %Convert.type.11 = struct_value () [template]
// CHECK:STDOUT: %.18: type = assoc_entity_type %As.type.5, %Convert.type.11 [template]
// CHECK:STDOUT: %.19: %.18 = assoc_entity element0, imports.%import_ref.34 [template]
// CHECK:STDOUT: %.19: %.18 = assoc_entity imports.%import_ref.34, element0 [template]
// CHECK:STDOUT: %Convert.type.12: type = fn_type @Convert.10, @impl.8(%N) [symbolic]
// CHECK:STDOUT: %Convert.12: %Convert.type.12 = struct_value () [symbolic]
// CHECK:STDOUT: %.20: <witness> = interface_witness (%Convert.12) [symbolic]
Expand Down Expand Up @@ -2062,7 +2062,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.1, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
// CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
// CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.2)]
// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.2) = assoc_entity element0, imports.%import_ref.10 [symbolic = %.2 (constants.%.3)]
// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.2) = assoc_entity imports.%import_ref.10, element0 [symbolic = %.2 (constants.%.3)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: !members:
Expand All @@ -2082,7 +2082,7 @@ class Class(U:! type) {
// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.6, @As(%Dest) [symbolic = %Convert.type (constants.%Convert.type.7)]
// CHECK:STDOUT: %Convert: @As.%Convert.type (%Convert.type.7) = struct_value () [symbolic = %Convert (constants.%Convert.7)]
// CHECK:STDOUT: %.1: type = assoc_entity_type @As.%As.type (%As.type.2), @As.%Convert.type (%Convert.type.7) [symbolic = %.1 (constants.%.12)]
// CHECK:STDOUT: %.2: @As.%.1 (%.12) = assoc_entity element0, imports.%import_ref.27 [symbolic = %.2 (constants.%.13)]
// CHECK:STDOUT: %.2: @As.%.1 (%.12) = assoc_entity imports.%import_ref.27, element0 [symbolic = %.2 (constants.%.13)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: !members:
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/testdata/function/builtin/method.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var arr: [i32; (1 as i32).(I.F)(2)];
// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
// CHECK:STDOUT: %.2: type = assoc_entity_type %I.type, %F.type.1 [template]
// CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @I.%F.decl [template]
// CHECK:STDOUT: %.3: %.2 = assoc_entity @I.%F.decl, element0 [template]
// CHECK:STDOUT: %.4: Core.IntLiteral = int_value 32 [template]
// CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
// CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
Expand Down Expand Up @@ -155,7 +155,7 @@ var arr: [i32; (1 as i32).(I.F)(2)];
// CHECK:STDOUT: %return.param: ref @F.1.%.loc12_14.1 (%.1) = out_param runtime_param2
// CHECK:STDOUT: %return: ref @F.1.%.loc12_14.1 (%.1) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc12: %.2 = assoc_entity element0, %F.decl [template = constants.%.3]
// CHECK:STDOUT: %.loc12: %.2 = assoc_entity %F.decl, element0 [template = constants.%.3]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
Expand Down
Loading

0 comments on commit 8256f89

Please sign in to comment.