Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / HLFIR / expr-addr.f90
blob3c69cdf88b3836a5b5f97c079cd73e3d8544f3a5
1 ! Test lowering of of expressions as address
2 ! RUN: bbc -emit-fir -hlfir -o - %s 2>&1 | FileCheck %s
4 ! CHECK-LABEL: func.func @_QPfoo(
5 ! CHECK-SAME: %[[arg0:.*]]: !fir.ref<i32>
6 subroutine foo(x)
7 integer :: x
8 read (*,*) x
9 ! CHECK: %[[x:.]]:2 = hlfir.declare %[[arg0]] {uniq_name = "_QFfooEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
10 ! CHECK: %[[x_cast:.*]] = fir.convert %[[x]]#1 : (!fir.ref<i32>) -> !fir.ref<i64>
11 ! CHECK: fir.call @_FortranAioInputInteger(%{{.*}}, %[[x_cast]], %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i64>, i32) -> i1
12 end subroutine
14 subroutine expr_to_var(c)
15 character(*) :: c
16 print *, c//c
17 end subroutine
19 ! CHECK-LABEL: func.func @_QPexpr_to_var(
20 ! CHECK: %[[VAL_9:.*]] = hlfir.concat %{{.*}}, %{{.*}} len %[[VAL_8:.*]] : (!fir.boxchar<1>, !fir.boxchar<1>, index) -> !hlfir.expr<!fir.char<1,?>>
21 ! CHECK: %[[VAL_10:.*]]:3 = hlfir.associate %[[VAL_9]] typeparams %[[VAL_8]] {uniq_name = "adapt.valuebyref"} : (!hlfir.expr<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>, i1)
22 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
23 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_8]] : (index) -> i64
24 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAioOutputAscii(%{{.*}}, %[[VAL_11]], %[[VAL_12]]) {{.*}} : (!fir.ref<i8>, !fir.ref<i8>, i64) -> i1
25 ! CHECK: hlfir.end_associate %[[VAL_10]]#1, %[[VAL_10]]#2 : !fir.ref<!fir.char<1,?>>, i1