2 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: func.func @_QPselected_real_kind_test1(
5 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i8> {fir.bindc_name = "p"},
6 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i8> {fir.bindc_name = "r"},
7 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i8> {fir.bindc_name = "d"}) {
8 ! CHECK: %[[VAL_3:.*]] = fir.alloca i8 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test1Eres"}
9 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i32
10 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : i32
11 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : i32
12 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i8>) -> !fir.llvm_ptr<i8>
13 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i8>) -> !fir.llvm_ptr<i8>
14 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<i8>) -> !fir.llvm_ptr<i8>
15 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
16 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i8
17 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i8>
21 subroutine selected_real_kind_test1(p
, r
, d
)
22 integer(1) :: p
, r
, d
, res
23 res
= selected_real_kind(P
=p
, R
=r
, RADIX
=d
)
26 ! CHECK-LABEL: func.func @_QPselected_real_kind_test2(
27 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i16> {fir.bindc_name = "p"},
28 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i16> {fir.bindc_name = "r"},
29 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i16> {fir.bindc_name = "d"}) {
30 ! CHECK: %[[VAL_3:.*]] = fir.alloca i16 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test2Eres"}
31 ! CHECK: %[[VAL_6:.*]] = arith.constant 2 : i32
32 ! CHECK: %[[VAL_7:.*]] = arith.constant 2 : i32
33 ! CHECK: %[[VAL_8:.*]] = arith.constant 2 : i32
34 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i16>) -> !fir.llvm_ptr<i8>
35 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i16>) -> !fir.llvm_ptr<i8>
36 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<i16>) -> !fir.llvm_ptr<i8>
37 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
38 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i16
39 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i16>
43 subroutine selected_real_kind_test2(p
, r
, d
)
44 integer(2) :: p
, r
, d
, res
45 res
= selected_real_kind(P
=p
, R
=r
, RADIX
=d
)
48 ! CHECK-LABEL: func.func @_QPselected_real_kind_test4(
49 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "p"},
50 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "r"},
51 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i32> {fir.bindc_name = "d"}) {
52 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test4Eres"}
53 ! CHECK: %[[VAL_6:.*]] = arith.constant 4 : i32
54 ! CHECK: %[[VAL_7:.*]] = arith.constant 4 : i32
55 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : i32
56 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
57 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
58 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
59 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
60 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_3]] : !fir.ref<i32>
64 subroutine selected_real_kind_test4(p
, r
, d
)
65 integer(4) :: p
, r
, d
, res
66 res
= selected_real_kind(P
=p
, R
=r
, RADIX
=d
)
69 ! CHECK-LABEL: func.func @_QPselected_real_kind_test8(
70 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64> {fir.bindc_name = "p"},
71 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i64> {fir.bindc_name = "r"},
72 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i64> {fir.bindc_name = "d"}) {
73 ! CHECK: %[[VAL_3:.*]] = fir.alloca i64 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test8Eres"}
74 ! CHECK: %[[VAL_6:.*]] = arith.constant 8 : i32
75 ! CHECK: %[[VAL_7:.*]] = arith.constant 8 : i32
76 ! CHECK: %[[VAL_8:.*]] = arith.constant 8 : i32
77 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i64>) -> !fir.llvm_ptr<i8>
78 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i64>) -> !fir.llvm_ptr<i8>
79 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<i64>) -> !fir.llvm_ptr<i8>
80 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
81 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
82 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i64>
86 subroutine selected_real_kind_test8(p
, r
, d
)
87 integer(8) :: p
, r
, d
, res
88 res
= selected_real_kind(P
=p
, R
=r
, RADIX
=d
)
91 ! CHECK-LABEL: func.func @_QPselected_real_kind_test16(
92 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i128> {fir.bindc_name = "p"},
93 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i128> {fir.bindc_name = "r"},
94 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i128> {fir.bindc_name = "d"}) {
95 ! CHECK: %[[VAL_3:.*]] = fir.alloca i128 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test16Eres"}
96 ! CHECK: %[[VAL_6:.*]] = arith.constant 16 : i32
97 ! CHECK: %[[VAL_7:.*]] = arith.constant 16 : i32
98 ! CHECK: %[[VAL_8:.*]] = arith.constant 16 : i32
99 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i128>) -> !fir.llvm_ptr<i8>
100 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i128>) -> !fir.llvm_ptr<i8>
101 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<i128>) -> !fir.llvm_ptr<i8>
102 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
103 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i128
104 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i128>
108 subroutine selected_real_kind_test16(p
, r
, d
)
109 integer(16) :: p
, r
, d
, res
110 res
= selected_real_kind(P
=p
, R
=r
, RADIX
=d
)
113 ! CHECK-LABEL: func.func @_QPselected_real_kind_test_rd(
114 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "r"},
115 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "d"}) {
116 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test_rdEres"}
117 ! CHECK: %[[VAL_3:.*]] = fir.absent !fir.ref<i1>
118 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
119 ! CHECK: %[[VAL_7:.*]] = arith.constant 4 : i32
120 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : i32
121 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i1>) -> !fir.llvm_ptr<i8>
122 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
123 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
124 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
125 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_2]] : !fir.ref<i32>
129 subroutine selected_real_kind_test_rd(r
, d
)
131 res
= selected_real_kind(R
=r
, RADIX
=d
)
134 ! CHECK-LABEL: func.func @_QPselected_real_kind_test_pd(
135 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "p"},
136 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "d"}) {
137 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test_pdEres"}
138 ! CHECK: %[[VAL_3:.*]] = fir.absent !fir.ref<i1>
139 ! CHECK: %[[VAL_6:.*]] = arith.constant 4 : i32
140 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : i32
141 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : i32
142 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
143 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i1>) -> !fir.llvm_ptr<i8>
144 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
145 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
146 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_2]] : !fir.ref<i32>
150 subroutine selected_real_kind_test_pd(p
, d
)
152 res
= selected_real_kind(P
=p
, RADIX
=d
)
155 ! CHECK-LABEL: func.func @_QPselected_real_kind_test_pr(
156 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "p"},
157 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "r"}) {
158 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFselected_real_kind_test_prEres"}
159 ! CHECK: %[[VAL_3:.*]] = fir.absent !fir.ref<i1>
160 ! CHECK: %[[VAL_6:.*]] = arith.constant 4 : i32
161 ! CHECK: %[[VAL_7:.*]] = arith.constant 4 : i32
162 ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : i32
163 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
164 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<i32>) -> !fir.llvm_ptr<i8>
165 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i1>) -> !fir.llvm_ptr<i8>
166 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranASelectedRealKind(%{{.*}}, %{{.*}}, %[[VAL_10]], %[[VAL_6]], %[[VAL_11]], %[[VAL_7]], %[[VAL_12]], %[[VAL_8]]) {{.*}}: (!fir.ref<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32, !fir.llvm_ptr<i8>, i32) -> i32
167 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_2]] : !fir.ref<i32>
171 subroutine selected_real_kind_test_pr(p
, r
)
173 res
= selected_real_kind(P
=p
, R
=r
)