1 ! Test lowering of elemental subroutine calls with array arguments
2 ! RUN: bbc -o - -emit-fir %s | FileCheck %s
4 ! CHECK-LABEL: func @_QPtest_elem_sub(
5 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<!fir.complex<4>>{{.*}}) {
6 ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index
7 ! CHECK: %[[VAL_6:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_5]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
8 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : i64
9 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
10 ! CHECK: %[[VAL_9:.*]] = arith.constant -1 : i64
11 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
12 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : i64
13 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
14 ! CHECK: %[[VAL_13:.*]] = fir.slice %[[VAL_8]], %[[VAL_12]], %[[VAL_10]] : (index, index, index) -> !fir.slice<1>
15 ! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.complex<4>>
16 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
17 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
18 ! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_6]]#1, %[[VAL_15]] : index
19 ! CHECK: fir.do_loop %[[VAL_18:.*]] = %[[VAL_16]] to %[[VAL_17]] step %[[VAL_15]] {
20 ! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
21 ! CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_18]], %[[VAL_19]] : index
22 ! CHECK: %[[VAL_21:.*]] = fir.array_coor %[[VAL_0]] %[[VAL_20]] : (!fir.box<!fir.array<?xf32>>, index) -> !fir.ref<f32>
23 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : index
24 ! CHECK: %[[VAL_23:.*]] = arith.addi %[[VAL_18]], %[[VAL_22]] : index
25 ! CHECK: %[[VAL_24:.*]] = fir.array_coor %[[VAL_1]] {{\[}}%[[VAL_13]]] %[[VAL_23]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,?>>
26 ! CHECK: %[[VAL_25:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
27 ! CHECK: %[[VAL_26:.*]] = fir.emboxchar %[[VAL_24]], %[[VAL_25]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
28 ! CHECK: fir.call @_QPfoo(%[[VAL_21]], %[[VAL_26]], %[[VAL_2]], %[[VAL_14]]) {{.*}}: (!fir.ref<f32>, !fir.boxchar<1>, !fir.ref<i32>, !fir.complex<4>) -> ()
33 subroutine test_elem_sub(x
, c
, i
, z
)
39 elemental
subroutine foo(x
, c
, i
, z
)
40 real, intent(out
) :: x
41 character(*), intent(inout
) :: c
42 integer, intent(in
) :: i
47 call foo(x
, c(10:1:-1), i
, z
)
50 ! CHECK-LABEL: func @_QPtest_elem_sub_no_array_args(
51 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}) {
52 subroutine test_elem_sub_no_array_args(i
, j
)
55 elemental
subroutine bar(i
, j
)
56 integer, intent(out
) :: i
57 integer, intent(in
) :: j
61 ! CHECK: fir.call @_QPbar(%[[VAL_0]], %[[VAL_1]]) {{.*}}: (!fir.ref<i32>, !fir.ref<i32>) -> ()