| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- // 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/builtins/int/xor.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/xor.carbon
- // --- int_xor.carbon
- fn Xor(a: i32, b: i32) -> i32 = "int.xor";
- var arr: [i32; Xor(12, 10)];
- let arr_p: [i32; 6]* = &arr;
- fn RuntimeCall(a: i32, b: i32) -> i32 {
- return Xor(a, b);
- }
- // CHECK:STDOUT: --- int_xor.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
- // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
- // CHECK:STDOUT: %Xor.type: type = fn_type @Xor [template]
- // CHECK:STDOUT: %Xor: %Xor.type = struct_value () [template]
- // CHECK:STDOUT: %.1: i32 = int_value 12 [template]
- // CHECK:STDOUT: %.2: i32 = int_value 10 [template]
- // CHECK:STDOUT: %.3: i32 = int_value 6 [template]
- // CHECK:STDOUT: %.4: type = array_type %.3, i32 [template]
- // CHECK:STDOUT: %.5: type = ptr_type %.4 [template]
- // CHECK:STDOUT: %RuntimeCall.type: type = fn_type @RuntimeCall [template]
- // CHECK:STDOUT: %RuntimeCall: %RuntimeCall.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref
- // 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: .Xor = %Xor.decl
- // CHECK:STDOUT: .arr = %arr
- // CHECK:STDOUT: .arr_p = @__global_init.%arr_p
- // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %Xor.decl: %Xor.type = fn_decl @Xor [template = constants.%Xor] {
- // 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: %return.patt: i32 = return_slot_pattern
- // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param2
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32]
- // CHECK:STDOUT: %.loc2_11.2: type = converted %int.make_type_32.loc2_11, %.loc2_11.1 [template = i32]
- // CHECK:STDOUT: %int.make_type_32.loc2_19: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc2_19.1: type = value_of_initializer %int.make_type_32.loc2_19 [template = i32]
- // CHECK:STDOUT: %.loc2_19.2: type = converted %int.make_type_32.loc2_19, %.loc2_19.1 [template = i32]
- // CHECK:STDOUT: %int.make_type_32.loc2_27: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc2_27.1: type = value_of_initializer %int.make_type_32.loc2_27 [template = i32]
- // CHECK:STDOUT: %.loc2_27.2: type = converted %int.make_type_32.loc2_27, %.loc2_27.1 [template = i32]
- // CHECK:STDOUT: %a.param: i32 = value_param runtime_param0
- // CHECK:STDOUT: %a: i32 = bind_name a, %a.param
- // CHECK:STDOUT: %b.param: i32 = value_param runtime_param1
- // CHECK:STDOUT: %b: i32 = bind_name b, %b.param
- // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param2
- // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %Xor.ref: %Xor.type = name_ref Xor, %Xor.decl [template = constants.%Xor]
- // CHECK:STDOUT: %.loc4_20: i32 = int_value 12 [template = constants.%.1]
- // CHECK:STDOUT: %.loc4_24: i32 = int_value 10 [template = constants.%.2]
- // CHECK:STDOUT: %int.xor: init i32 = call %Xor.ref(%.loc4_20, %.loc4_24) [template = constants.%.3]
- // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
- // CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_32.loc4, %.loc4_11.1 [template = i32]
- // CHECK:STDOUT: %.loc4_27: type = array_type %int.xor, i32 [template = constants.%.4]
- // CHECK:STDOUT: %arr.var: ref %.4 = var arr
- // CHECK:STDOUT: %arr: ref %.4 = bind_name arr, %arr.var
- // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc5_18: i32 = int_value 6 [template = constants.%.3]
- // CHECK:STDOUT: %.loc5_13.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
- // CHECK:STDOUT: %.loc5_13.2: type = converted %int.make_type_32.loc5, %.loc5_13.1 [template = i32]
- // CHECK:STDOUT: %.loc5_19: type = array_type %.loc5_18, i32 [template = constants.%.4]
- // CHECK:STDOUT: %.loc5_20: type = ptr_type %.4 [template = constants.%.5]
- // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [template = constants.%RuntimeCall] {
- // 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: %return.patt: i32 = return_slot_pattern
- // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param2
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %int.make_type_32.loc7_19: init type = call constants.%Int32() [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: %int.make_type_32.loc7_27: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc7_27.1: type = value_of_initializer %int.make_type_32.loc7_27 [template = i32]
- // CHECK:STDOUT: %.loc7_27.2: type = converted %int.make_type_32.loc7_27, %.loc7_27.1 [template = i32]
- // CHECK:STDOUT: %int.make_type_32.loc7_35: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc7_35.1: type = value_of_initializer %int.make_type_32.loc7_35 [template = i32]
- // CHECK:STDOUT: %.loc7_35.2: type = converted %int.make_type_32.loc7_35, %.loc7_35.1 [template = i32]
- // CHECK:STDOUT: %a.param: i32 = value_param runtime_param0
- // CHECK:STDOUT: %a: i32 = bind_name a, %a.param
- // CHECK:STDOUT: %b.param: i32 = value_param runtime_param1
- // CHECK:STDOUT: %b: i32 = bind_name b, %b.param
- // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param2
- // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Xor(%a.param_patt: i32, %b.param_patt: i32) -> i32 = "int.xor";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @RuntimeCall(%a.param_patt: i32, %b.param_patt: i32) -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %Xor.ref: %Xor.type = name_ref Xor, file.%Xor.decl [template = constants.%Xor]
- // CHECK:STDOUT: %a.ref: i32 = name_ref a, %a
- // CHECK:STDOUT: %b.ref: i32 = name_ref b, %b
- // CHECK:STDOUT: %int.xor: init i32 = call %Xor.ref(%a.ref, %b.ref)
- // CHECK:STDOUT: %.loc8_19.1: i32 = value_of_initializer %int.xor
- // CHECK:STDOUT: %.loc8_19.2: i32 = converted %int.xor, %.loc8_19.1
- // CHECK:STDOUT: return %.loc8_19.2
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @__global_init() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %arr.ref: ref %.4 = name_ref arr, file.%arr
- // CHECK:STDOUT: %.loc5: %.5 = addr_of %arr.ref
- // CHECK:STDOUT: %arr_p: %.5 = bind_name arr_p, %.loc5
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|