Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenACC / acc-data.f90
blob1716ac99629e4e68b2336882aceb40652eff5b3d
1 ! This test checks lowering of OpenACC data directive.
3 ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
5 subroutine acc_data
6 real, dimension(10, 10) :: a, b, c
7 real, pointer :: d, e
8 logical :: ifCondition = .TRUE.
10 !CHECK: [[A:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ea"}
11 !CHECK: [[B:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Eb"}
12 !CHECK: [[C:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ec"}
13 !CHECK: [[D:%.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "d", uniq_name = "{{.*}}Ed"}
14 !CHECK: [[E:%.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "e", uniq_name = "{{.*}}Ee"}
16 !$acc data if(.TRUE.) copy(a)
17 !$acc end data
19 !CHECK: [[IF1:%.*]] = arith.constant true
20 !CHECK: acc.data if([[IF1]]) copy([[A]] : !fir.ref<!fir.array<10x10xf32>>) {
21 !CHECK: acc.terminator
22 !CHECK-NEXT: }{{$}}
24 !$acc data copy(a) if(ifCondition)
25 !$acc end data
27 !CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
28 !CHECK: [[IF2:%.*]] = fir.convert [[IFCOND]] : (!fir.logical<4>) -> i1
29 !CHECK: acc.data if([[IF2]]) copy([[A]] : !fir.ref<!fir.array<10x10xf32>>) {
30 !CHECK: acc.terminator
31 !CHECK-NEXT: }{{$}}
33 !$acc data copy(a, b, c)
34 !$acc end data
36 !CHECK: acc.data copy([[A]], [[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) {
37 !CHECK: acc.terminator
38 !CHECK-NEXT: }{{$}}
40 !$acc data copy(a) copy(b) copy(c)
41 !$acc end data
43 !CHECK: acc.data copy([[A]], [[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) {
44 !CHECK: acc.terminator
45 !CHECK-NEXT: }{{$}}
47 !$acc data copyin(a) copyin(readonly: b, c)
48 !$acc end data
50 !CHECK: acc.data copyin([[A]] : !fir.ref<!fir.array<10x10xf32>>) copyin_readonly([[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) {
51 !CHECK: acc.terminator
52 !CHECK-NEXT: }{{$}}
54 !$acc data copyout(a) copyout(zero: b) copyout(c)
55 !$acc end data
57 !CHECK: acc.data copyout([[A]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) copyout_zero([[B]] : !fir.ref<!fir.array<10x10xf32>>) {
58 !CHECK: acc.terminator
59 !CHECK-NEXT: }{{$}}
61 !$acc data create(a, b) create(zero: c)
62 !$acc end data
64 !CHECK: acc.data create([[A]], [[B]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) create_zero([[C]] : !fir.ref<!fir.array<10x10xf32>>) {
65 !CHECK: acc.terminator
66 !CHECK-NEXT: }{{$}}
68 !$acc data no_create(a, b) create(zero: c)
69 !$acc end data
71 !CHECK: acc.data create_zero([[C]] : !fir.ref<!fir.array<10x10xf32>>) no_create([[A]], [[B]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) {
72 !CHECK: acc.terminator
73 !CHECK-NEXT: }{{$}}
75 !$acc data present(a, b, c)
76 !$acc end data
78 !CHECK: acc.data present([[A]], [[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) {
79 !CHECK: acc.terminator
80 !CHECK-NEXT: }{{$}}
82 !$acc data deviceptr(b, c)
83 !$acc end data
85 !CHECK: acc.data deviceptr([[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) {
86 !CHECK: acc.terminator
87 !CHECK-NEXT: }{{$}}
89 !$acc data attach(d, e)
90 !$acc end data
92 !CHECK: acc.data attach([[D]], [[E]] : !fir.ref<!fir.box<!fir.ptr<f32>>>, !fir.ref<!fir.box<!fir.ptr<f32>>>) {
93 !CHECK: acc.terminator
94 !CHECK-NEXT: }{{$}}
96 end subroutine acc_data