| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
- // Exceptions. See /LICENSE for license information.
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- //
- // AUTOUPDATE
- // TIP: To test this file alone, run:
- // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/call/more_param_ir.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/more_param_ir.carbon
- fn Foo(a: i32, b: i32) {}
- fn Main() {
- var x: (i32,) = (1,);
- // Generates multiple IR instructions for the first parameter.
- Foo(x.0, 6);
- }
- // CHECK:STDOUT: --- more_param_ir.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
- // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
- // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
- // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
- // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
- // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
- // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
- // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template]
- // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
- // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
- // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
- // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
- // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
- // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
- // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
- // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
- // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
- // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
- // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
- // CHECK:STDOUT: %Convert.specific_fn.70c: <specific function> = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template]
- // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
- // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_1.5d2) [template]
- // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
- // CHECK:STDOUT: %int_6.462: Core.IntLiteral = int_value 6 [template]
- // CHECK:STDOUT: %Convert.bound.ce9: <bound method> = bound_method %int_6.462, %Convert.956 [template]
- // CHECK:STDOUT: %Convert.specific_fn.631: <specific function> = specific_function %Convert.bound.ce9, @Convert.2(%int_32) [template]
- // CHECK:STDOUT: %int_6.e56: %i32 = int_value 6 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int = %Core.Int
- // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/...
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .Foo = %Foo.decl
- // CHECK:STDOUT: .Main = %Main.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
- // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
- // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
- // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
- // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
- // CHECK:STDOUT: %.loc11_11: type = splice_block %i32.loc11_11 [template = constants.%i32] {
- // CHECK:STDOUT: %int_32.loc11_11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
- // CHECK:STDOUT: %i32.loc11_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
- // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
- // CHECK:STDOUT: %.loc11_19: type = splice_block %i32.loc11_19 [template = constants.%i32] {
- // CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
- // CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Foo(%a.param_patt: %i32, %b.param_patt: %i32) {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Main() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: name_binding_decl {
- // CHECK:STDOUT: %x.patt: %tuple.type.a1c = binding_pattern x
- // CHECK:STDOUT: %.loc14_3.1: %tuple.type.a1c = var_pattern %x.patt
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %x.var: ref %tuple.type.a1c = var x
- // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
- // CHECK:STDOUT: %.loc14_22.1: %tuple.type.985 = tuple_literal (%int_1)
- // CHECK:STDOUT: %impl.elem0.loc14: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
- // CHECK:STDOUT: %bound_method.loc14: <bound method> = bound_method %int_1, %impl.elem0.loc14 [template = constants.%Convert.bound.ab5]
- // CHECK:STDOUT: %specific_fn.loc14: <specific function> = specific_function %bound_method.loc14, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c]
- // CHECK:STDOUT: %int.convert_checked.loc14: init %i32 = call %specific_fn.loc14(%int_1) [template = constants.%int_1.5d2]
- // CHECK:STDOUT: %.loc14_22.2: init %i32 = converted %int_1, %int.convert_checked.loc14 [template = constants.%int_1.5d2]
- // CHECK:STDOUT: %.loc14_22.3: init %tuple.type.a1c = tuple_init (%.loc14_22.2) to %x.var [template = constants.%tuple]
- // CHECK:STDOUT: %.loc14_3.2: init %tuple.type.a1c = converted %.loc14_22.1, %.loc14_22.3 [template = constants.%tuple]
- // CHECK:STDOUT: assign %x.var, %.loc14_3.2
- // CHECK:STDOUT: %.loc14_15.1: type = splice_block %.loc14_15.3 [template = constants.%tuple.type.a1c] {
- // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
- // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
- // CHECK:STDOUT: %.loc14_15.2: %tuple.type.85c = tuple_literal (%i32)
- // CHECK:STDOUT: %.loc14_15.3: type = converted %.loc14_15.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %x: ref %tuple.type.a1c = bind_name x, %x.var
- // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
- // CHECK:STDOUT: %x.ref: ref %tuple.type.a1c = name_ref x, %x
- // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
- // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %x.ref, element0
- // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [template = constants.%int_6.462]
- // CHECK:STDOUT: %.loc16_8: %i32 = bind_value %tuple.elem0
- // CHECK:STDOUT: %impl.elem0.loc16: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
- // CHECK:STDOUT: %bound_method.loc16: <bound method> = bound_method %int_6, %impl.elem0.loc16 [template = constants.%Convert.bound.ce9]
- // CHECK:STDOUT: %specific_fn.loc16: <specific function> = specific_function %bound_method.loc16, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.631]
- // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %specific_fn.loc16(%int_6) [template = constants.%int_6.e56]
- // CHECK:STDOUT: %.loc16_12.1: %i32 = value_of_initializer %int.convert_checked.loc16 [template = constants.%int_6.e56]
- // CHECK:STDOUT: %.loc16_12.2: %i32 = converted %int_6, %.loc16_12.1 [template = constants.%int_6.e56]
- // CHECK:STDOUT: %Foo.call: init %empty_tuple.type = call %Foo.ref(%.loc16_8, %.loc16_12.2)
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|