Switch type literals to use builtin functions. (#3978)

Modifies the core package and literal handling to use factory functions
for standard type literals.

Updates function/builtin/import.carbon to stop depending on the prelude,
since it would list all the impls in the core file. Updates
alias/builtins.carbon to be failing (the type values cannot be aliased).
This commit is contained in:
Jon Ross-Perkins
2024-05-23 16:00:08 +00:00
committed by GitHub
parent 5c8fa6ad5c
commit 55300d1ebb
314 changed files with 12506 additions and 4323 deletions
@@ -16,7 +16,9 @@ fn Run() {
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Run: type = fn_type @Run [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct: Run = struct_value () [template]
// CHECK:STDOUT: %struct.1: Run = struct_value () [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %struct.2: Int32 = struct_value () [template]
// CHECK:STDOUT: %.2: type = ptr_type String [template]
// CHECK:STDOUT: %.3: String = string_literal "hello" [template]
// CHECK:STDOUT: }
@@ -27,15 +29,21 @@ fn Run() {
// CHECK:STDOUT: .Run = %Run.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Run.decl: Run = fn_decl @Run [template = constants.%struct] {}
// CHECK:STDOUT: %Run.decl: Run = fn_decl @Run [template = constants.%struct.1] {}
// CHECK:STDOUT: %import_ref: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.2]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.2() [template = i32]
// CHECK:STDOUT: %.loc11_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc11_10.2: type = converted %int.make_type_32, %.loc11_10.1 [template = i32]
// CHECK:STDOUT: %x.var: ref i32 = var x
// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
// CHECK:STDOUT: %.loc11: String = string_literal "hello" [template = constants.%.3]
// CHECK:STDOUT: %.loc11_16: String = string_literal "hello" [template = constants.%.3]
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
@@ -66,12 +66,14 @@ fn Main() {
// CHECK:STDOUT: %Run0: type = fn_type @Run0 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Run0 = struct_value () [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %struct.2: Int32 = struct_value () [template]
// CHECK:STDOUT: %Run1: type = fn_type @Run1 [template]
// CHECK:STDOUT: %struct.2: Run1 = struct_value () [template]
// CHECK:STDOUT: %struct.3: Run1 = struct_value () [template]
// CHECK:STDOUT: %Run2: type = fn_type @Run2 [template]
// CHECK:STDOUT: %struct.3: Run2 = struct_value () [template]
// CHECK:STDOUT: %struct.4: Run2 = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.4: Main = struct_value () [template]
// CHECK:STDOUT: %struct.5: Main = struct_value () [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 0 [template]
// CHECK:STDOUT: }
@@ -86,17 +88,29 @@ fn Main() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Run0.decl: Run0 = fn_decl @Run0 [template = constants.%struct.1] {}
// CHECK:STDOUT: %Run1.decl: Run1 = fn_decl @Run1 [template = constants.%struct.2] {
// CHECK:STDOUT: %import_ref.1: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.2]
// CHECK:STDOUT: %Run1.decl: Run1 = fn_decl @Run1 [template = constants.%struct.3] {
// CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%struct.2() [template = i32]
// CHECK:STDOUT: %.loc8_12.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
// CHECK:STDOUT: %.loc8_12.2: type = converted %int.make_type_32.loc8, %.loc8_12.1 [template = i32]
// CHECK:STDOUT: %a.loc8_9.1: i32 = param a
// CHECK:STDOUT: @Run1.%a: i32 = bind_name a, %a.loc8_9.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Run2.decl: Run2 = fn_decl @Run2 [template = constants.%struct.3] {
// CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.2]
// CHECK:STDOUT: %import_ref.3: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.2]
// CHECK:STDOUT: %Run2.decl: Run2 = fn_decl @Run2 [template = constants.%struct.4] {
// CHECK:STDOUT: %int.make_type_32.loc9_12: init type = call constants.%struct.2() [template = i32]
// CHECK:STDOUT: %.loc9_12.1: type = value_of_initializer %int.make_type_32.loc9_12 [template = i32]
// CHECK:STDOUT: %.loc9_12.2: type = converted %int.make_type_32.loc9_12, %.loc9_12.1 [template = i32]
// CHECK:STDOUT: %a.loc9_9.1: i32 = param a
// CHECK:STDOUT: @Run2.%a: i32 = bind_name a, %a.loc9_9.1
// CHECK:STDOUT: %int.make_type_32.loc9_20: init type = call constants.%struct.2() [template = i32]
// CHECK:STDOUT: %.loc9_20.1: type = value_of_initializer %int.make_type_32.loc9_20 [template = i32]
// CHECK:STDOUT: %.loc9_20.2: type = converted %int.make_type_32.loc9_20, %.loc9_20.1 [template = i32]
// CHECK:STDOUT: %b.loc9_17.1: i32 = param b
// CHECK:STDOUT: @Run2.%b: i32 = bind_name b, %b.loc9_17.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.4] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.5] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run0() {
@@ -104,6 +118,8 @@ fn Main() {
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run1(%a: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -123,15 +139,15 @@ fn Main() {
// CHECK:STDOUT: %.loc27_8: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %.loc27_11: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Run0.call.loc27: init () = call %Run0.ref.loc27(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run1.ref.loc36: Run1 = name_ref Run1, file.%Run1.decl [template = constants.%struct.2]
// CHECK:STDOUT: %Run1.ref.loc36: Run1 = name_ref Run1, file.%Run1.decl [template = constants.%struct.3]
// CHECK:STDOUT: %Run1.call.loc36: init () = call %Run1.ref.loc36(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run1.ref.loc44: Run1 = name_ref Run1, file.%Run1.decl [template = constants.%struct.2]
// CHECK:STDOUT: %Run1.ref.loc44: Run1 = name_ref Run1, file.%Run1.decl [template = constants.%struct.3]
// CHECK:STDOUT: %.loc44_8: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %.loc44_11: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Run1.call.loc44: init () = call %Run1.ref.loc44(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run2.ref.loc53: Run2 = name_ref Run2, file.%Run2.decl [template = constants.%struct.3]
// CHECK:STDOUT: %Run2.ref.loc53: Run2 = name_ref Run2, file.%Run2.decl [template = constants.%struct.4]
// CHECK:STDOUT: %Run2.call.loc53: init () = call %Run2.ref.loc53(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run2.ref.loc60: Run2 = name_ref Run2, file.%Run2.decl [template = constants.%struct.3]
// CHECK:STDOUT: %Run2.ref.loc60: Run2 = name_ref Run2, file.%Run2.decl [template = constants.%struct.4]
// CHECK:STDOUT: %.loc60: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %Run2.call.loc60: init () = call %Run2.ref.loc60(<invalid>) [template = <error>]
// CHECK:STDOUT: return
@@ -19,11 +19,13 @@ fn F() {
// CHECK:STDOUT: --- fail_param_type.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %G: type = fn_type @G [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: G = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %G: type = fn_type @G [template]
// CHECK:STDOUT: %struct.2: G = struct_value () [template]
// CHECK:STDOUT: %F: type = fn_type @F [template]
// CHECK:STDOUT: %struct.2: F = struct_value () [template]
// CHECK:STDOUT: %struct.3: F = struct_value () [template]
// CHECK:STDOUT: %.2: f64 = float_literal 1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -34,13 +36,19 @@ fn F() {
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_9.1: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc7_9.2: type = converted %int.make_type_32, %.loc7_9.1 [template = i32]
// CHECK:STDOUT: %a.loc7_6.1: i32 = param a
// CHECK:STDOUT: @G.%a: i32 = bind_name a, %a.loc7_6.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.2] {}
// CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.3] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G(%a: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -48,7 +56,7 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %G.ref: G = name_ref G, file.%G.decl [template = constants.%struct.1]
// CHECK:STDOUT: %G.ref: G = name_ref G, file.%G.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc16: f64 = float_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %G.call: init () = call %G.ref(<invalid>) [template = <error>]
// CHECK:STDOUT: return
@@ -16,12 +16,17 @@ fn Run() {
// CHECK:STDOUT: --- fail_return_type_mismatch.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 64 [template]
// CHECK:STDOUT: %Float: type = fn_type @Float [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Float = struct_value () [template]
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
// CHECK:STDOUT: %.2: f64 = float_literal 1 [template]
// CHECK:STDOUT: %struct.2: Foo = struct_value () [template]
// CHECK:STDOUT: %.3: f64 = float_literal 1 [template]
// CHECK:STDOUT: %Run: type = fn_type @Run [template]
// CHECK:STDOUT: %struct.2: Run = struct_value () [template]
// CHECK:STDOUT: %struct.3: Run = struct_value () [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %struct.4: Int32 = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -31,25 +36,38 @@ fn Run() {
// CHECK:STDOUT: .Run = %Run.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref.1: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.2] {
// CHECK:STDOUT: %.loc7_13.1: i32 = int_literal 64 [template = constants.%.1]
// CHECK:STDOUT: %float.make_type: init type = call constants.%struct.1(%.loc7_13.1) [template = f64]
// CHECK:STDOUT: %.loc7_13.2: type = value_of_initializer %float.make_type [template = f64]
// CHECK:STDOUT: %.loc7_13.3: type = converted %float.make_type, %.loc7_13.2 [template = f64]
// CHECK:STDOUT: @Foo.%return: ref f64 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Run.decl: Run = fn_decl @Run [template = constants.%struct.2] {}
// CHECK:STDOUT: %Run.decl: Run = fn_decl @Run [template = constants.%struct.3] {}
// CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.4]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() -> f64 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc7: f64 = float_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc7: f64 = float_literal 1 [template = constants.%.3]
// CHECK:STDOUT: return %.loc7
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.4() [template = i32]
// CHECK:STDOUT: %.loc13_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc13_10.2: type = converted %int.make_type_32, %.loc13_10.1 [template = i32]
// CHECK:STDOUT: %x.var: ref i32 = var x
// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %Foo.call: init f64 = call %Foo.ref()
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
+24 -8
View File
@@ -15,11 +15,13 @@ fn Main() {
// CHECK:STDOUT: --- i32.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Echo: type = fn_type @Echo [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Echo = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %Echo: type = fn_type @Echo [template]
// CHECK:STDOUT: %struct.2: Echo = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.2: Main = struct_value () [template]
// CHECK:STDOUT: %struct.3: Main = struct_value () [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -30,14 +32,25 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Echo.decl: Echo = fn_decl @Echo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref.1: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Echo.decl: Echo = fn_decl @Echo [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32.loc7_12: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_12.1: type = value_of_initializer %int.make_type_32.loc7_12 [template = i32]
// CHECK:STDOUT: %.loc7_12.2: type = converted %int.make_type_32.loc7_12, %.loc7_12.1 [template = i32]
// CHECK:STDOUT: %a.loc7_9.1: i32 = param a
// CHECK:STDOUT: @Echo.%a: i32 = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %int.make_type_32.loc7_20: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_20.1: type = value_of_initializer %int.make_type_32.loc7_20 [template = i32]
// CHECK:STDOUT: %.loc7_20.2: type = converted %int.make_type_32.loc7_20, %.loc7_20.1 [template = i32]
// CHECK:STDOUT: @Echo.%return: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.3] {}
// CHECK:STDOUT: %import_ref.3: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Echo(%a: i32) -> i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a.ref: i32 = name_ref a, %a
@@ -46,11 +59,14 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_32, %.loc12_10.1 [template = i32]
// CHECK:STDOUT: %b.var: ref i32 = var b
// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
// CHECK:STDOUT: %Echo.ref: Echo = name_ref Echo, file.%Echo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %.loc12: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Echo.call: init i32 = call %Echo.ref(%.loc12)
// CHECK:STDOUT: %Echo.ref: Echo = name_ref Echo, file.%Echo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc12_21: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Echo.call: init i32 = call %Echo.ref(%.loc12_21)
// CHECK:STDOUT: assign %b.var, %Echo.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
+24 -8
View File
@@ -15,11 +15,13 @@ fn Main() {
// CHECK:STDOUT: --- more_param_ir.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %struct.2: Foo = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.2: Main = struct_value () [template]
// CHECK:STDOUT: %struct.3: Main = struct_value () [template]
// CHECK:STDOUT: %.2: type = tuple_type (type) [template]
// CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
@@ -35,15 +37,26 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref.1: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32.loc7_11: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_11.1: type = value_of_initializer %int.make_type_32.loc7_11 [template = i32]
// CHECK:STDOUT: %.loc7_11.2: type = converted %int.make_type_32.loc7_11, %.loc7_11.1 [template = i32]
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %int.make_type_32.loc7_19: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_19.1: type = value_of_initializer %int.make_type_32.loc7_19 [template = i32]
// CHECK:STDOUT: %.loc7_19.2: type = converted %int.make_type_32.loc7_19, %.loc7_19.1 [template = i32]
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.3] {}
// CHECK:STDOUT: %import_ref.3: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -51,8 +64,11 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc10_15.1: (type,) = tuple_literal (i32)
// CHECK:STDOUT: %.loc10_15.2: type = converted %.loc10_15.1, constants.%.3 [template = constants.%.3]
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc10_15.1: (type,) = tuple_literal (%int.make_type_32)
// CHECK:STDOUT: %.loc10_15.2: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc10_15.3: type = converted %int.make_type_32, %.loc10_15.2 [template = i32]
// CHECK:STDOUT: %.loc10_15.4: type = converted %.loc10_15.1, constants.%.3 [template = constants.%.3]
// CHECK:STDOUT: %x.var: ref (i32,) = var x
// CHECK:STDOUT: %x: ref (i32,) = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_20: i32 = int_literal 1 [template = constants.%.4]
@@ -60,7 +76,7 @@ fn Main() {
// CHECK:STDOUT: %.loc10_22.2: init (i32,) = tuple_init (%.loc10_20) to %x.var [template = constants.%tuple]
// CHECK:STDOUT: %.loc10_23: init (i32,) = converted %.loc10_22.1, %.loc10_22.2 [template = constants.%tuple]
// CHECK:STDOUT: assign %x.var, %.loc10_23
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %x.ref: ref (i32,) = name_ref x, %x
// CHECK:STDOUT: %.loc12_9: i32 = int_literal 0 [template = constants.%.5]
// CHECK:STDOUT: %.loc12_10.1: ref i32 = tuple_index %x.ref, %.loc12_9
+14 -6
View File
@@ -13,11 +13,13 @@ fn Main() {
// CHECK:STDOUT: --- params_one.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %struct.2: Foo = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.2: Main = struct_value () [template]
// CHECK:STDOUT: %struct.3: Main = struct_value () [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -28,13 +30,19 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc7_11.2: type = converted %int.make_type_32, %.loc7_11.1 [template = i32]
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.3] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -42,7 +50,7 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc10: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Foo.call: init () = call %Foo.ref(%.loc10)
// CHECK:STDOUT: return
@@ -14,11 +14,13 @@ fn Main() {
// CHECK:STDOUT: --- params_one_comma.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %struct.2: Foo = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.2: Main = struct_value () [template]
// CHECK:STDOUT: %struct.3: Main = struct_value () [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -29,13 +31,19 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
// CHECK:STDOUT: %.loc7_11.2: type = converted %int.make_type_32, %.loc7_11.1 [template = i32]
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.3] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -43,10 +51,10 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref.loc10: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref.loc10: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc10: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Foo.call.loc10: init () = call %Foo.ref.loc10(%.loc10)
// CHECK:STDOUT: %Foo.ref.loc11: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref.loc11: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc11: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %Foo.call.loc11: init () = call %Foo.ref.loc11(%.loc11)
// CHECK:STDOUT: return
+18 -6
View File
@@ -13,11 +13,13 @@ fn Main() {
// CHECK:STDOUT: --- params_two.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %struct.2: Foo = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.2: Main = struct_value () [template]
// CHECK:STDOUT: %struct.3: Main = struct_value () [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
// CHECK:STDOUT: }
@@ -29,15 +31,25 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref.1: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32.loc7_11: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_11.1: type = value_of_initializer %int.make_type_32.loc7_11 [template = i32]
// CHECK:STDOUT: %.loc7_11.2: type = converted %int.make_type_32.loc7_11, %.loc7_11.1 [template = i32]
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %int.make_type_32.loc7_19: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_19.1: type = value_of_initializer %int.make_type_32.loc7_19 [template = i32]
// CHECK:STDOUT: %.loc7_19.2: type = converted %int.make_type_32.loc7_19, %.loc7_19.1 [template = i32]
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.3] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -45,7 +57,7 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 [template = constants.%.3]
// CHECK:STDOUT: %Foo.call: init () = call %Foo.ref(%.loc10_7, %.loc10_10)
@@ -14,11 +14,13 @@ fn Main() {
// CHECK:STDOUT: --- params_two_comma.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
// CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
// CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
// CHECK:STDOUT: %struct.2: Foo = struct_value () [template]
// CHECK:STDOUT: %Main: type = fn_type @Main [template]
// CHECK:STDOUT: %struct.2: Main = struct_value () [template]
// CHECK:STDOUT: %struct.3: Main = struct_value () [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
// CHECK:STDOUT: }
@@ -30,15 +32,25 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
// CHECK:STDOUT: %import_ref.1: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.2] {
// CHECK:STDOUT: %int.make_type_32.loc7_11: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_11.1: type = value_of_initializer %int.make_type_32.loc7_11 [template = i32]
// CHECK:STDOUT: %.loc7_11.2: type = converted %int.make_type_32.loc7_11, %.loc7_11.1 [template = i32]
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %int.make_type_32.loc7_19: init type = call constants.%struct.1() [template = i32]
// CHECK:STDOUT: %.loc7_19.1: type = value_of_initializer %int.make_type_32.loc7_19 [template = i32]
// CHECK:STDOUT: %.loc7_19.2: type = converted %int.make_type_32.loc7_19, %.loc7_19.1 [template = i32]
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
// CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.3] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
@@ -46,11 +58,11 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref.loc10: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref.loc10: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 [template = constants.%.3]
// CHECK:STDOUT: %Foo.call.loc10: init () = call %Foo.ref.loc10(%.loc10_7, %.loc10_10)
// CHECK:STDOUT: %Foo.ref.loc11: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
// CHECK:STDOUT: %Foo.ref.loc11: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.2]
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc11_10: i32 = int_literal 2 [template = constants.%.3]
// CHECK:STDOUT: %Foo.call.loc11: init () = call %Foo.ref.loc11(%.loc11_7, %.loc11_10)