mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:21:16 +01:00
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:
co-authored by
Josh L
Richard Smith
parent
5e4038048b
commit
67f2c9ce26
+48
-48
@@ -32,20 +32,20 @@ fn G() {
|
||||
// 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: %tuple.type.2: type = tuple_type (type, type, type) [template]
|
||||
// CHECK:STDOUT: %tuple.type.3: type = tuple_type (%i32, %i32, %i32) [template]
|
||||
// CHECK:STDOUT: %tuple: %tuple.type.3 = tuple_value (%.30, %.33, %.36) [template]
|
||||
// CHECK:STDOUT: %tuple: %tuple.type.3 = tuple_value (%.34, %.37, %.40) [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
@@ -80,30 +80,30 @@ fn G() {
|
||||
// CHECK:STDOUT: %.loc13_25: Core.IntLiteral = int_value 2 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc13_28: Core.IntLiteral = int_value 3 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc13_29.1: %tuple.type.1 = tuple_literal (%.loc13_22, %.loc13_25, %.loc13_28)
|
||||
// CHECK:STDOUT: %.loc13_29.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc13_29.3: <bound method> = bound_method %.loc13_22, %.loc13_29.2 [template = constants.%.28]
|
||||
// CHECK:STDOUT: %.loc13_29.4: <specific function> = specific_function %.loc13_29.3, @Convert.2(constants.%.1) [template = constants.%.29]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_29.1: init %i32 = call %.loc13_29.4(%.loc13_22) [template = constants.%.30]
|
||||
// CHECK:STDOUT: %.loc13_29.5: init %i32 = converted %.loc13_22, %int.convert_checked.loc13_29.1 [template = constants.%.30]
|
||||
// CHECK:STDOUT: %.loc13_29.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc13_29.3: <bound method> = bound_method %.loc13_22, %.loc13_29.2 [template = constants.%.32]
|
||||
// CHECK:STDOUT: %.loc13_29.4: <specific function> = specific_function %.loc13_29.3, @Convert.2(constants.%.1) [template = constants.%.33]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_29.1: init %i32 = call %.loc13_29.4(%.loc13_22) [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc13_29.5: init %i32 = converted %.loc13_22, %int.convert_checked.loc13_29.1 [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc13_29.6: Core.IntLiteral = int_value 0 [template = constants.%.7]
|
||||
// CHECK:STDOUT: %.loc13_29.7: ref %i32 = array_index %a.var, %.loc13_29.6
|
||||
// CHECK:STDOUT: %.loc13_29.8: init %i32 = initialize_from %.loc13_29.5 to %.loc13_29.7 [template = constants.%.30]
|
||||
// CHECK:STDOUT: %.loc13_29.9: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc13_29.10: <bound method> = bound_method %.loc13_25, %.loc13_29.9 [template = constants.%.31]
|
||||
// CHECK:STDOUT: %.loc13_29.11: <specific function> = specific_function %.loc13_29.10, @Convert.2(constants.%.1) [template = constants.%.32]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_29.2: init %i32 = call %.loc13_29.11(%.loc13_25) [template = constants.%.33]
|
||||
// CHECK:STDOUT: %.loc13_29.12: init %i32 = converted %.loc13_25, %int.convert_checked.loc13_29.2 [template = constants.%.33]
|
||||
// CHECK:STDOUT: %.loc13_29.8: init %i32 = initialize_from %.loc13_29.5 to %.loc13_29.7 [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc13_29.9: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc13_29.10: <bound method> = bound_method %.loc13_25, %.loc13_29.9 [template = constants.%.35]
|
||||
// CHECK:STDOUT: %.loc13_29.11: <specific function> = specific_function %.loc13_29.10, @Convert.2(constants.%.1) [template = constants.%.36]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_29.2: init %i32 = call %.loc13_29.11(%.loc13_25) [template = constants.%.37]
|
||||
// CHECK:STDOUT: %.loc13_29.12: init %i32 = converted %.loc13_25, %int.convert_checked.loc13_29.2 [template = constants.%.37]
|
||||
// CHECK:STDOUT: %.loc13_29.13: Core.IntLiteral = int_value 1 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc13_29.14: ref %i32 = array_index %a.var, %.loc13_29.13
|
||||
// CHECK:STDOUT: %.loc13_29.15: init %i32 = initialize_from %.loc13_29.12 to %.loc13_29.14 [template = constants.%.33]
|
||||
// CHECK:STDOUT: %.loc13_29.16: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc13_29.17: <bound method> = bound_method %.loc13_28, %.loc13_29.16 [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc13_29.18: <specific function> = specific_function %.loc13_29.17, @Convert.2(constants.%.1) [template = constants.%.35]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_29.3: init %i32 = call %.loc13_29.18(%.loc13_28) [template = constants.%.36]
|
||||
// CHECK:STDOUT: %.loc13_29.19: init %i32 = converted %.loc13_28, %int.convert_checked.loc13_29.3 [template = constants.%.36]
|
||||
// CHECK:STDOUT: %.loc13_29.15: init %i32 = initialize_from %.loc13_29.12 to %.loc13_29.14 [template = constants.%.37]
|
||||
// CHECK:STDOUT: %.loc13_29.16: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc13_29.17: <bound method> = bound_method %.loc13_28, %.loc13_29.16 [template = constants.%.38]
|
||||
// CHECK:STDOUT: %.loc13_29.18: <specific function> = specific_function %.loc13_29.17, @Convert.2(constants.%.1) [template = constants.%.39]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_29.3: init %i32 = call %.loc13_29.18(%.loc13_28) [template = constants.%.40]
|
||||
// CHECK:STDOUT: %.loc13_29.19: init %i32 = converted %.loc13_28, %int.convert_checked.loc13_29.3 [template = constants.%.40]
|
||||
// CHECK:STDOUT: %.loc13_29.20: Core.IntLiteral = int_value 2 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc13_29.21: ref %i32 = array_index %a.var, %.loc13_29.20
|
||||
// CHECK:STDOUT: %.loc13_29.22: init %i32 = initialize_from %.loc13_29.19 to %.loc13_29.21 [template = constants.%.36]
|
||||
// CHECK:STDOUT: %.loc13_29.22: init %i32 = initialize_from %.loc13_29.19 to %.loc13_29.21 [template = constants.%.40]
|
||||
// CHECK:STDOUT: %.loc13_29.23: init %.3 = array_init (%.loc13_29.8, %.loc13_29.15, %.loc13_29.22) to %a.var [template = constants.%array]
|
||||
// CHECK:STDOUT: %.loc13_30: init %.3 = converted %.loc13_29.1, %.loc13_29.23 [template = constants.%array]
|
||||
// CHECK:STDOUT: assign %a.var, %.loc13_30
|
||||
@@ -127,27 +127,27 @@ fn G() {
|
||||
// CHECK:STDOUT: %.loc14_32: Core.IntLiteral = int_value 2 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc14_35: Core.IntLiteral = int_value 3 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc14_36.1: %tuple.type.1 = tuple_literal (%.loc14_29, %.loc14_32, %.loc14_35)
|
||||
// CHECK:STDOUT: %.loc14_36.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc14_36.3: <bound method> = bound_method %.loc14_29, %.loc14_36.2 [template = constants.%.28]
|
||||
// CHECK:STDOUT: %.loc14_36.4: <specific function> = specific_function %.loc14_36.3, @Convert.2(constants.%.1) [template = constants.%.29]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_36.1: init %i32 = call %.loc14_36.4(%.loc14_29) [template = constants.%.30]
|
||||
// CHECK:STDOUT: %.loc14_36.5: init %i32 = converted %.loc14_29, %int.convert_checked.loc14_36.1 [template = constants.%.30]
|
||||
// CHECK:STDOUT: %.loc14_36.2: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc14_36.3: <bound method> = bound_method %.loc14_29, %.loc14_36.2 [template = constants.%.32]
|
||||
// CHECK:STDOUT: %.loc14_36.4: <specific function> = specific_function %.loc14_36.3, @Convert.2(constants.%.1) [template = constants.%.33]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_36.1: init %i32 = call %.loc14_36.4(%.loc14_29) [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc14_36.5: init %i32 = converted %.loc14_29, %int.convert_checked.loc14_36.1 [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc14_36.6: ref %i32 = tuple_access %b.var, element0
|
||||
// CHECK:STDOUT: %.loc14_36.7: init %i32 = initialize_from %.loc14_36.5 to %.loc14_36.6 [template = constants.%.30]
|
||||
// CHECK:STDOUT: %.loc14_36.8: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc14_36.9: <bound method> = bound_method %.loc14_32, %.loc14_36.8 [template = constants.%.31]
|
||||
// CHECK:STDOUT: %.loc14_36.10: <specific function> = specific_function %.loc14_36.9, @Convert.2(constants.%.1) [template = constants.%.32]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_36.2: init %i32 = call %.loc14_36.10(%.loc14_32) [template = constants.%.33]
|
||||
// CHECK:STDOUT: %.loc14_36.11: init %i32 = converted %.loc14_32, %int.convert_checked.loc14_36.2 [template = constants.%.33]
|
||||
// CHECK:STDOUT: %.loc14_36.7: init %i32 = initialize_from %.loc14_36.5 to %.loc14_36.6 [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc14_36.8: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc14_36.9: <bound method> = bound_method %.loc14_32, %.loc14_36.8 [template = constants.%.35]
|
||||
// CHECK:STDOUT: %.loc14_36.10: <specific function> = specific_function %.loc14_36.9, @Convert.2(constants.%.1) [template = constants.%.36]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_36.2: init %i32 = call %.loc14_36.10(%.loc14_32) [template = constants.%.37]
|
||||
// CHECK:STDOUT: %.loc14_36.11: init %i32 = converted %.loc14_32, %int.convert_checked.loc14_36.2 [template = constants.%.37]
|
||||
// CHECK:STDOUT: %.loc14_36.12: ref %i32 = tuple_access %b.var, element1
|
||||
// CHECK:STDOUT: %.loc14_36.13: init %i32 = initialize_from %.loc14_36.11 to %.loc14_36.12 [template = constants.%.33]
|
||||
// CHECK:STDOUT: %.loc14_36.14: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc14_36.15: <bound method> = bound_method %.loc14_35, %.loc14_36.14 [template = constants.%.34]
|
||||
// CHECK:STDOUT: %.loc14_36.16: <specific function> = specific_function %.loc14_36.15, @Convert.2(constants.%.1) [template = constants.%.35]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_36.3: init %i32 = call %.loc14_36.16(%.loc14_35) [template = constants.%.36]
|
||||
// CHECK:STDOUT: %.loc14_36.17: init %i32 = converted %.loc14_35, %int.convert_checked.loc14_36.3 [template = constants.%.36]
|
||||
// CHECK:STDOUT: %.loc14_36.13: init %i32 = initialize_from %.loc14_36.11 to %.loc14_36.12 [template = constants.%.37]
|
||||
// CHECK:STDOUT: %.loc14_36.14: %Convert.type.2 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.14]
|
||||
// CHECK:STDOUT: %.loc14_36.15: <bound method> = bound_method %.loc14_35, %.loc14_36.14 [template = constants.%.38]
|
||||
// CHECK:STDOUT: %.loc14_36.16: <specific function> = specific_function %.loc14_36.15, @Convert.2(constants.%.1) [template = constants.%.39]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_36.3: init %i32 = call %.loc14_36.16(%.loc14_35) [template = constants.%.40]
|
||||
// CHECK:STDOUT: %.loc14_36.17: init %i32 = converted %.loc14_35, %int.convert_checked.loc14_36.3 [template = constants.%.40]
|
||||
// CHECK:STDOUT: %.loc14_36.18: ref %i32 = tuple_access %b.var, element2
|
||||
// CHECK:STDOUT: %.loc14_36.19: init %i32 = initialize_from %.loc14_36.17 to %.loc14_36.18 [template = constants.%.36]
|
||||
// CHECK:STDOUT: %.loc14_36.19: init %i32 = initialize_from %.loc14_36.17 to %.loc14_36.18 [template = constants.%.40]
|
||||
// CHECK:STDOUT: %.loc14_36.20: init %tuple.type.3 = tuple_init (%.loc14_36.7, %.loc14_36.13, %.loc14_36.19) to %b.var [template = constants.%tuple]
|
||||
// CHECK:STDOUT: %.loc14_37: init %tuple.type.3 = converted %.loc14_36.1, %.loc14_36.20 [template = constants.%tuple]
|
||||
// CHECK:STDOUT: assign %b.var, %.loc14_37
|
||||
|
||||
Reference in New Issue
Block a user