mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:11:04 +01:00
Split the witness table into a separate ImplWitnessTable instruction (#5272)
This allows us to import the table for a given impl only once, while we can import many ImplWitness instructions with different specifics for a generic impl. For example in convert_facet_value_to_narrowed_facet_type.carbon we see that a single witness table is imported for the BitAnd interface, with multiple witnesses (for different specifics) imported and sharing the same table. The ImplWitnessTable now contains a back-link to the Impl the witness is for, allowing inst namer to name that interface in the textual semir, and allowing the interface to be found when debugging from a witness. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
c34a8d0a3a
commit
0e8d354567
+8
-7
@@ -33,11 +33,12 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
|
||||
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
|
||||
// CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.4f9(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (imports.%Core.import_ref.a5b), @impl.4f9 [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness %ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%impl_witness.d39) [concrete]
|
||||
// CHECK:STDOUT: %.be7: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
|
||||
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
|
||||
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
|
||||
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
|
||||
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
|
||||
@@ -125,7 +126,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
|
||||
// CHECK:STDOUT: %.loc16_20.1: %tuple.type = tuple_literal (%int_1.loc16_13, %int_2.loc16_16, %int_3)
|
||||
// CHECK:STDOUT: %int_1.loc16_23: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_20.1: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_20.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %bound_method.loc16_20.1: <bound method> = bound_method %int_1.loc16_13, %impl.elem0.loc16_20.1 [concrete = constants.%Convert.bound.ab5]
|
||||
// CHECK:STDOUT: %specific_fn.loc16_20.1: <specific function> = specific_function %impl.elem0.loc16_20.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc16_20.2: <bound method> = bound_method %int_1.loc16_13, %specific_fn.loc16_20.1 [concrete = constants.%bound_method.9a1]
|
||||
@@ -135,7 +136,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
|
||||
// CHECK:STDOUT: %.loc16_20.4: ref %i32 = array_index %.loc16_20.3, %int_0
|
||||
// CHECK:STDOUT: %.loc16_20.5: init %i32 = initialize_from %.loc16_20.2 to %.loc16_20.4 [concrete = constants.%int_1.5d2]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_20.2: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_20.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %bound_method.loc16_20.3: <bound method> = bound_method %int_2.loc16_16, %impl.elem0.loc16_20.2 [concrete = constants.%Convert.bound.ef9]
|
||||
// CHECK:STDOUT: %specific_fn.loc16_20.2: <specific function> = specific_function %impl.elem0.loc16_20.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc16_20.4: <bound method> = bound_method %int_2.loc16_16, %specific_fn.loc16_20.2 [concrete = constants.%bound_method.b92]
|
||||
@@ -144,7 +145,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %int_1.loc16_20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
|
||||
// CHECK:STDOUT: %.loc16_20.7: ref %i32 = array_index %.loc16_20.3, %int_1.loc16_20
|
||||
// CHECK:STDOUT: %.loc16_20.8: init %i32 = initialize_from %.loc16_20.6 to %.loc16_20.7 [concrete = constants.%int_2.ef8]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_20.3: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_20.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %bound_method.loc16_20.5: <bound method> = bound_method %int_3, %impl.elem0.loc16_20.3 [concrete = constants.%Convert.bound.b30]
|
||||
// CHECK:STDOUT: %specific_fn.loc16_20.3: <specific function> = specific_function %impl.elem0.loc16_20.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc16_20.6: <bound method> = bound_method %int_3, %specific_fn.loc16_20.3 [concrete = constants.%bound_method.047]
|
||||
@@ -157,7 +158,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %.loc16_20.13: init %array_type = converted %.loc16_20.1, %.loc16_20.12 [concrete = constants.%array]
|
||||
// CHECK:STDOUT: %.loc16_20.14: ref %array_type = temporary %.loc16_20.3, %.loc16_20.13
|
||||
// CHECK:STDOUT: %.loc16_20.15: %array_type = bind_value %.loc16_20.14
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_23: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %impl.elem0.loc16_23: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
|
||||
// CHECK:STDOUT: %bound_method.loc16_23.1: <bound method> = bound_method %int_1.loc16_23, %impl.elem0.loc16_23 [concrete = constants.%Convert.bound.ab5]
|
||||
// CHECK:STDOUT: %specific_fn.loc16_23: <specific function> = specific_function %impl.elem0.loc16_23, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc16_23.2: <bound method> = bound_method %int_1.loc16_23, %specific_fn.loc16_23 [concrete = constants.%bound_method.9a1]
|
||||
|
||||
Reference in New Issue
Block a user