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
+3 -1
View File
@@ -465,6 +465,7 @@ class V {
// CHECK:STDOUT: %pattern_type.5c86: type = pattern_type %ptr.ddb [concrete]
// CHECK:STDOUT: %Base: type = class_type @Base [concrete]
// CHECK:STDOUT: %ptr.fb2: type = ptr_type %Base [concrete]
// CHECK:STDOUT: %.43a: form = init_form %ptr.fb2, call_param1 [concrete]
// CHECK:STDOUT: %pattern_type.72a: type = pattern_type %ptr.fb2 [concrete]
// CHECK:STDOUT: %ConvertPtr.type: type = fn_type @ConvertPtr [concrete]
// CHECK:STDOUT: %ConvertPtr: %ConvertPtr.type = struct_value () [concrete]
@@ -508,8 +509,9 @@ class V {
// CHECK:STDOUT: %Cpp.ref.loc7_35: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%Base.decl [concrete = constants.%Base]
// CHECK:STDOUT: %ptr.loc7_43: type = ptr_type %Base.ref [concrete = constants.%ptr.fb2]
// CHECK:STDOUT: %.loc7_43: form = init_form %ptr.loc7_43, call_param1 [concrete = constants.%.43a]
// CHECK:STDOUT: %d.param: %ptr.ddb = value_param call_param0
// CHECK:STDOUT: %.loc7: type = splice_block %ptr.loc7_29 [concrete = constants.%ptr.ddb] {
// CHECK:STDOUT: %.loc7_29: type = splice_block %ptr.loc7_29 [concrete = constants.%ptr.ddb] {
// CHECK:STDOUT: %Cpp.ref.loc7_18: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, imports.%Derived.decl [concrete = constants.%Derived]
// CHECK:STDOUT: %ptr.loc7_29: type = ptr_type %Derived.ref [concrete = constants.%ptr.ddb]