33 lines · plain
1! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s2 3! Test lowering of CUDA pointers.4 5module mod16 7integer, device, pointer :: x(:)8 9contains10 11subroutine allocate_pointer12 real, device, pointer :: pr(:)13 allocate(pr(10))14end 15 16! CHECK-LABEL: func.func @_QMmod1Pallocate_pointer()17! CHECK-COUNT-2: fir.embox %{{.*}} {allocator_idx = 2 : i32} : (!fir.ptr<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>18 19subroutine c_f_pointer_sync20 use iso_c_binding21 use, intrinsic :: __fortran_builtins, only: c_devptr => __builtin_c_devptr22 type(c_devptr) :: cd123 integer, parameter :: N = 200024 call c_f_pointer(cd1, x, (/ 2000 /))25end 26 27! CHECK-LABEL: func.func @_QMmod1Pc_f_pointer_sync()28! CHECK: %[[ADDR_X:.*]] = fir.address_of(@_QMmod1Ex) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>29! CHECK: %[[CONV:.*]] = fir.convert %[[ADDR_X]] : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> !fir.llvm_ptr<i8>30! CHECK: fir.call @_FortranACUFSyncGlobalDescriptor(%[[CONV]], %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.llvm_ptr<i8>, !fir.ref<i8>, i32) -> ()31 32end module33