Initial support for return forms (#6556)

The main changes here are:
- Introducing `InitForm` and `RefForm` to represent initializing and
reference forms (the two return forms currently supported by the
parser).
- Introducing the `FormType` singleton inst to represent their type
(i.e. `Core.Form`).
- Emitting an inst representing a function's declared return form as
part of handling the function signature.

The return form inst is currently ignored. Subsequent PRs will expose it
in `SemIR::Function` and use it to determine the form of call
expressions.
This commit is contained in:
Geoff Romer
2026-01-07 00:54:18 +00:00
committed by GitHub
parent 444c18dfa3
commit 505b1c86b9
225 changed files with 4164 additions and 2583 deletions
@@ -26,6 +26,7 @@ fn Main() {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
// CHECK:STDOUT: %.3e7: form = init_form %empty_tuple.type, call_param1 [concrete]
// CHECK:STDOUT: %Echo.type: type = fn_type @Echo [concrete]
// CHECK:STDOUT: %Echo: %Echo.type = struct_value () [concrete]
// CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
@@ -45,6 +46,7 @@ fn Main() {
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc15_20.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc15_20.2: type = converted %.loc15_20.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc15_20.3: form = init_form %.loc15_20.2, call_param1 [concrete = constants.%.3e7]
// CHECK:STDOUT: %a.param: %empty_tuple.type = value_param call_param0
// CHECK:STDOUT: %.loc15_13.1: type = splice_block %.loc15_13.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc15_13.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]