brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · 69abf05 Raw
101 lines · plain
1! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s2 3! Test assumed shape dummy argument on callee side4 5! TODO: These tests rely on looking at how a new fir.box is made for an assumed shape6! to see if lowering lowered and mapped the assumed shape symbol properties.7! However, the argument fir.box of the assumed shape could also be used instead8! of making a new fir.box and this would break all these tests. In fact, for non9! contiguous arrays, this is the case. Find a better way to tests symbol lowering/mapping.10 11! CHECK-LABEL: func @_QPtest_assumed_shape_1(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "x", fir.contiguous})12subroutine test_assumed_shape_1(x)13  integer, contiguous :: x(:)14  ! CHECK: %[[addr:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>15  ! CHECK: %[[c0:.*]] = arith.constant 0 : index16  ! CHECK: %[[dims:.*]]:3 = fir.box_dims %arg0, %[[c0]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)17  ! CHECK: %[[c1:.*]] = arith.constant 1 : index18 19  print *, x20  ! Test extent/lower bound use in the IO statement21  ! CHECK: %[[cookie:.*]] = fir.call @_FortranAioBeginExternalListOutput22  ! CHECK: %[[shape:.*]] = fir.shape_shift %[[c1]], %[[dims]]#1 : (index, index) -> !fir.shapeshift<1>23  ! CHECK: %[[newbox:.*]] = fir.embox %[[addr]](%[[shape]]) : (!fir.ref<!fir.array<?xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<?xi32>>24  ! CHECK: %[[castedBox:.*]] = fir.convert %[[newbox]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>25  ! CHECK: fir.call @_FortranAioOutputDescriptor(%[[cookie]], %[[castedBox]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i126end subroutine27 28! lower bounds all ones29! CHECK-LABEL:  func @_QPtest_assumed_shape_2(%arg0: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "x", fir.contiguous})30subroutine test_assumed_shape_2(x)31  real, contiguous :: x(1:, 1:)32  ! CHECK: fir.box_addr33  ! CHECK: %[[dims1:.*]]:3 = fir.box_dims34  ! CHECK: %[[dims2:.*]]:3 = fir.box_dims35  print *, x36  ! CHECK: fir.call @_FortranAioBeginExternalListOutput37  ! CHECK: fir.shape %[[dims1]]#1, %[[dims2]]#138end subroutine39 40! explicit lower bounds different from 141! CHECK-LABEL: func @_QPtest_assumed_shape_3(%arg0: !fir.box<!fir.array<?x?x?xi32>> {fir.bindc_name = "x", fir.contiguous})42subroutine test_assumed_shape_3(x)43  integer, contiguous :: x(2:, 3:, 42:)44  ! CHECK: fir.box_addr45  ! CHECK: fir.box_dim46  ! CHECK: %[[c2_i64:.*]] = arith.constant 2 : i6447  ! CHECK: %[[c2:.*]] = fir.convert %[[c2_i64]] : (i64) -> index48  ! CHECK: fir.box_dim49  ! CHECK: %[[c3_i64:.*]] = arith.constant 3 : i6450  ! CHECK: %[[c3:.*]] = fir.convert %[[c3_i64]] : (i64) -> index51  ! CHECK: fir.box_dim52  ! CHECK: %[[c42_i64:.*]] = arith.constant 42 : i6453  ! CHECK: %[[c42:.*]] = fir.convert %[[c42_i64]] : (i64) -> index54 55  print *, x56  ! CHECK: fir.shape_shift %[[c2]], %{{.*}}, %[[c3]], %{{.*}}, %[[c42]], %{{.*}} :57end subroutine58 59! Constant length60! func @_QPtest_assumed_shape_char(%arg0: !fir.box<!fir.array<?x!fir.char<1,10>>> {fir.bindc_name = "c", fir.contiguous})61subroutine test_assumed_shape_char(c)62  character(10), contiguous :: c(:)63  ! CHECK: %[[addr:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?x!fir.char<1,10>>>) -> !fir.ref<!fir.array<?x!fir.char<1,10>>>64 65  ! CHECK: %[[dims:.*]]:3 = fir.box_dims %arg0, %c0 : (!fir.box<!fir.array<?x!fir.char<1,10>>>, index) -> (index, index, index)66  ! CHECK: %[[c1:.*]] = arith.constant 1 : index67 68  print *, c69  ! CHECK: %[[shape:.*]] = fir.shape_shift %[[c1]], %[[dims]]#1 : (index, index) -> !fir.shapeshift<1>70  ! CHECK: fir.embox %[[addr]](%[[shape]]) : (!fir.ref<!fir.array<?x!fir.char<1,10>>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<?x!fir.char<1,10>>>71end subroutine72 73! Assumed length74! CHECK-LABEL: func @_QPtest_assumed_shape_char_2(%arg0: !fir.box<!fir.array<?x!fir.char<1,?>>> {fir.bindc_name = "c", fir.contiguous})75subroutine test_assumed_shape_char_2(c)76  character(*), contiguous :: c(:)77  ! CHECK: %[[addr:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>78  ! CHECK: %[[len:.*]] = fir.box_elesize %arg0 : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index79 80  ! CHECK: %[[dims:.*]]:3 = fir.box_dims %arg0, %c0 : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index) -> (index, index, index)81  ! CHECK: %[[c1:.*]] = arith.constant 1 : index82 83  print *, c84  ! CHECK: %[[shape:.*]] = fir.shape_shift %[[c1]], %[[dims]]#1 : (index, index) -> !fir.shapeshift<1>85  ! CHECK: fir.embox %[[addr]](%[[shape]]) typeparams %[[len]] : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shapeshift<1>, index) -> !fir.box<!fir.array<?x!fir.char<1,?>>>86end subroutine87 88 89! lower bounds all 1.90! CHECK: func @_QPtest_assumed_shape_char_3(%arg0: !fir.box<!fir.array<?x?x!fir.char<1,?>>> {fir.bindc_name = "c", fir.contiguous})91subroutine test_assumed_shape_char_3(c)92  character(*), contiguous :: c(1:, 1:)93  ! CHECK: fir.box_addr94  ! CHECK: fir.box_elesize95  ! CHECK: %[[dims1:.*]]:3 = fir.box_dims96  ! CHECK: %[[dims2:.*]]:3 = fir.box_dims97  print *, c98  ! CHECK: fir.call @_FortranAioBeginExternalListOutput99  ! CHECK: fir.shape %[[dims1]]#1, %[[dims2]]#1100end subroutine101