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
@@ -129,14 +129,14 @@ fn G() -> str {
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() -> %return.param: %str.ee0 {
// CHECK:STDOUT: fn @G() -> out %return.param: %str.ee0 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Produce.ref: %Produce.cpp_overload_set.type = name_ref Produce, imports.%Produce.cpp_overload_set.value [concrete = constants.%Produce.cpp_overload_set.value]
// CHECK:STDOUT: %.loc13_11.1: ref %str.ee0 = splice_block %return.param {}
// CHECK:STDOUT: %addr: %ptr.85f = addr_of %.loc13_11.1
// CHECK:STDOUT: %Produce__carbon_thunk.call: init %empty_tuple.type = call imports.%Produce__carbon_thunk.decl(%addr)
// CHECK:STDOUT: %.loc14: init %str.ee0 = in_place_init %Produce__carbon_thunk.call, %.loc13_11.1
// CHECK:STDOUT: %.loc14: init %str.ee0 to %.loc13_11.1 = in_place_init %Produce__carbon_thunk.call
// CHECK:STDOUT: return %.loc14 to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: