Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenACC / acc-exit-data.f90
blob5bae065bf1ea62bac63360c2076bc5477eedfac7
1 ! This test checks lowering of OpenACC exit data directive.
3 ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
5 subroutine acc_exit_data
6 integer :: async = 1
7 real, dimension(10, 10) :: a, b, c
8 real, pointer :: d
9 logical :: ifCondition = .TRUE.
11 !CHECK: [[A:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ea"}
12 !CHECK: [[B:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Eb"}
13 !CHECK: [[C:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ec"}
14 !CHECK: [[D:%.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "d", uniq_name = "{{.*}}Ed"}
16 !$acc exit data delete(a)
17 !CHECK: acc.exit_data delete([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
19 !$acc exit data delete(a) if(.true.)
20 !CHECK: [[IF1:%.*]] = arith.constant true
21 !CHECK: acc.exit_data if([[IF1]]) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
23 !$acc exit data delete(a) if(ifCondition)
24 !CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
25 !CHECK: [[IF2:%.*]] = fir.convert [[IFCOND]] : (!fir.logical<4>) -> i1
26 !CHECK: acc.exit_data if([[IF2]]) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
28 !$acc exit data delete(a) delete(b) delete(c)
29 !CHECK: acc.exit_data delete([[A]], [[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>){{$}}
31 !$acc exit data copyout(a) delete(b) detach(d)
32 !CHECK: acc.exit_data copyout([[A]] : !fir.ref<!fir.array<10x10xf32>>) delete([[B]] : !fir.ref<!fir.array<10x10xf32>>) detach([[D]] : !fir.ref<!fir.box<!fir.ptr<f32>>>){{$}}
34 !$acc exit data delete(a) async
35 !CHECK: acc.exit_data delete([[A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {async}
37 !$acc exit data delete(a) wait
38 !CHECK: acc.exit_data delete([[A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {wait}
40 !$acc exit data delete(a) async wait
41 !CHECK: acc.exit_data delete([[A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {async, wait}
43 !$acc exit data delete(a) async(1)
44 !CHECK: [[ASYNC1:%.*]] = arith.constant 1 : i32
45 !CHECK: acc.exit_data async([[ASYNC1]] : i32) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>)
47 !$acc exit data delete(a) async(async)
48 !CHECK: [[ASYNC2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
49 !CHECK: acc.exit_data async([[ASYNC2]] : i32) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>)
51 !$acc exit data delete(a) wait(1)
52 !CHECK: [[WAIT1:%.*]] = arith.constant 1 : i32
53 !CHECK: acc.exit_data wait([[WAIT1]] : i32) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>)
55 !$acc exit data delete(a) wait(queues: 1, 2)
56 !CHECK: [[WAIT2:%.*]] = arith.constant 1 : i32
57 !CHECK: [[WAIT3:%.*]] = arith.constant 2 : i32
58 !CHECK: acc.exit_data wait([[WAIT2]], [[WAIT3]] : i32, i32) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>)
60 !$acc exit data delete(a) wait(devnum: 1: queues: 1, 2)
61 !CHECK: [[WAIT4:%.*]] = arith.constant 1 : i32
62 !CHECK: [[WAIT5:%.*]] = arith.constant 2 : i32
63 !CHECK: [[WAIT6:%.*]] = arith.constant 1 : i32
64 !CHECK: acc.exit_data wait_devnum([[WAIT6]] : i32) wait([[WAIT4]], [[WAIT5]] : i32, i32) delete([[A]] : !fir.ref<!fir.array<10x10xf32>>)
66 end subroutine acc_exit_data