1 // PowerPC supports VLAs.
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host-ppc.bc
3 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-ppc.bc -o %t-ppc-device.ll
5 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host-ppc.bc
6 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-ppc.bc -o %t-ppc-device.ll
8 // Nvidia GPUs don't support VLAs.
9 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvptx.bc
10 // RUN: %clang_cc1 -verify -DNO_VLA -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvptx.bc -o %t-nvptx-device.ll
12 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvptx.bc
15 // expected-no-diagnostics
18 #pragma omp declare target
19 void declare(int arg) {
22 // expected-error@+2 {{variable length arrays are not supported for the current target}}
27 void declare_parallel_reduction(int arg) {
30 #pragma omp parallel reduction(+: a)
33 #pragma omp parallel reduction(+: a[0:2])
37 // expected-error@+3 {{cannot generate code for reduction on array section, which requires a variable length array}}
38 // expected-note@+2 {{variable length arrays are not supported for the current target}}
40 #pragma omp parallel reduction(+: a[0:arg])
43 #pragma omp end declare target
46 void target_template(int arg) {
50 // expected-error@+2 {{variable length arrays are not supported for the current target}}
56 void target(int arg) {
60 // expected-error@+2 {{variable length arrays are not supported for the current target}}
70 // expected-error@+2 {{variable length arrays are not supported for the current target}}
76 target_template<long>(arg);
79 void teams_reduction(int arg) {
83 #pragma omp target map(a)
84 #pragma omp teams reduction(+: a)
88 // expected-error@+4 {{cannot generate code for reduction on variable length array}}
89 // expected-note@+3 {{variable length arrays are not supported for the current target}}
91 #pragma omp target map(vla)
92 #pragma omp teams reduction(+: vla)
95 #pragma omp target map(a[0:2])
96 #pragma omp teams reduction(+: a[0:2])
99 #pragma omp target map(vla[0:2])
100 #pragma omp teams reduction(+: vla[0:2])
104 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
105 // expected-note@+3 {{variable length arrays are not supported for the current target}}
107 #pragma omp target map(a[0:arg])
108 #pragma omp teams reduction(+: a[0:arg])
112 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
113 // expected-note@+3 {{variable length arrays are not supported for the current target}}
115 #pragma omp target map(vla[0:arg])
116 #pragma omp teams reduction(+: vla[0:arg])
120 void parallel_reduction(int arg) {
124 #pragma omp target map(a)
125 #pragma omp parallel reduction(+: a)
129 // expected-error@+4 {{cannot generate code for reduction on variable length array}}
130 // expected-note@+3 {{variable length arrays are not supported for the current target}}
132 #pragma omp target map(vla)
133 #pragma omp parallel reduction(+: vla)
136 #pragma omp target map(a[0:2])
137 #pragma omp parallel reduction(+: a[0:2])
140 #pragma omp target map(vla[0:2])
141 #pragma omp parallel reduction(+: vla[0:2])
145 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
146 // expected-note@+3 {{variable length arrays are not supported for the current target}}
148 #pragma omp target map(a[0:arg])
149 #pragma omp parallel reduction(+: a[0:arg])
153 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
154 // expected-note@+3 {{variable length arrays are not supported for the current target}}
156 #pragma omp target map(vla[0:arg])
157 #pragma omp parallel reduction(+: vla[0:arg])
161 void for_reduction(int arg) {
165 #pragma omp target map(a)
167 #pragma omp for reduction(+: a)
168 for (int i = 0; i < arg; i++) ;
171 // expected-error@+5 {{cannot generate code for reduction on variable length array}}
172 // expected-note@+4 {{variable length arrays are not supported for the current target}}
174 #pragma omp target map(vla)
176 #pragma omp for reduction(+: vla)
177 for (int i = 0; i < arg; i++) ;
179 #pragma omp target map(a[0:2])
181 #pragma omp for reduction(+: a[0:2])
182 for (int i = 0; i < arg; i++) ;
184 #pragma omp target map(vla[0:2])
186 #pragma omp for reduction(+: vla[0:2])
187 for (int i = 0; i < arg; i++) ;
190 // expected-error@+5 {{cannot generate code for reduction on array section, which requires a variable length array}}
191 // expected-note@+4 {{variable length arrays are not supported for the current target}}
193 #pragma omp target map(a[0:arg])
195 #pragma omp for reduction(+: a[0:arg])
196 for (int i = 0; i < arg; i++) ;
199 // expected-error@+5 {{cannot generate code for reduction on array section, which requires a variable length array}}
200 // expected-note@+4 {{variable length arrays are not supported for the current target}}
202 #pragma omp target map(vla[0:arg])
204 #pragma omp for reduction(+: vla[0:arg])
205 for (int i = 0; i < arg; i++) ;