| 1 |
! Test lowering of of expressions as fir.box |
| 2 |
! RUN: bbc -hlfir -o - %s 2>&1 --use-hlfir-intrinsic-ops=false | FileCheck %s |
| 3 |
|
| 4 |
! CHECK-LABEL: func.func @_QPfoo( |
| 5 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> |
| 6 |
subroutine foo(x) |
| 7 |
integer :: x(21:30) |
| 8 |
print *, x |
| 9 |
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 21 : index |
| 10 |
! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 10 : index |
| 11 |
! CHECK: %[[VAL_5:.*]] = fir.shape_shift %[[VAL_3]], %[[VAL_4]] : (index, index) -> !fir.shapeshift<1> |
| 12 |
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_5]]) dummy_scope %{{[0-9]+}} {uniq_name = "_QFfooEx"} : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.dscope) -> (!fir.box<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) |
| 13 |
! CHECK: fir.embox %[[VAL_6]]#1(%[[VAL_5]]) : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<10xi32>> |
| 14 |
end subroutine |
| 15 |
|
| 16 |
subroutine test_place_in_memory_and_embox() |
| 17 |
logical(8) :: a, b |
| 18 |
write(06), a.and.b |
| 19 |
end subroutine |
| 20 |
! CHECK-LABEL: func.func @_QPtest_place_in_memory_and_embox( |
| 21 |
! CHECK: %[[TEMP:.*]] = fir.alloca !fir.logical<8> |
| 22 |
! CHECK: %[[AND:.*]] = arith.andi {{.*}} |
| 23 |
! CHECK: %[[CAST:.*]] = fir.convert %[[AND]] : (i1) -> !fir.logical<8> |
| 24 |
! CHECK: fir.store %[[CAST]] to %[[TEMP]] : !fir.ref<!fir.logical<8>> |
| 25 |
! CHECK: %[[BOX:.*]] = fir.embox %[[TEMP]] : (!fir.ref<!fir.logical<8>>) -> !fir.box<!fir.logical<8>> |
| 26 |
! CHECK: %[[BOX_CAST:.*]] = fir.convert %[[BOX]] : (!fir.box<!fir.logical<8>>) -> !fir.box<none> |
| 27 |
! CHECK: fir.call @_FortranAioOutputDescriptor(%{{.*}}, %[[BOX_CAST]]) |
| 28 |
|
| 29 |
! check we can box a trivial value |
| 30 |
subroutine productMask(s, a) |
| 31 |
integer :: s |
| 32 |
integer :: a(:) |
| 33 |
s = product(a, mask=.true.) |
| 34 |
endsubroutine |
| 35 |
! CHECK-LABEL: func.func @_QPproductmask( |
| 36 |
! CHECK: %[[TRUE:.*]] = arith.constant true |
| 37 |
! CHECK: %[[ALLOC:.*]] = fir.alloca !fir.logical<4> |
| 38 |
! CHECK: %[[TRUE_L4:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4> |
| 39 |
! CHECK-NEXT: fir.store %[[TRUE_L4]] to %[[ALLOC]] |
| 40 |
! CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[ALLOC]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>> |