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
+13 -13
View File
@@ -170,12 +170,12 @@ let (a: {}, b: {}) = ({}, {}, {});
// CHECK:STDOUT: %.loc8_30.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc8_31.1: %tuple.type.b6b = tuple_literal (%.loc8_26.1, %.loc8_30.1) [concrete = constants.%tuple]
// CHECK:STDOUT: %tuple.elem0.loc8_31: ref %empty_struct_type = tuple_access %.var.loc8, element0
// CHECK:STDOUT: %.loc8_26.2: init %empty_struct_type = struct_init () to %tuple.elem0.loc8_31 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc8_26.2: init %empty_struct_type to %tuple.elem0.loc8_31 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc8_31.2: init %empty_struct_type = converted %.loc8_26.1, %.loc8_26.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %tuple.elem1.loc8_31: ref %empty_struct_type = tuple_access %.var.loc8, element1
// CHECK:STDOUT: %.loc8_30.2: init %empty_struct_type = struct_init () to %tuple.elem1.loc8_31 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc8_30.2: init %empty_struct_type to %tuple.elem1.loc8_31 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc8_31.3: init %empty_struct_type = converted %.loc8_30.1, %.loc8_30.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc8_31.4: init %tuple.type.b6b = tuple_init (%.loc8_31.2, %.loc8_31.3) to %.var.loc8 [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc8_31.4: init %tuple.type.b6b to %.var.loc8 = tuple_init (%.loc8_31.2, %.loc8_31.3) [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc8_3: init %tuple.type.b6b = converted %.loc8_31.1, %.loc8_31.4 [concrete = constants.%tuple]
// CHECK:STDOUT: assign %.var.loc8, %.loc8_3
// CHECK:STDOUT: %tuple.elem0.loc8_3: ref %empty_struct_type = tuple_access %.var.loc8, element0
@@ -229,12 +229,12 @@ let (a: {}, b: {}) = ({}, {}, {});
// CHECK:STDOUT: %.loc6_31.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_32.1: %tuple.type.b6b = tuple_literal (%.loc6_27.1, %.loc6_31.1) [concrete = constants.%tuple]
// CHECK:STDOUT: %tuple.elem0.loc6: ref %empty_struct_type = tuple_access %tuple.var, element0
// CHECK:STDOUT: %.loc6_27.2: init %empty_struct_type = struct_init () to %tuple.elem0.loc6 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_27.2: init %empty_struct_type to %tuple.elem0.loc6 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_32.2: init %empty_struct_type = converted %.loc6_27.1, %.loc6_27.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %tuple.elem1.loc6: ref %empty_struct_type = tuple_access %tuple.var, element1
// CHECK:STDOUT: %.loc6_31.2: init %empty_struct_type = struct_init () to %tuple.elem1.loc6 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_31.2: init %empty_struct_type to %tuple.elem1.loc6 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_32.3: init %empty_struct_type = converted %.loc6_31.1, %.loc6_31.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_32.4: init %tuple.type.b6b = tuple_init (%.loc6_32.2, %.loc6_32.3) to %tuple.var [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc6_32.4: init %tuple.type.b6b to %tuple.var = tuple_init (%.loc6_32.2, %.loc6_32.3) [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc6_3: init %tuple.type.b6b = converted %.loc6_32.1, %.loc6_32.4 [concrete = constants.%tuple]
// CHECK:STDOUT: assign %tuple.var, %.loc6_3
// CHECK:STDOUT: %.loc6_21.1: type = splice_block %.loc6_21.5 [concrete = constants.%tuple.type.b6b] {
@@ -256,13 +256,13 @@ let (a: {}, b: {}) = ({}, {}, {});
// CHECK:STDOUT: %tuple.ref: ref %tuple.type.b6b = name_ref tuple, %tuple
// CHECK:STDOUT: %tuple.elem0.loc7_24.1: ref %empty_struct_type = tuple_access %tuple.ref, element0
// CHECK:STDOUT: %tuple.elem0.loc7_24.2: ref %empty_struct_type = tuple_access %.var, element0
// CHECK:STDOUT: %.loc7_24.1: init %empty_struct_type = struct_init () to %tuple.elem0.loc7_24.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc7_24.1: init %empty_struct_type to %tuple.elem0.loc7_24.2 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc7_24.2: init %empty_struct_type = converted %tuple.elem0.loc7_24.1, %.loc7_24.1 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %tuple.elem1.loc7_24.1: ref %empty_struct_type = tuple_access %tuple.ref, element1
// CHECK:STDOUT: %tuple.elem1.loc7_24.2: ref %empty_struct_type = tuple_access %.var, element1
// CHECK:STDOUT: %.loc7_24.3: init %empty_struct_type = struct_init () to %tuple.elem1.loc7_24.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc7_24.3: init %empty_struct_type to %tuple.elem1.loc7_24.2 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc7_24.4: init %empty_struct_type = converted %tuple.elem1.loc7_24.1, %.loc7_24.3 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc7_24.5: init %tuple.type.b6b = tuple_init (%.loc7_24.2, %.loc7_24.4) to %.var [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc7_24.5: init %tuple.type.b6b to %.var = tuple_init (%.loc7_24.2, %.loc7_24.4) [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc7_3: init %tuple.type.b6b = converted %tuple.ref, %.loc7_24.5 [concrete = constants.%tuple]
// CHECK:STDOUT: assign %.var, %.loc7_3
// CHECK:STDOUT: %tuple.elem0.loc7_3: ref %empty_struct_type = tuple_access %.var, element0
@@ -319,13 +319,13 @@ let (a: {}, b: {}) = ({}, {}, {});
// CHECK:STDOUT: %tuple.ref: %tuple.type.b6b = name_ref tuple, %tuple.loc13_7
// CHECK:STDOUT: %tuple.elem0.loc14_24.1: %empty_struct_type = tuple_access %tuple.ref, element0
// CHECK:STDOUT: %tuple.elem0.loc14_24.2: ref %empty_struct_type = tuple_access %.var, element0
// CHECK:STDOUT: %.loc14_24.1: init %empty_struct_type = struct_init () to %tuple.elem0.loc14_24.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc14_24.1: init %empty_struct_type to %tuple.elem0.loc14_24.2 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc14_24.2: init %empty_struct_type = converted %tuple.elem0.loc14_24.1, %.loc14_24.1 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %tuple.elem1.loc14_24.1: %empty_struct_type = tuple_access %tuple.ref, element1
// CHECK:STDOUT: %tuple.elem1.loc14_24.2: ref %empty_struct_type = tuple_access %.var, element1
// CHECK:STDOUT: %.loc14_24.3: init %empty_struct_type = struct_init () to %tuple.elem1.loc14_24.2 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc14_24.3: init %empty_struct_type to %tuple.elem1.loc14_24.2 = struct_init () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc14_24.4: init %empty_struct_type = converted %tuple.elem1.loc14_24.1, %.loc14_24.3 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc14_24.5: init %tuple.type.b6b = tuple_init (%.loc14_24.2, %.loc14_24.4) to %.var [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc14_24.5: init %tuple.type.b6b to %.var = tuple_init (%.loc14_24.2, %.loc14_24.4) [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc14_3: init %tuple.type.b6b = converted %tuple.ref, %.loc14_24.5 [concrete = constants.%tuple]
// CHECK:STDOUT: assign %.var, %.loc14_3
// CHECK:STDOUT: %tuple.elem0.loc14_3: ref %empty_struct_type = tuple_access %.var, element0
@@ -356,7 +356,7 @@ let (a: {}, b: {}) = ({}, {}, {});
// CHECK:STDOUT: %.var: ref %tuple.type.b6b = var %.var_patt
// CHECK:STDOUT: %MakeTuple.ref: %MakeTuple.type = name_ref MakeTuple, file.%MakeTuple.decl [concrete = constants.%MakeTuple]
// CHECK:STDOUT: %.loc22_3: ref %tuple.type.b6b = splice_block %.var {}
// CHECK:STDOUT: %MakeTuple.call: init %tuple.type.b6b = call %MakeTuple.ref() to %.loc22_3
// CHECK:STDOUT: %MakeTuple.call: init %tuple.type.b6b to %.loc22_3 = call %MakeTuple.ref()
// CHECK:STDOUT: assign %.var, %MakeTuple.call
// CHECK:STDOUT: %tuple.elem0: ref %empty_struct_type = tuple_access %.var, element0
// CHECK:STDOUT: %tuple.elem1: ref %empty_struct_type = tuple_access %.var, element1