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
@@ -116,7 +116,7 @@ var a2: Cpp.Second(Cpp.B, Cpp.A) = Cpp.A.A();
// CHECK:STDOUT: %.loc7_1: ref %A = splice_block file.%a1.var [concrete = file.%a1.var] {}
// CHECK:STDOUT: %addr.loc7: %ptr.270 = addr_of %.loc7_1
// CHECK:STDOUT: %A__carbon_thunk.call.loc7: init %empty_tuple.type = call imports.%A__carbon_thunk.decl(%addr.loc7)
// CHECK:STDOUT: %.loc7_43: init %A = in_place_init %A__carbon_thunk.call.loc7, %.loc7_1
// CHECK:STDOUT: %.loc7_43: init %A to %.loc7_1 = in_place_init %A__carbon_thunk.call.loc7
// CHECK:STDOUT: assign file.%a1.var, %.loc7_43
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %B.ref.loc8_38: type = name_ref B, imports.%B.decl [concrete = constants.%B]
@@ -124,7 +124,7 @@ var a2: Cpp.Second(Cpp.B, Cpp.A) = Cpp.A.A();
// CHECK:STDOUT: %.loc8_1: ref %B = splice_block file.%b1.var [concrete = file.%b1.var] {}
// CHECK:STDOUT: %addr.loc8: %ptr.a04 = addr_of %.loc8_1
// CHECK:STDOUT: %B__carbon_thunk.call.loc8: init %empty_tuple.type = call imports.%B__carbon_thunk.decl(%addr.loc8)
// CHECK:STDOUT: %.loc8_43: init %B = in_place_init %B__carbon_thunk.call.loc8, %.loc8_1
// CHECK:STDOUT: %.loc8_43: init %B to %.loc8_1 = in_place_init %B__carbon_thunk.call.loc8
// CHECK:STDOUT: assign file.%b1.var, %.loc8_43
// CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %B.ref.loc9_39: type = name_ref B, imports.%B.decl [concrete = constants.%B]
@@ -132,7 +132,7 @@ var a2: Cpp.Second(Cpp.B, Cpp.A) = Cpp.A.A();
// CHECK:STDOUT: %.loc9_1: ref %B = splice_block file.%b2.var [concrete = file.%b2.var] {}
// CHECK:STDOUT: %addr.loc9: %ptr.a04 = addr_of %.loc9_1
// CHECK:STDOUT: %B__carbon_thunk.call.loc9: init %empty_tuple.type = call imports.%B__carbon_thunk.decl(%addr.loc9)
// CHECK:STDOUT: %.loc9_44: init %B = in_place_init %B__carbon_thunk.call.loc9, %.loc9_1
// CHECK:STDOUT: %.loc9_44: init %B to %.loc9_1 = in_place_init %B__carbon_thunk.call.loc9
// CHECK:STDOUT: assign file.%b2.var, %.loc9_44
// CHECK:STDOUT: %Cpp.ref.loc10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %A.ref.loc10_39: type = name_ref A, imports.%A.decl [concrete = constants.%A]
@@ -140,7 +140,7 @@ var a2: Cpp.Second(Cpp.B, Cpp.A) = Cpp.A.A();
// CHECK:STDOUT: %.loc10_1: ref %A = splice_block file.%a2.var [concrete = file.%a2.var] {}
// CHECK:STDOUT: %addr.loc10: %ptr.270 = addr_of %.loc10_1
// CHECK:STDOUT: %A__carbon_thunk.call.loc10: init %empty_tuple.type = call imports.%A__carbon_thunk.decl(%addr.loc10)
// CHECK:STDOUT: %.loc10_44: init %A = in_place_init %A__carbon_thunk.call.loc10, %.loc10_1
// CHECK:STDOUT: %.loc10_44: init %A to %.loc10_1 = in_place_init %A__carbon_thunk.call.loc10
// CHECK:STDOUT: assign file.%a2.var, %.loc10_44
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
@@ -94,7 +94,7 @@ var a: Cpp.A = Cpp.X(Cpp.A, Cpp.B).f({} as Cpp.B);
// CHECK:STDOUT: %Cpp.ref.loc7_44: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %B.ref.loc7_47: type = name_ref B, imports.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc7_39.2: ref %B = temporary_storage
// CHECK:STDOUT: %.loc7_39.3: init %B = class_init (), %.loc7_39.2 [concrete = constants.%B.val]
// CHECK:STDOUT: %.loc7_39.3: init %B to %.loc7_39.2 = class_init () [concrete = constants.%B.val]
// CHECK:STDOUT: %.loc7_39.4: ref %B = temporary %.loc7_39.2, %.loc7_39.3
// CHECK:STDOUT: %.loc7_41.1: ref %B = converted %.loc7_39.1, %.loc7_39.4
// CHECK:STDOUT: %.loc7_1: ref %A = splice_block file.%a.var [concrete = file.%a.var] {}
@@ -103,7 +103,7 @@ var a: Cpp.A = Cpp.X(Cpp.A, Cpp.B).f({} as Cpp.B);
// CHECK:STDOUT: %addr.loc7_49.1: %ptr.a04 = addr_of %.loc7_41.3
// CHECK:STDOUT: %addr.loc7_49.2: %ptr.270 = addr_of %.loc7_1
// CHECK:STDOUT: %f__carbon_thunk.call: init %empty_tuple.type = call imports.%f__carbon_thunk.decl(%addr.loc7_49.1, %addr.loc7_49.2)
// CHECK:STDOUT: %.loc7_49: init %A = in_place_init %f__carbon_thunk.call, %.loc7_1
// CHECK:STDOUT: %.loc7_49: init %A to %.loc7_1 = in_place_init %f__carbon_thunk.call
// CHECK:STDOUT: assign file.%a.var, %.loc7_49
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
@@ -110,7 +110,7 @@ var x2: X(Cpp.IsLarge(Cpp.Large)) = X(true).Make();
// CHECK:STDOUT: %Make.ref.loc11: %X.Make.type.4e2 = name_ref Make, %.loc11_45 [concrete = constants.%X.Make.ae0]
// CHECK:STDOUT: %X.Make.specific_fn.loc11: <specific function> = specific_function %Make.ref.loc11, @X.Make(constants.%false) [concrete = constants.%X.Make.specific_fn.9a2]
// CHECK:STDOUT: %.loc11_1: ref %X.49c = splice_block file.%x1.var [concrete = file.%x1.var] {}
// CHECK:STDOUT: %X.Make.call.loc11: init %X.49c = call %X.Make.specific_fn.loc11() to %.loc11_1
// CHECK:STDOUT: %X.Make.call.loc11: init %X.49c to %.loc11_1 = call %X.Make.specific_fn.loc11()
// CHECK:STDOUT: assign file.%x1.var, %X.Make.call.loc11
// CHECK:STDOUT: %X.ref.loc12: %X.type = name_ref X, file.%X.decl [concrete = constants.%X.generic]
// CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
@@ -119,7 +119,7 @@ var x2: X(Cpp.IsLarge(Cpp.Large)) = X(true).Make();
// CHECK:STDOUT: %Make.ref.loc12: %X.Make.type.7d1 = name_ref Make, %.loc12_44 [concrete = constants.%X.Make.3ee]
// CHECK:STDOUT: %X.Make.specific_fn.loc12: <specific function> = specific_function %Make.ref.loc12, @X.Make(constants.%true) [concrete = constants.%X.Make.specific_fn.5a7]
// CHECK:STDOUT: %.loc12_1: ref %X.07f = splice_block file.%x2.var [concrete = file.%x2.var] {}
// CHECK:STDOUT: %X.Make.call.loc12: init %X.07f = call %X.Make.specific_fn.loc12() to %.loc12_1
// CHECK:STDOUT: %X.Make.call.loc12: init %X.07f to %.loc12_1 = call %X.Make.specific_fn.loc12()
// CHECK:STDOUT: assign file.%x2.var, %X.Make.call.loc12
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }