| 1 |
! Test lowering of intrinsic module procedures to HLFIR. This |
| 2 |
! test is not meant to test every intrinsic module procedure, |
| 3 |
! it only tests that the HFLIR procedure reference lowering |
| 4 |
! infrastructure properly detects and dispatches intrinsic module |
| 5 |
! procedure calls. |
| 6 |
! RUN: bbc -emit-hlfir -o - %s | FileCheck %s |
| 7 |
|
| 8 |
subroutine foo(cptr, x) |
| 9 |
use iso_c_binding, only : c_ptr, c_loc |
| 10 |
type(c_ptr) :: cptr |
| 11 |
integer, target :: x |
| 12 |
cptr = c_loc(x) |
| 13 |
end subroutine |
| 14 |
! CHECK-LABEL: func.func @_QPfoo( |
| 15 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare {{.*}}Ecptr" |
| 16 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare {{.*}}Ex" |
| 17 |
! CHECK: %[[VAL_4:.*]] = fir.embox %[[VAL_3]]#1 : (!fir.ref<i32>) -> !fir.box<i32> |
| 18 |
! CHECK: %[[VAL_5:.*]] = fir.alloca !fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}> |
| 19 |
! CHECK: %[[VAL_6:.*]] = fir.field_index __address, !fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}> |
| 20 |
! CHECK: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_6]] : (!fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, !fir.field) -> !fir.ref<i64> |
| 21 |
! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_4]] : (!fir.box<i32>) -> !fir.ref<i32> |
| 22 |
! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<i32>) -> i64 |
| 23 |
! CHECK: fir.store %[[VAL_9]] to %[[VAL_7]] : !fir.ref<i64> |
| 24 |
|
| 25 |
subroutine test_renaming(p) |
| 26 |
use iso_c_binding, only: c_associated_alias => c_associated, c_ptr |
| 27 |
type(c_ptr) p |
| 28 |
print *, c_associated_alias(p) |
| 29 |
end subroutine |
| 30 |
|
| 31 |
! CHECK-LABEL: func.func @_QPtest_renaming |
| 32 |
! CHECK: %[[C_PTR_TARG:.*]] = fir.load %{{.*}} : !fir.ref<i64> |
| 33 |
! CHECK: %[[NULL:.*]] = arith.constant 0 : i64 |
| 34 |
! CHECK: arith.cmpi ne, %[[C_PTR_TARG]], %[[NULL]] : i64 |