1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -DGPU
2 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DGPU | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
3 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -DGPU
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -DGPU | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
6 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -DNOHOST
7 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DNOHOST | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
8 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -DNOHOST
9 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -DNOHOST | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
11 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -DGPU
12 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DGPU | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
13 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -DGPU
14 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -DGPU | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
16 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -DNOHOST
17 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DNOHOST | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
18 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -DNOHOST
19 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -DNOHOST | FileCheck %s --implicit-check-not='ret i32 {{6|7|9|10|12|14|17|18|20|21|22|23|24|26}}'
20 // expected-no-diagnostics
22 // CHECK-DAG: ret i32 2
23 // CHECK-DAG: ret i32 3
24 // CHECK-DAG: ret i32 4
25 // CHECK-DAG: ret i32 5
26 // CHECK-DAG: ret i32 8
27 // CHECK-DAG: ret i32 11
28 // CHECK-DAG: ret i32 13
29 // CHECK-DAG: ret i32 15
30 // CHECK-DAG: ret i32 16
31 // CHECK-DAG: ret i32 19
32 // CHECK-DAG: ret i32 25
34 // Outputs for function members checked via implicit filecheck flag
42 #define CORRECT nohost, gpu
43 #define WRONG cpu, gpu
47 #define CORRECT nohost, gpu
48 #define WRONG nohost, host
51 int foo() { return 2; }
54 static int stat_unused_();
55 static int stat_used_();
57 #pragma omp declare target
59 #pragma omp declare variant(foo) match(device = {kind(CORRECT)})
60 int bar() { return 3; }
62 #pragma omp declare variant(bazzz) match(device = {kind(CORRECT)})
63 int baz() { return 4; }
65 #pragma omp declare variant(test) match(device = {kind(CORRECT)})
66 int call() { return 5; }
68 #pragma omp declare variant(stat_unused_) match(device = {kind(CORRECT)})
69 static int stat_unused() { return 6; }
71 #pragma omp declare variant(stat_used_) match(device = {kind(CORRECT)})
72 static int stat_used() { return 7; }
74 #pragma omp end declare target
78 #pragma omp target map(from \
80 res
= bar() + baz() + call();
84 int test() { return 8; }
85 static int stat_unused_() { return 9; }
86 static int stat_used_() { return 10; }
88 #pragma omp declare target
94 int method_() { return 11; }
95 #pragma omp declare variant(SpecialFuncs::method_) \
96 match(device = {kind(CORRECT)})
97 int method() { return 12; }
98 #pragma omp declare variant(SpecialFuncs::method_) \
99 match(device = {kind(CORRECT)})
103 int SpecialFuncs::Method() { return 13; }
105 struct SpecSpecialFuncs
{
111 #pragma omp declare variant(SpecSpecialFuncs::method_) \
112 match(device = {kind(CORRECT)})
113 int method() { return 14; }
114 #pragma omp declare variant(SpecSpecialFuncs::method_) \
115 match(device = {kind(CORRECT)})
119 #pragma omp end declare target
121 int SpecSpecialFuncs::method_() { return 15; }
122 int SpecSpecialFuncs::Method() { return 16; }
124 int prio() { return 17; }
125 int prio1() { return 18; }
126 static int prio2() { return 19; }
127 static int prio3() { return 20; }
128 static int prio4() { return 21; }
129 int fn_linkage_variant() { return 22; }
130 extern "C" int fn_linkage_variant1() { return 23; }
131 int fn_variant2() { return 24; }
133 #pragma omp declare target
140 #pragma omp declare variant(prio) match(device = {kind(SUBSET)})
141 #pragma omp declare variant(prio1) match(device = {kind(CORRECT)})
142 int prio_() { return 25; }
144 #pragma omp declare variant(prio4) match(device = {kind(SUBSET)})
145 #pragma omp declare variant(prio2) match(device = {kind(CORRECT)})
146 #pragma omp declare variant(prio3) match(device = {kind(SUBSET)})
147 static int prio1_() { return 26; }
149 int int_fn() { return prio1_(); }
152 #pragma omp declare variant(fn_linkage_variant) match(device = {kind(CORRECT)})
153 int fn_linkage() { return 27; }
156 #pragma omp declare variant(fn_linkage_variant1) match(device = {kind(CORRECT)})
157 int fn_linkage1() { return 28; }
159 #pragma omp declare variant(fn_variant2) match(device = {kind(WRONG)})
160 int fn2() { return 29; }
162 #pragma omp end declare target