Model the return slot as an output parameter (#4432)

Also fix `Param` insts to have meaningful names in pretty-printing, to
help clarify relationship with return slot.
This commit is contained in:
Geoff Romer
2024-10-23 16:53:34 +00:00
committed by GitHub
parent 5038218cea
commit 9266f867f9
463 changed files with 7401 additions and 4939 deletions
+49 -17
View File
@@ -68,7 +68,7 @@ fn While() {
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -85,53 +85,85 @@ fn While() {
// CHECK:STDOUT: .While = %While.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {
// CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc11_11.2: type = converted %bool.make_type, %.loc11_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {
// CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc12_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc12_11.2: type = converted %bool.make_type, %.loc12_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {
// CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc13_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc13_11.2: type = converted %bool.make_type, %.loc13_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {
// CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc14_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc14_11.2: type = converted %bool.make_type, %.loc14_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {
// CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc15_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc15_11.2: type = converted %bool.make_type, %.loc15_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc16_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc16_11.2: type = converted %bool.make_type, %.loc16_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc17_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc17_11.2: type = converted %bool.make_type, %.loc17_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} {
// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc18_11.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc18_11.2: type = converted %bool.make_type, %.loc18_11.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %While.decl: %While.type = fn_decl @While [template = constants.%While] {} {}
// CHECK:STDOUT: }
+6 -6
View File
@@ -57,12 +57,12 @@ fn While() {
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+46, loaded [template = constants.%ImplicitAs]
// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+52, unloaded
// CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.4) = import_ref Core//prelude/operators/as, inst+71, loaded [symbolic = @ImplicitAs.%.2 (constants.%.8)]
// CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+64, unloaded
// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+64, unloaded
// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+64, unloaded
// CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+55, unloaded
// CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.4) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.8)]
// CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+70, unloaded
// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded
// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
+7 -3
View File
@@ -53,7 +53,7 @@ fn While() {
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -66,11 +66,15 @@ fn While() {
// CHECK:STDOUT: .While = %While.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Cond.decl: %Cond.type = fn_decl @Cond [template = constants.%Cond] {} {
// CHECK:STDOUT: %Cond.decl: %Cond.type = fn_decl @Cond [template = constants.%Cond] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc11_14.2: type = converted %bool.make_type, %.loc11_14.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {}
+7 -3
View File
@@ -52,7 +52,7 @@ fn While() {
// CHECK:STDOUT: import Core//prelude/operators/comparison
// CHECK:STDOUT: import Core//prelude/types/bool
// CHECK:STDOUT: }
// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -65,11 +65,15 @@ fn While() {
// CHECK:STDOUT: .While = %While.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Cond.decl: %Cond.type = fn_decl @Cond [template = constants.%Cond] {} {
// CHECK:STDOUT: %Cond.decl: %Cond.type = fn_decl @Cond [template = constants.%Cond] {
// CHECK:STDOUT: %return.patt: bool = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: bool = param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
// CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %bool.make_type [template = bool]
// CHECK:STDOUT: %.loc11_14.2: type = converted %bool.make_type, %.loc11_14.1 [template = bool]
// CHECK:STDOUT: %return: ref bool = var <return slot>
// CHECK:STDOUT: %return.param: bool = param runtime_param0
// CHECK:STDOUT: %return: ref bool = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {}