| 1 |
! RUN: bbc -emit-hlfir -o - %s | FileCheck %s |
| 2 |
! test multiple return values with different types coming from ENTRY statements |
| 3 |
|
| 4 |
complex function f1() |
| 5 |
logical e1 |
| 6 |
entry e1() |
| 7 |
e1 = .false. |
| 8 |
end function |
| 9 |
! CHECK-LABEL: func.func @_QPf1() -> !fir.complex<4> { |
| 10 |
! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.complex<4> {bindc_name = "f1", uniq_name = "_QFf1Ef1"} |
| 11 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFf1Ef1"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>) |
| 12 |
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#1 : (!fir.ref<!fir.complex<4>>) -> !fir.ref<!fir.logical<4>> |
| 13 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFf1Ee1"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 14 |
! CHECK: cf.br ^bb1 |
| 15 |
! CHECK: ^bb1: |
| 16 |
! CHECK: %[[VAL_4:.*]] = arith.constant false |
| 17 |
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i1) -> !fir.logical<4> |
| 18 |
! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_3]]#0 : !fir.logical<4>, !fir.ref<!fir.logical<4>> |
| 19 |
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_1]]#1 : !fir.ref<!fir.complex<4>> |
| 20 |
! CHECK: return %[[VAL_6]] : !fir.complex<4> |
| 21 |
! CHECK: } |
| 22 |
|
| 23 |
! // CHECK-LABEL: func.func @_QPe1() -> !fir.logical<4> { |
| 24 |
! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.complex<4> {bindc_name = "f1", uniq_name = "_QFf1Ef1"} |
| 25 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFf1Ef1"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>) |
| 26 |
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#1 : (!fir.ref<!fir.complex<4>>) -> !fir.ref<!fir.logical<4>> |
| 27 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFf1Ee1"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 28 |
! CHECK: cf.br ^bb1 |
| 29 |
! CHECK: ^bb1: |
| 30 |
! CHECK: %[[VAL_4:.*]] = arith.constant false |
| 31 |
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i1) -> !fir.logical<4> |
| 32 |
! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_3]]#0 : !fir.logical<4>, !fir.ref<!fir.logical<4>> |
| 33 |
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_3]]#1 : !fir.ref<!fir.logical<4>> |
| 34 |
! CHECK: return %[[VAL_6]] : !fir.logical<4> |
| 35 |
! CHECK: } |
| 36 |
|
| 37 |
logical function f2() |
| 38 |
complex e2 |
| 39 |
entry e2() |
| 40 |
e2 = complex(1.0, 2.0) |
| 41 |
end function |
| 42 |
! CHECK-LABEL: func.func @_QPf2() -> !fir.logical<4> { |
| 43 |
! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.complex<4> {bindc_name = "e2", uniq_name = "_QFf2Ee2"} |
| 44 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFf2Ee2"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>) |
| 45 |
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#1 : (!fir.ref<!fir.complex<4>>) -> !fir.ref<!fir.logical<4>> |
| 46 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFf2Ef2"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 47 |
! CHECK: cf.br ^bb1 |
| 48 |
! CHECK: ^bb1: |
| 49 |
! CHECK: %[[VAL_4:.*]] = arith.constant 1.000000e+00 : f32 |
| 50 |
! CHECK: %[[VAL_5:.*]] = arith.constant 2.000000e+00 : f32 |
| 51 |
! CHECK: %[[VAL_6:.*]]:3 = hlfir.associate %[[VAL_4]] {adapt.valuebyref} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1) |
| 52 |
! CHECK: %[[VAL_7:.*]]:3 = hlfir.associate %[[VAL_5]] {adapt.valuebyref} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1) |
| 53 |
! CHECK: %[[VAL_8:.*]] = fir.call @_QPcomplex(%[[VAL_6]]#1, %[[VAL_7]]#1) fastmath<contract> : (!fir.ref<f32>, !fir.ref<f32>) -> f32 |
| 54 |
! CHECK: hlfir.end_associate %[[VAL_6]]#1, %[[VAL_6]]#2 : !fir.ref<f32>, i1 |
| 55 |
! CHECK: hlfir.end_associate %[[VAL_7]]#1, %[[VAL_7]]#2 : !fir.ref<f32>, i1 |
| 56 |
! CHECK: %[[VAL_9:.*]] = arith.constant 0.000000e+00 : f32 |
| 57 |
! CHECK: %[[VAL_10:.*]] = fir.undefined !fir.complex<4> |
| 58 |
! CHECK: %[[VAL_11:.*]] = fir.insert_value %[[VAL_10]], %[[VAL_8]], [0 : index] : (!fir.complex<4>, f32) -> !fir.complex<4> |
| 59 |
! CHECK: %[[VAL_12:.*]] = fir.insert_value %[[VAL_11]], %[[VAL_9]], [1 : index] : (!fir.complex<4>, f32) -> !fir.complex<4> |
| 60 |
! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_1]]#0 : !fir.complex<4>, !fir.ref<!fir.complex<4>> |
| 61 |
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_3]]#1 : !fir.ref<!fir.logical<4>> |
| 62 |
! CHECK: return %[[VAL_13]] : !fir.logical<4> |
| 63 |
! CHECK: } |
| 64 |
|
| 65 |
! CHECK-LABEL: func.func @_QPe2() -> !fir.complex<4> { |
| 66 |
! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.complex<4> {bindc_name = "e2", uniq_name = "_QFf2Ee2"} |
| 67 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFf2Ee2"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>) |
| 68 |
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#1 : (!fir.ref<!fir.complex<4>>) -> !fir.ref<!fir.logical<4>> |
| 69 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFf2Ef2"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 70 |
! CHECK: cf.br ^bb1 |
| 71 |
! CHECK: ^bb1: |
| 72 |
! CHECK: %[[VAL_4:.*]] = arith.constant 1.000000e+00 : f32 |
| 73 |
! CHECK: %[[VAL_5:.*]] = arith.constant 2.000000e+00 : f32 |
| 74 |
! CHECK: %[[VAL_6:.*]]:3 = hlfir.associate %[[VAL_4]] {adapt.valuebyref} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1) |
| 75 |
! CHECK: %[[VAL_7:.*]]:3 = hlfir.associate %[[VAL_5]] {adapt.valuebyref} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1) |
| 76 |
! CHECK: %[[VAL_8:.*]] = fir.call @_QPcomplex(%[[VAL_6]]#1, %[[VAL_7]]#1) fastmath<contract> : (!fir.ref<f32>, !fir.ref<f32>) -> f32 |
| 77 |
! CHECK: hlfir.end_associate %[[VAL_6]]#1, %[[VAL_6]]#2 : !fir.ref<f32>, i1 |
| 78 |
! CHECK: hlfir.end_associate %[[VAL_7]]#1, %[[VAL_7]]#2 : !fir.ref<f32>, i1 |
| 79 |
! CHECK: %[[VAL_9:.*]] = arith.constant 0.000000e+00 : f32 |
| 80 |
! CHECK: %[[VAL_10:.*]] = fir.undefined !fir.complex<4> |
| 81 |
! CHECK: %[[VAL_11:.*]] = fir.insert_value %[[VAL_10]], %[[VAL_8]], [0 : index] : (!fir.complex<4>, f32) -> !fir.complex<4> |
| 82 |
! CHECK: %[[VAL_12:.*]] = fir.insert_value %[[VAL_11]], %[[VAL_9]], [1 : index] : (!fir.complex<4>, f32) -> !fir.complex<4> |
| 83 |
! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_1]]#0 : !fir.complex<4>, !fir.ref<!fir.complex<4>> |
| 84 |
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_1]]#1 : !fir.ref<!fir.complex<4>> |
| 85 |
! CHECK: return %[[VAL_13]] : !fir.complex<4> |
| 86 |
! CHECK: } |