Debian Codegraph @

flang/test/Lower/HLFIR/ignore-type-assumed-shape.f90

raw
1 ! Test descriptor dummy argument preparation when the
2 ! dummy has IGNORE_TKR(t). The descriptor should be prepared
3 ! according to the actual argument type, but its bounds and
4 ! attributes should still be set as expected for the dummy.
5 ! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
6
7 module tkr_ifaces
8 interface
9 subroutine takes_assumed_shape_ignore_tkr_t(x) bind(c)
10 !dir$ ignore_tkr (t) x
11 integer :: x(:)
12 end subroutine
13 end interface
14 end module
15
16 subroutine test_ignore_t_1(x)
17 use tkr_ifaces
18 real :: x(10)
19 call takes_assumed_shape_ignore_tkr_t(x)
20 end subroutine
21 ! CHECK-LABEL: func.func @_QPtest_ignore_t_1(
22 ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index
23 ! CHECK: %[[VAL_6:.*]] = fir.shift %[[VAL_5]] : (index) -> !fir.shift<1>
24 ! CHECK: %[[VAL_7:.*]] = fir.rebox %{{.*}}(%[[VAL_6]]) : (!fir.box<!fir.array<10xf32>>, !fir.shift<1>) -> !fir.box<!fir.array<?xf32>>
25 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xi32>>
26 ! CHECK: fir.call @takes_assumed_shape_ignore_tkr_t(%[[VAL_8]]) fastmath<contract> {is_bind_c} : (!fir.box<!fir.array<?xi32>>) -> ()
27
28 subroutine test_ignore_t_2(x)
29 use tkr_ifaces
30 class(*) :: x(:)
31 call takes_assumed_shape_ignore_tkr_t(x)
32 end subroutine
33 ! CHECK-LABEL: func.func @_QPtest_ignore_t_2(
34 ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
35 ! CHECK: %[[VAL_3:.*]] = fir.shift %[[VAL_2]] : (index) -> !fir.shift<1>
36 ! CHECK: %[[VAL_4:.*]] = fir.rebox %{{.*}}(%[[VAL_3]]) : (!fir.class<!fir.array<?xnone>>, !fir.shift<1>) -> !fir.class<!fir.array<?xnone>>
37 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.class<!fir.array<?xnone>>) -> !fir.box<!fir.array<?xi32>>
38 ! CHECK: fir.call @takes_assumed_shape_ignore_tkr_t(%[[VAL_5]]) fastmath<contract> {is_bind_c} : (!fir.box<!fir.array<?xi32>>) -> ()
39
40 subroutine test_ignore_t_3(x)
41 use tkr_ifaces
42 real :: x(10)
43 call takes_assumed_shape_ignore_tkr_t(x+1.0)
44 end subroutine
45 ! CHECK-LABEL: func.func @_QPtest_ignore_t_3(
46 ! CHECK: %[[VAL_12:.*]] = arith.constant 0 : index
47 ! CHECK: %[[VAL_13:.*]] = fir.shift %[[VAL_12]] : (index) -> !fir.shift<1>
48 ! CHECK: %[[VAL_14:.*]] = fir.rebox %{{.*}}(%[[VAL_13]]) : (!fir.box<!fir.array<10xf32>>, !fir.shift<1>) -> !fir.box<!fir.array<?xf32>>
49 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xi32>>
50 ! CHECK: fir.call @takes_assumed_shape_ignore_tkr_t(%[[VAL_15]]) fastmath<contract> {is_bind_c} : (!fir.box<!fir.array<?xi32>>) -> ()
51
52 subroutine test_ignore_t_4(x)
53 use tkr_ifaces
54 real, pointer :: x(:)
55 call takes_assumed_shape_ignore_tkr_t(x)
56 end subroutine
57 ! CHECK-LABEL: func.func @_QPtest_ignore_t_4(
58 ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
59 ! CHECK: %[[VAL_4:.*]] = fir.shift %[[VAL_3]] : (index) -> !fir.shift<1>
60 ! CHECK: %[[VAL_5:.*]] = fir.rebox %{{.*}}(%[[VAL_4]]) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, !fir.shift<1>) -> !fir.box<!fir.array<?xf32>>
61 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xi32>>
62 ! CHECK: fir.call @takes_assumed_shape_ignore_tkr_t(%[[VAL_6]]) fastmath<contract> {is_bind_c} : (!fir.box<!fir.array<?xi32>>) -> ()