1 ! RUN: bbc -emit-fir -polymorphic-type %s -o - | FileCheck %s
9 type, extends(p1
) :: p2
15 ! CHECK-LABEL: func @_QMspread_modPspread_test(
16 ! CHECK-SAME: %[[arg0:[^:]+]]: !fir.ref<i32>{{.*}}, %[[arg1:[^:]+]]: !fir.ref<i32>{{.*}}, %[[arg2:[^:]+]]: !fir.ref<i32>{{.*}}, %[[arg3:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}) {
17 subroutine spread_test(s
,d
,n
,r
)
20 ! CHECK-DAG: %[[a0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
21 ! CHECK-DAG: %[[a1:.*]] = fir.load %[[arg1]] : !fir.ref<i32>
22 ! CHECK-DAG: %[[a2:.*]] = fir.load %[[arg2]] : !fir.ref<i32>
23 ! CHECK-DAG: %[[a3:.*]] = fir.embox %[[arg0]] : (!fir.ref<i32>) -> !fir.box<i32>
24 ! CHECK-DAG: %[[a8:.*]] = fir.convert %[[a0]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
25 ! CHECK-DAG: %[[a9:.*]] = fir.convert %[[a3]] : (!fir.box<i32>) -> !fir.box<none>
26 ! CHECK-DAG: %[[a10:.*]] = fir.convert %[[a2]] : (i32) -> i64
28 ! CHECK: %{{.*}} = fir.call @_FortranASpread(%[[a8]], %[[a9]], %[[a1]], %[[a10]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i64, !fir.ref<i8>, i32) -> none
29 ! CHECK-DAG: %[[a13:.*]] = fir.load %[[a0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
30 ! CHECK-DAG: %[[a15:.*]] = fir.box_addr %[[a13]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
31 ! CHECK: fir.freemem %[[a15]]
34 ! CHECK-LABEL: func @_QMspread_modPspread_test2(
35 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[arg1:[^:]+]]: !fir.ref<i32>{{.*}}, %[[arg2:[^:]+]]: !fir.ref<i32>{{.*}}, %[[arg3:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}) {
36 subroutine spread_test2(s
,d
,n
,r
)
39 ! CHECK-DAG: %[[a0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x?xi32>>>
40 ! CHECK-DAG: %[[a1:.*]] = fir.load %[[arg1]] : !fir.ref<i32>
41 ! CHECK-DAG: %[[a2:.*]] = fir.load %[[arg2]] : !fir.ref<i32>
42 ! CHECK-DAG: %[[a7:.*]] = fir.convert %[[a0]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>) -> !fir.ref<!fir.box<none>>
43 ! CHECK-DAG: %[[a8:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
44 ! CHECK-DAG: %[[a9:.*]] = fir.convert %[[a2]] : (i32) -> i64
46 ! CHECK: %{{.*}} = fir.call @_FortranASpread(%[[a7]], %[[a8]], %[[a1]], %[[a9]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i64, !fir.ref<i8>, i32) -> none
47 ! CHECK-DAG: %[[a12:.*]] = fir.load %[[a0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
48 ! CHECK-DAG: %[[a15:.*]] = fir.box_addr %[[a12]] : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>) -> !fir.heap<!fir.array<?x?xi32>>
49 ! CHECK: fir.freemem %[[a15:.*]]
52 ! CHECK-LABEL: func.func @_QMspread_modPspread_test_polymorphic_source(
53 ! CHECK-SAME: %[[arg0:.*]]: !fir.ref<!fir.class<!fir.ptr<!fir.array<?x?xnone>>>> {fir.bindc_name = "p"}) {
54 subroutine spread_test_polymorphic_source(p
)
55 class(*), pointer :: p(:,:)
56 class(*), allocatable
:: r(:,:,:)
57 r
= spread(p(:,::2), dim
=1, ncopies
=2)
58 ! CHECK: %[[res:.*]] = fir.alloca !fir.class<!fir.heap<!fir.array<?x?x?xnone>>>
59 ! CHECK: %[[load_p:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.class<!fir.ptr<!fir.array<?x?xnone>>>>
60 ! CHECK: %[[source_box:.*]] = fir.rebox %[[load_p]](%{{.*}}) [%{{.*}}] : (!fir.class<!fir.ptr<!fir.array<?x?xnone>>>, !fir.shift<2>, !fir.slice<2>) -> !fir.class<!fir.array<?x?xnone>>
61 ! CHECK: %[[embox:.*]] = fir.embox %{{.*}}(%{{.*}}) source_box %[[source_box]] : (!fir.heap<!fir.array<?x?x?xnone>>, !fir.shape<3>, !fir.class<!fir.array<?x?xnone>>) -> !fir.class<!fir.heap<!fir.array<?x?x?xnone>>>
62 ! CHECK: fir.store %[[embox]] to %[[res]] : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x?xnone>>>>
63 ! CHECK: %[[res_box_none:.*]] = fir.convert %[[res]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x?xnone>>>>) -> !fir.ref<!fir.box<none>>
64 ! CHECK: %[[source_box_none:.*]] = fir.convert %[[source_box]] : (!fir.class<!fir.array<?x?xnone>>) -> !fir.box<none>
65 ! CHECK: %{{.*}} = fir.call @_FortranASpread(%[[res_box_none]], %[[source_box_none]], %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i64, !fir.ref<i8>, i32) -> none