Form-aware textual format for return parameters and arguments (#6588)

The key changes are:
- Function output parameters are now prefixed with `out`, and more
consistently formatted as named parameters.
- Function and inst output arguments are now written as part of the inst
form, rather than as one of the inst arguments.

As a drive-by fix, this also changes `Temporary::storage_id` from
`DestInstId` to `InstId`, because it doesn't represent an output
parameter of the `Temporary` inst itself.

See the review of
[#6532](https://github.com/carbon-language/carbon-lang/pull/6532) and
[this Discord
discussion](https://discord.com/channels/655572317891461132/999638000126394370/1458268977020141589)
for additional background.
This commit is contained in:
Geoff Romer
2026-01-14 23:27:21 +00:00
committed by GitHub
parent 9861c31476
commit 4329a83e4c
353 changed files with 1779 additions and 1721 deletions
+1 -1
View File
@@ -100,7 +100,7 @@ fn F() -> i32 {
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %i32 {
// CHECK:STDOUT: fn @F() -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %n.patt: %pattern_type.7ce = ref_binding_pattern n [concrete]
+6 -6
View File
@@ -145,7 +145,7 @@ fn F() {
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16_46.1: init %i32 = call %bound_method.loc16_46.2(%int_1.loc16) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_46.2: init %i32 = converted %int_1.loc16, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16_46.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_46.3: ref %i32 = struct_access %s.var, element0
// CHECK:STDOUT: %.loc16_46.4: init %i32 = initialize_from %.loc16_46.2 to %.loc16_46.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_46.4: init %i32 to %.loc16_46.3 = initialize_from %.loc16_46.2 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc16_46.2: %.863 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
// CHECK:STDOUT: %bound_method.loc16_46.3: <bound method> = bound_method %int_2.loc16, %impl.elem0.loc16_46.2 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.4e5]
// CHECK:STDOUT: %specific_fn.loc16_46.2: <specific function> = specific_function %impl.elem0.loc16_46.2, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
@@ -153,8 +153,8 @@ fn F() {
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16_46.2: init %i32 = call %bound_method.loc16_46.4(%int_2.loc16) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc16_46.5: init %i32 = converted %int_2.loc16, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16_46.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc16_46.6: ref %i32 = struct_access %s.var, element1
// CHECK:STDOUT: %.loc16_46.7: init %i32 = initialize_from %.loc16_46.5 to %.loc16_46.6 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc16_46.8: init %struct_type.a.b.501 = struct_init (%.loc16_46.4, %.loc16_46.7) to %s.var [concrete = constants.%struct.ed5]
// CHECK:STDOUT: %.loc16_46.7: init %i32 to %.loc16_46.6 = initialize_from %.loc16_46.5 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc16_46.8: init %struct_type.a.b.501 to %s.var = struct_init (%.loc16_46.4, %.loc16_46.7) [concrete = constants.%struct.ed5]
// CHECK:STDOUT: %.loc16_3: init %struct_type.a.b.501 = converted %.loc16_46.1, %.loc16_46.8 [concrete = constants.%struct.ed5]
// CHECK:STDOUT: assign %s.var, %.loc16_3
// CHECK:STDOUT: %.loc16_27: type = splice_block %struct_type.a.b.loc16 [concrete = constants.%struct_type.a.b.501] {
@@ -242,7 +242,7 @@ fn F() {
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc22_28.1: init %i32 = call %bound_method.loc22_28.2(%int_1.loc22) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc22_28.2: init %i32 = converted %int_1.loc22, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc22_28.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %tuple.elem0.loc22: ref %i32 = tuple_access %t.var, element0
// CHECK:STDOUT: %.loc22_28.3: init %i32 = initialize_from %.loc22_28.2 to %tuple.elem0.loc22 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc22_28.3: init %i32 to %tuple.elem0.loc22 = initialize_from %.loc22_28.2 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc22_28.2: %.863 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
// CHECK:STDOUT: %bound_method.loc22_28.3: <bound method> = bound_method %int_2.loc22, %impl.elem0.loc22_28.2 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.4e5]
// CHECK:STDOUT: %specific_fn.loc22_28.2: <specific function> = specific_function %impl.elem0.loc22_28.2, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
@@ -250,8 +250,8 @@ fn F() {
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc22_28.2: init %i32 = call %bound_method.loc22_28.4(%int_2.loc22) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc22_28.4: init %i32 = converted %int_2.loc22, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc22_28.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %tuple.elem1.loc22: ref %i32 = tuple_access %t.var, element1
// CHECK:STDOUT: %.loc22_28.5: init %i32 = initialize_from %.loc22_28.4 to %tuple.elem1.loc22 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc22_28.6: init %tuple.type.d07 = tuple_init (%.loc22_28.3, %.loc22_28.5) to %t.var [concrete = constants.%tuple.21c]
// CHECK:STDOUT: %.loc22_28.5: init %i32 to %tuple.elem1.loc22 = initialize_from %.loc22_28.4 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc22_28.6: init %tuple.type.d07 to %t.var = tuple_init (%.loc22_28.3, %.loc22_28.5) [concrete = constants.%tuple.21c]
// CHECK:STDOUT: %.loc22_3: init %tuple.type.d07 = converted %.loc22_28.1, %.loc22_28.6 [concrete = constants.%tuple.21c]
// CHECK:STDOUT: assign %t.var, %.loc22_3
// CHECK:STDOUT: %.loc22_19.1: type = splice_block %.loc22_19.3 [concrete = constants.%tuple.type.d07] {
+1 -1
View File
@@ -116,7 +116,7 @@ fn F() -> i32 {
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %i32 {
// CHECK:STDOUT: fn @F() -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %n.patt: %pattern_type.7ce = ref_binding_pattern n [concrete]
+1 -1
View File
@@ -80,7 +80,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) {
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @ConstMismatch(%p.param: %ptr.bf9) -> %const.987 {
// CHECK:STDOUT: fn @ConstMismatch(%p.param: %ptr.bf9) -> out %return.param: %const.987 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %p.ref: %ptr.bf9 = name_ref p, %p
// CHECK:STDOUT: %.loc23: %const.987 = converted %p.ref, <error> [concrete = <error>]
+1 -1
View File
@@ -99,7 +99,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 {
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%p.param: %const.fa2) -> %const.20a {
// CHECK:STDOUT: fn @F(%p.param: %const.fa2) -> out %return.param: %const.20a {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %p.ref: %const.fa2 = name_ref p, %p
// CHECK:STDOUT: %.loc17_11.1: ref %const.58f = deref %p.ref
+2 -2
View File
@@ -121,7 +121,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* {
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Ptr(%p.param: %ptr.235) -> %ptr.235 {
// CHECK:STDOUT: fn @Ptr(%p.param: %ptr.235) -> out %return.param: %ptr.235 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %p.ref: %ptr.235 = name_ref p, %p
// CHECK:STDOUT: %impl.elem0: %.e6f = impl_witness_access constants.%Copy.impl_witness.843, element0 [concrete = constants.%ptr.as.Copy.impl.Op.011]
@@ -132,7 +132,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* {
// CHECK:STDOUT: return %ptr.as.Copy.impl.Op.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @ConstPtr(%p.param: %ptr.36b) -> %ptr.36b {
// CHECK:STDOUT: fn @ConstPtr(%p.param: %ptr.36b) -> out %return.param: %ptr.36b {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %p.ref: %ptr.36b = name_ref p, %p
// CHECK:STDOUT: %impl.elem0: %.dbc = impl_witness_access constants.%Copy.impl_witness.ce1, element0 [concrete = constants.%ptr.as.Copy.impl.Op.efa]