mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:44: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:
+20
-4
@@ -270,6 +270,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %.4d5: form = init_form %i32, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %B.type: type = fn_type @B [concrete]
|
||||
// CHECK:STDOUT: %B: %B.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [concrete]
|
||||
@@ -277,6 +278,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.b74: type = pattern_type %tuple.type.a1c [concrete]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete]
|
||||
// CHECK:STDOUT: %.d06: form = init_form %struct_type.c, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.688: type = pattern_type %struct_type.c [concrete]
|
||||
// CHECK:STDOUT: %C.type: type = fn_type @C [concrete]
|
||||
// CHECK:STDOUT: %C: %C.type = struct_value () [concrete]
|
||||
@@ -314,8 +316,9 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32.loc5_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc5_17: form = init_form %i32.loc5_17, call_param1 [concrete = constants.%.4d5]
|
||||
// CHECK:STDOUT: %b.param: %i32 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_9 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %.loc5_9: type = splice_block %i32.loc5_9 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc5_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -332,6 +335,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %int_32.loc6_25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc6_25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c]
|
||||
// CHECK:STDOUT: %.loc6_28: form = init_form %struct_type.c, call_param1 [concrete = constants.%.d06]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6_14.1: type = splice_block %.loc6_14.3 [concrete = constants.%tuple.type.a1c] {
|
||||
// CHECK:STDOUT: %int_32.loc6_10: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
@@ -370,6 +374,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %.4d5: form = init_form %i32, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %B.type: type = fn_type @B [concrete]
|
||||
// CHECK:STDOUT: %B: %B.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [concrete]
|
||||
@@ -377,6 +382,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.b74: type = pattern_type %tuple.type.a1c [concrete]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete]
|
||||
// CHECK:STDOUT: %.d06: form = init_form %struct_type.c, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.688: type = pattern_type %struct_type.c [concrete]
|
||||
// CHECK:STDOUT: %C.type: type = fn_type @C [concrete]
|
||||
// CHECK:STDOUT: %C: %C.type = struct_value () [concrete]
|
||||
@@ -414,8 +420,9 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32.loc5_52: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_52: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc5_52: form = init_form %i32.loc5_52, call_param1 [concrete = constants.%.4d5]
|
||||
// CHECK:STDOUT: %b.param: %i32 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_44 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %.loc5_44: type = splice_block %i32.loc5_44 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc5_44: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_44: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -432,6 +439,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %int_32.loc6_60: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc6_60: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c]
|
||||
// CHECK:STDOUT: %.loc6_63: form = init_form %struct_type.c, call_param1 [concrete = constants.%.d06]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6_49.1: type = splice_block %.loc6_49.3 [concrete = constants.%tuple.type.a1c] {
|
||||
// CHECK:STDOUT: %int_32.loc6_45: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
@@ -658,12 +666,14 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %.4d5: form = init_form %i32, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %B.type: type = fn_type @B [concrete]
|
||||
// CHECK:STDOUT: %B: %B.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [concrete]
|
||||
// CHECK:STDOUT: %tuple.896: %tuple.type.85c = tuple_value (%i32) [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [concrete]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete]
|
||||
// CHECK:STDOUT: %.d06: form = init_form %struct_type.c, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.688: type = pattern_type %struct_type.c [concrete]
|
||||
// CHECK:STDOUT: %C.type: type = fn_type @C [concrete]
|
||||
// CHECK:STDOUT: %C: %C.type = struct_value () [concrete]
|
||||
@@ -732,8 +742,9 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [concrete = constants.%B] {} {
|
||||
// CHECK:STDOUT: %int_32.loc23_24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc23_24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc23_24: form = init_form %i32.loc23_24, call_param1 [concrete = constants.%.4d5]
|
||||
// CHECK:STDOUT: %b.param: %i32 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc23: type = splice_block %i32.loc23_16 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %.loc23_16: type = splice_block %i32.loc23_16 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc23_16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc23_16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -745,6 +756,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %int_32.loc32_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc32_32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c]
|
||||
// CHECK:STDOUT: %.loc32_35: form = init_form %struct_type.c, call_param1 [concrete = constants.%.d06]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc32_21.1: type = splice_block %.loc32_21.3 [concrete = constants.%tuple.type.a1c] {
|
||||
// CHECK:STDOUT: %int_32.loc32_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
@@ -883,8 +895,10 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %D: %D.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %E.type: type = fn_type @E [concrete]
|
||||
// CHECK:STDOUT: %E: %E.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.49e: form = init_form %i32, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [concrete]
|
||||
// CHECK:STDOUT: %tuple.38e: %tuple.type.85c = tuple_value (%i32) [concrete]
|
||||
// CHECK:STDOUT: %.407: form = init_form %struct_type.c, call_param1 [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
|
||||
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
|
||||
@@ -946,8 +960,9 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [concrete = constants.%B] {} {
|
||||
// CHECK:STDOUT: %int_32.loc7_24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc7_24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc7_24: form = init_form %i32.loc7_24, call_param1 [concrete = constants.%.49e]
|
||||
// CHECK:STDOUT: %b.param: %i32 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %i32.loc7_16 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %.loc7_16: type = splice_block %i32.loc7_16 [concrete = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc7_16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc7_16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -959,6 +974,7 @@ import library "extern_api";
|
||||
// CHECK:STDOUT: %int_32.loc8_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc8_32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c]
|
||||
// CHECK:STDOUT: %.loc8_35: form = init_form %struct_type.c, call_param1 [concrete = constants.%.407]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.dd4 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc8_21.1: type = splice_block %.loc8_21.3 [concrete = constants.%tuple.type.dd4] {
|
||||
// CHECK:STDOUT: %int_32.loc8_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
|
||||
Reference in New Issue
Block a user