mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -94,6 +94,7 @@ fn F() -> Cpp.AbstractFinal {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %AbstractFinal: type = class_type @AbstractFinal [concrete]
|
||||
// CHECK:STDOUT: %.fd6: form = init_form %AbstractFinal, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %AbstractFinal [concrete]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
@@ -114,6 +115,7 @@ fn F() -> Cpp.AbstractFinal {
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %AbstractFinal.ref: type = name_ref AbstractFinal, imports.%AbstractFinal.decl [concrete = constants.%AbstractFinal]
|
||||
// CHECK:STDOUT: %.loc11_14: form = init_form %AbstractFinal.ref, call_param0 [concrete = constants.%.fd6]
|
||||
// CHECK:STDOUT: %return.param: ref %AbstractFinal = out_param call_param0
|
||||
// CHECK:STDOUT: %return: ref %AbstractFinal = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
@@ -122,8 +124,8 @@ fn F() -> Cpp.AbstractFinal {
|
||||
// CHECK:STDOUT: fn @F() -> %return.param: %AbstractFinal {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
|
||||
// CHECK:STDOUT: %.loc11: ref %AbstractFinal = splice_block %return {}
|
||||
// CHECK:STDOUT: %F.call: init %AbstractFinal = call %F.ref() to %.loc11
|
||||
// CHECK:STDOUT: %.loc11_8: ref %AbstractFinal = splice_block %return {}
|
||||
// CHECK:STDOUT: %F.call: init %AbstractFinal = call %F.ref() to %.loc11_8
|
||||
// CHECK:STDOUT: return %F.call to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
+3
-1
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user