Add a FacetValue instruction (#4545)

The new `FacetValue` instruction represents `C as I` for some type `C`
and facet type `I`. It is named `FacetValue` instead of just `Facet` to
parallel the `FacetType` instruction.

This PR uses this instruction represent the facet value `Self` in an
`impl` declaration. This instruction will be used in the future to also
support things like:

* `C as I` where `C` is a class; and
* forming a specific for a generic with a `T:! I` parameter where `T` is
being given a concrete value.

(Here `I` is an interface or other non-`type` facet type.)

Also do some renaming and add some comments to make things a bit more
clear.

* `FacetTypeAccess` -> `FacetAccessType` to clarify this is not access
of a facet type, but access of the type of a facet
* `.facet_id` -> `.facet_value_inst_id` to parallel the `FacetValue`
instruction

`FacetAccessWitness` will be in a future PR.

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
josh11b
2024-11-21 22:29:53 +00:00
committed by GitHub
co-authored by Josh L Richard Smith
parent 5e4038048b
commit 67f2c9ce26
243 changed files with 11104 additions and 10481 deletions
+35 -35
View File
@@ -36,17 +36,17 @@ fn G() -> i32 {
// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
// CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
// CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
// CHECK:STDOUT: %.27: <witness> = interface_witness (%Convert.14) [template]
// CHECK:STDOUT: %.28: <bound method> = bound_method %.5, %Convert.14 [template]
// CHECK:STDOUT: %.29: <specific function> = specific_function %.28, @Convert.2(%.1) [template]
// CHECK:STDOUT: %.30: %i32 = int_value 1 [template]
// CHECK:STDOUT: %.31: <bound method> = bound_method %.6, %Convert.14 [template]
// CHECK:STDOUT: %.32: <specific function> = specific_function %.31, @Convert.2(%.1) [template]
// CHECK:STDOUT: %.33: %i32 = int_value 2 [template]
// CHECK:STDOUT: %.34: <bound method> = bound_method %.2, %Convert.14 [template]
// CHECK:STDOUT: %.35: <specific function> = specific_function %.34, @Convert.2(%.1) [template]
// CHECK:STDOUT: %.36: %i32 = int_value 3 [template]
// CHECK:STDOUT: %array: %.3 = tuple_value (%.30, %.33, %.36) [template]
// CHECK:STDOUT: %.31: <witness> = interface_witness (%Convert.14) [template]
// CHECK:STDOUT: %.32: <bound method> = bound_method %.5, %Convert.14 [template]
// CHECK:STDOUT: %.33: <specific function> = specific_function %.32, @Convert.2(%.1) [template]
// CHECK:STDOUT: %.34: %i32 = int_value 1 [template]
// CHECK:STDOUT: %.35: <bound method> = bound_method %.6, %Convert.14 [template]
// CHECK:STDOUT: %.36: <specific function> = specific_function %.35, @Convert.2(%.1) [template]
// CHECK:STDOUT: %.37: %i32 = int_value 2 [template]
// CHECK:STDOUT: %.38: <bound method> = bound_method %.2, %Convert.14 [template]
// CHECK:STDOUT: %.39: <specific function> = specific_function %.38, @Convert.2(%.1) [template]
// CHECK:STDOUT: %.40: %i32 = int_value 3 [template]
// CHECK:STDOUT: %array: %.3 = tuple_value (%.34, %.37, %.40) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -125,41 +125,41 @@ fn G() -> i32 {
// CHECK:STDOUT: %.loc16_19: Core.IntLiteral = int_value 3 [template = constants.%.2]
// CHECK:STDOUT: %.loc16_20.1: %tuple.type = tuple_literal (%.loc16_13, %.loc16_16, %.loc16_19)
// CHECK:STDOUT: %.loc16_23.1: Core.IntLiteral = int_value 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc16_20.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_20.3: <bound method> = bound_method %.loc16_13, %.loc16_20.2 [template = constants.%.28]
// CHECK:STDOUT: %.loc16_20.4: <specific function> = specific_function %.loc16_20.3, @Convert.2(constants.%.1) [template = constants.%.29]
// CHECK:STDOUT: %int.convert_checked.loc16_20.1: init %i32 = call %.loc16_20.4(%.loc16_13) [template = constants.%.30]
// CHECK:STDOUT: %.loc16_20.5: init %i32 = converted %.loc16_13, %int.convert_checked.loc16_20.1 [template = constants.%.30]
// CHECK:STDOUT: %.loc16_20.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_20.3: <bound method> = bound_method %.loc16_13, %.loc16_20.2 [template = constants.%.32]
// CHECK:STDOUT: %.loc16_20.4: <specific function> = specific_function %.loc16_20.3, @Convert.2(constants.%.1) [template = constants.%.33]
// CHECK:STDOUT: %int.convert_checked.loc16_20.1: init %i32 = call %.loc16_20.4(%.loc16_13) [template = constants.%.34]
// CHECK:STDOUT: %.loc16_20.5: init %i32 = converted %.loc16_13, %int.convert_checked.loc16_20.1 [template = constants.%.34]
// CHECK:STDOUT: %.loc16_20.6: ref %.3 = temporary_storage
// CHECK:STDOUT: %.loc16_20.7: Core.IntLiteral = int_value 0 [template = constants.%.7]
// CHECK:STDOUT: %.loc16_20.8: ref %i32 = array_index %.loc16_20.6, %.loc16_20.7
// CHECK:STDOUT: %.loc16_20.9: init %i32 = initialize_from %.loc16_20.5 to %.loc16_20.8 [template = constants.%.30]
// CHECK:STDOUT: %.loc16_20.10: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_20.11: <bound method> = bound_method %.loc16_16, %.loc16_20.10 [template = constants.%.31]
// CHECK:STDOUT: %.loc16_20.12: <specific function> = specific_function %.loc16_20.11, @Convert.2(constants.%.1) [template = constants.%.32]
// CHECK:STDOUT: %int.convert_checked.loc16_20.2: init %i32 = call %.loc16_20.12(%.loc16_16) [template = constants.%.33]
// CHECK:STDOUT: %.loc16_20.13: init %i32 = converted %.loc16_16, %int.convert_checked.loc16_20.2 [template = constants.%.33]
// CHECK:STDOUT: %.loc16_20.9: init %i32 = initialize_from %.loc16_20.5 to %.loc16_20.8 [template = constants.%.34]
// CHECK:STDOUT: %.loc16_20.10: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_20.11: <bound method> = bound_method %.loc16_16, %.loc16_20.10 [template = constants.%.35]
// CHECK:STDOUT: %.loc16_20.12: <specific function> = specific_function %.loc16_20.11, @Convert.2(constants.%.1) [template = constants.%.36]
// CHECK:STDOUT: %int.convert_checked.loc16_20.2: init %i32 = call %.loc16_20.12(%.loc16_16) [template = constants.%.37]
// CHECK:STDOUT: %.loc16_20.13: init %i32 = converted %.loc16_16, %int.convert_checked.loc16_20.2 [template = constants.%.37]
// CHECK:STDOUT: %.loc16_20.14: Core.IntLiteral = int_value 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc16_20.15: ref %i32 = array_index %.loc16_20.6, %.loc16_20.14
// CHECK:STDOUT: %.loc16_20.16: init %i32 = initialize_from %.loc16_20.13 to %.loc16_20.15 [template = constants.%.33]
// CHECK:STDOUT: %.loc16_20.17: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_20.18: <bound method> = bound_method %.loc16_19, %.loc16_20.17 [template = constants.%.34]
// CHECK:STDOUT: %.loc16_20.19: <specific function> = specific_function %.loc16_20.18, @Convert.2(constants.%.1) [template = constants.%.35]
// CHECK:STDOUT: %int.convert_checked.loc16_20.3: init %i32 = call %.loc16_20.19(%.loc16_19) [template = constants.%.36]
// CHECK:STDOUT: %.loc16_20.20: init %i32 = converted %.loc16_19, %int.convert_checked.loc16_20.3 [template = constants.%.36]
// CHECK:STDOUT: %.loc16_20.16: init %i32 = initialize_from %.loc16_20.13 to %.loc16_20.15 [template = constants.%.37]
// CHECK:STDOUT: %.loc16_20.17: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_20.18: <bound method> = bound_method %.loc16_19, %.loc16_20.17 [template = constants.%.38]
// CHECK:STDOUT: %.loc16_20.19: <specific function> = specific_function %.loc16_20.18, @Convert.2(constants.%.1) [template = constants.%.39]
// CHECK:STDOUT: %int.convert_checked.loc16_20.3: init %i32 = call %.loc16_20.19(%.loc16_19) [template = constants.%.40]
// CHECK:STDOUT: %.loc16_20.20: init %i32 = converted %.loc16_19, %int.convert_checked.loc16_20.3 [template = constants.%.40]
// CHECK:STDOUT: %.loc16_20.21: Core.IntLiteral = int_value 2 [template = constants.%.6]
// CHECK:STDOUT: %.loc16_20.22: ref %i32 = array_index %.loc16_20.6, %.loc16_20.21
// CHECK:STDOUT: %.loc16_20.23: init %i32 = initialize_from %.loc16_20.20 to %.loc16_20.22 [template = constants.%.36]
// CHECK:STDOUT: %.loc16_20.23: init %i32 = initialize_from %.loc16_20.20 to %.loc16_20.22 [template = constants.%.40]
// CHECK:STDOUT: %.loc16_20.24: init %.3 = array_init (%.loc16_20.9, %.loc16_20.16, %.loc16_20.23) to %.loc16_20.6 [template = constants.%array]
// CHECK:STDOUT: %.loc16_20.25: init %.3 = converted %.loc16_20.1, %.loc16_20.24 [template = constants.%array]
// CHECK:STDOUT: %.loc16_20.26: ref %.3 = temporary %.loc16_20.6, %.loc16_20.25
// CHECK:STDOUT: %.loc16_20.27: %.3 = bind_value %.loc16_20.26
// CHECK:STDOUT: %.loc16_23.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_23.3: <bound method> = bound_method %.loc16_23.1, %.loc16_23.2 [template = constants.%.28]
// CHECK:STDOUT: %.loc16_23.4: <specific function> = specific_function %.loc16_23.3, @Convert.2(constants.%.1) [template = constants.%.29]
// CHECK:STDOUT: %int.convert_checked.loc16_23: init %i32 = call %.loc16_23.4(%.loc16_23.1) [template = constants.%.30]
// CHECK:STDOUT: %.loc16_23.5: %i32 = value_of_initializer %int.convert_checked.loc16_23 [template = constants.%.30]
// CHECK:STDOUT: %.loc16_23.6: %i32 = converted %.loc16_23.1, %.loc16_23.5 [template = constants.%.30]
// CHECK:STDOUT: %.loc16_23.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
// CHECK:STDOUT: %.loc16_23.3: <bound method> = bound_method %.loc16_23.1, %.loc16_23.2 [template = constants.%.32]
// CHECK:STDOUT: %.loc16_23.4: <specific function> = specific_function %.loc16_23.3, @Convert.2(constants.%.1) [template = constants.%.33]
// CHECK:STDOUT: %int.convert_checked.loc16_23: init %i32 = call %.loc16_23.4(%.loc16_23.1) [template = constants.%.34]
// CHECK:STDOUT: %.loc16_23.5: %i32 = value_of_initializer %int.convert_checked.loc16_23 [template = constants.%.34]
// CHECK:STDOUT: %.loc16_23.6: %i32 = converted %.loc16_23.1, %.loc16_23.5 [template = constants.%.34]
// CHECK:STDOUT: %F.call: init %i32 = call %F.ref(%.loc16_20.27, %.loc16_23.6)
// CHECK:STDOUT: %.loc16_25.1: %i32 = value_of_initializer %F.call
// CHECK:STDOUT: %.loc16_25.2: %i32 = converted %F.call, %.loc16_25.1