Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / Intrinsics / selected_int_kind.f90
blob2536e73055534cd5336289e5b16eb7c76a3ff757
1 ! REQUIRES: shell
2 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: func.func @_QPselected_int_kind_test1(
5 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i8> {fir.bindc_name = "a"}) {
6 ! CHECK: %[[VAL_1:.*]] = fir.alloca i8 {bindc_name = "res", uniq_name = "_QFselected_int_kind_test1Eres"}
7 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
8 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i8>) -> !fir.llvm_ptr<i8>
9 ! CHECK: %[[VAL_7:.*]] = fir.call @_FortranASelectedIntKind(%{{.*}}, %{{.*}}, %[[VAL_6]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
10 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> i8
11 ! CHECK: fir.store %[[VAL_8]] to %[[VAL_1]] : !fir.ref<i8>
12 ! CHECK: return
13 ! CHECK: }
15 subroutine selected_int_kind_test1(a)
16 integer(1) :: a, res
17 res = selected_int_kind(a)
18 end
20 ! CHECK-LABEL: func.func @_QPselected_int_kind_test2(
21 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i16> {fir.bindc_name = "a"}) {
22 ! CHECK: %[[VAL_1:.*]] = fir.alloca i16 {bindc_name = "res", uniq_name = "_QFselected_int_kind_test2Eres"}
23 ! CHECK: %[[VAL_4:.*]] = arith.constant 2 : i32
24 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i16>) -> !fir.llvm_ptr<i8>
25 ! CHECK: %[[VAL_7:.*]] = fir.call @_FortranASelectedIntKind(%{{.*}}, %{{.*}}, %[[VAL_6]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
26 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> i16
27 ! CHECK: fir.store %[[VAL_8]] to %[[VAL_1]] : !fir.ref<i16>
28 ! CHECK: return
29 ! CHECK: }
31 subroutine selected_int_kind_test2(a)
32 integer(2) :: a, res
33 res = selected_int_kind(a)
34 end
36 ! CHECK-LABEL: func.func @_QPselected_int_kind_test4(
37 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "a"}) {
38 ! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFselected_int_kind_test4Eres"}
39 ! CHECK: %[[VAL_4:.*]] = arith.constant 4 : i32
40 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
41 ! CHECK: %[[VAL_7:.*]] = fir.call @_FortranASelectedIntKind(%{{.*}}, %{{.*}}, %[[VAL_6]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
42 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<i32>
43 ! CHECK: return
44 ! CHECK: }
46 subroutine selected_int_kind_test4(a)
47 integer(4) :: a, res
48 res = selected_int_kind(a)
49 end
51 ! CHECK-LABEL: func.func @_QPselected_int_kind_test8(
52 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64> {fir.bindc_name = "a"}) {
53 ! CHECK: %[[VAL_1:.*]] = fir.alloca i64 {bindc_name = "res", uniq_name = "_QFselected_int_kind_test8Eres"}
54 ! CHECK: %[[VAL_4:.*]] = arith.constant 8 : i32
55 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i64>) -> !fir.llvm_ptr<i8>
56 ! CHECK: %[[VAL_7:.*]] = fir.call @_FortranASelectedIntKind(%{{.*}}, %{{.*}}, %[[VAL_6]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
57 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> i64
58 ! CHECK: fir.store %[[VAL_8]] to %[[VAL_1]] : !fir.ref<i64>
59 ! CHECK: return
60 ! CHECK: }
62 subroutine selected_int_kind_test8(a)
63 integer(8) :: a, res
64 res = selected_int_kind(a)
65 end
67 ! CHECK-LABEL: func.func @_QPselected_int_kind_test16(
68 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i128> {fir.bindc_name = "a"}) {
69 ! CHECK: %[[VAL_1:.*]] = fir.alloca i128 {bindc_name = "res", uniq_name = "_QFselected_int_kind_test16Eres"}
70 ! CHECK: %[[VAL_4:.*]] = arith.constant 16 : i32
71 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i128>) -> !fir.llvm_ptr<i8>
72 ! CHECK: %[[VAL_7:.*]] = fir.call @_FortranASelectedIntKind(%{{.*}}, %{{.*}}, %[[VAL_6]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
73 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> i128
74 ! CHECK: fir.store %[[VAL_8]] to %[[VAL_1]] : !fir.ref<i128>
75 ! CHECK: return
76 ! CHECK: }
78 subroutine selected_int_kind_test16(a)
79 integer(16) :: a, res
80 res = selected_int_kind(a)
81 end