• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - -femit-all-decls | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck %s
4 // expected-no-diagnostics
5 // REQUIRES: x86-registered-target
6 #ifndef HEADER
7 #define HEADER
8 
9 #pragma omp declare simd linear(d : 8)
10 #pragma omp declare simd inbranch simdlen(32)
11 #pragma omp declare simd notinbranch
add_1(float * d)12 void add_1(float *d) {}
13 
14 #pragma omp declare simd aligned(hp, hp2)
15 template <class C>
h(C * hp,C * hp2,C * hq,C * lin)16 void h(C *hp, C *hp2, C *hq, C *lin) {
17 }
18 
19 // Explicit specialization with <C=int>.
20 // Pragmas need to be same, otherwise standard says that's undefined behavior.
21 #pragma omp declare simd aligned(hp, hp2)
22 template <>
h(int * hp,int * hp2,int * hq,int * lin)23 void h(int *hp, int *hp2, int *hq, int *lin) {
24   // Implicit specialization with <C=float>.
25   // This is special case where the directive is stored by Sema and is
26   // generated together with the (pending) function instatiation.
27   h((float *)hp, (float *)hp2, (float *)hq, (float *)lin);
28 }
29 
30 class VV {
31 public:
32 #pragma omp declare simd uniform(this, a) linear(val(b) : a)
add(int a,int b)33   int add(int a, int b) __attribute__((cold)) { return a + b; }
34 
35 #pragma omp declare simd aligned(b : 4) aligned(a) linear(ref(b) : 4) linear(this, a)
taddpf(float * a,float * & b)36   float taddpf(float *a, float *&b) { return *a + *b; }
37 
38 #pragma omp declare simd linear(uval(c) : 8)
39 #pragma omp declare simd aligned(b : 8)
tadd(int (& b)[],int & c)40   int tadd(int (&b)[], int &c) { return x[b[0]] + b[0]; }
41 
42 private:
43   int x[10];
44 } vv;
45 
46 template <int X, typename T>
47 class TVV {
48 public:
49 #pragma omp declare simd simdlen(X)
tadd(int a,int b)50   int tadd(int a, int b) { return a + b; }
51 
52 #pragma omp declare simd aligned(a : X * 2) aligned(b) linear(ref(b) : X)
taddpf(float * a,T * & b)53   float taddpf(float *a, T *&b) { return *a + *b; }
54 
55 #pragma omp declare simd
56 #pragma omp declare simd uniform(this, b)
tadd(int b)57   int tadd(int b) { return x[b] + b; }
58 
59 private:
60   int x[X];
61 };
62 
63 #pragma omp declare simd simdlen(N) aligned(b : N * 2) linear(uval(c) : N)
64 template <int N>
foo(int (& b)[N],float * & c)65 void foo(int (&b)[N], float *&c) {}
66 
67 TVV<16, float> t16;
68 
f(int (& g)[])69 void f(int (&g)[]) {
70   float a = 1.0f, b = 2.0f;
71   float *p = &b;
72   float r = t16.taddpf(&a, p);
73   int res = t16.tadd(b);
74   int c[64];
75   vv.add(res, res);
76   vv.taddpf(p, p);
77   vv.tadd(g, res);
78   foo(c, p);
79 }
80 
81 #pragma omp declare simd
82 #pragma omp declare simd notinbranch aligned(a : 32)
bar(VV v,float * a)83 int bar(VV v, float *a) { return 0; }
84 #pragma omp declare simd
85 #pragma omp declare simd notinbranch aligned(a)
baz(VV v,int a[])86 float baz(VV v, int a[]) { return 0; }
87 #pragma omp declare simd
88 #pragma omp declare simd notinbranch aligned(a)
bay(VV v,double * & a)89 double bay(VV v, double *&a) { return 0; }
90 #pragma omp declare simd
91 #pragma omp declare simd inbranch linear(a : b) uniform(v, b)
bax(VV v,double * a,int b)92 void bax(VV v, double *a, int b) {}
93 #pragma omp declare simd uniform(q) aligned(q : 16) linear(k : 1)
foo(float * q,float x,int k)94 float foo(float *q, float x, int k) { return 0; }
95 #pragma omp declare simd notinbranch
foo(double x)96 double foo(double x) { return 0; }
97 
98 // CHECK-DAG: define {{.+}}@_Z5add_1Pf(
99 // CHECK-DAG: define {{.+}}@_Z1hIiEvPT_S1_S1_S1_(
100 // CHECK-DAG: define {{.+}}@_Z1hIfEvPT_S1_S1_S1_(
101 // CHECK-DAG: define {{.+}}@_ZN2VV3addEii(
102 // CHECK-DAG: define {{.+}}@_ZN2VV6taddpfEPfRS0_(
103 // CHECK-DAG: define {{.+}}@_ZN2VV4taddERA_iRi(
104 // CHECK-DAG: define {{.+}}@_Z1fRA_i(
105 // CHECK-DAG: define {{.+}}@_ZN3TVVILi16EfE6taddpfEPfRS1_(
106 // CHECK-DAG: define {{.+}}@_ZN3TVVILi16EfE4taddEi(
107 // CHECK-DAG: define {{.+}}@_Z3fooILi64EEvRAT__iRPf(
108 // CHECK-DAG: define {{.+}}@_Z3bar2VVPf(
109 // CHECK-DAG: define {{.+}}@_Z3baz2VVPi(
110 // CHECK-DAG: define {{.+}}@_Z3bay2VVRPd(
111 // CHECK-DAG: define {{.+}}@_Z3bax2VVPdi(
112 // CHECK-DAG: define {{.+}}@_Z3fooPffi(
113 // CHECK-DAG: define {{.+}}@_Z3food(
114 
115 // CHECK-DAG: "_ZGVbM4l8__Z5add_1Pf"
116 // CHECK-DAG: "_ZGVbN4l8__Z5add_1Pf"
117 // CHECK-DAG: "_ZGVcM8l8__Z5add_1Pf"
118 // CHECK-DAG: "_ZGVcN8l8__Z5add_1Pf"
119 // CHECK-DAG: "_ZGVdM8l8__Z5add_1Pf"
120 // CHECK-DAG: "_ZGVdN8l8__Z5add_1Pf"
121 // CHECK-DAG: "_ZGVeM16l8__Z5add_1Pf"
122 // CHECK-DAG: "_ZGVeN16l8__Z5add_1Pf"
123 // CHECK-DAG: "_ZGVbM32v__Z5add_1Pf"
124 // CHECK-DAG: "_ZGVcM32v__Z5add_1Pf"
125 // CHECK-DAG: "_ZGVdM32v__Z5add_1Pf"
126 // CHECK-DAG: "_ZGVeM32v__Z5add_1Pf"
127 // CHECK-DAG: "_ZGVbN2v__Z5add_1Pf"
128 // CHECK-DAG: "_ZGVcN4v__Z5add_1Pf"
129 // CHECK-DAG: "_ZGVdN4v__Z5add_1Pf"
130 // CHECK-DAG: "_ZGVeN8v__Z5add_1Pf"
131 
132 // CHECK-DAG: "_ZGVbM2va16va16vv__Z1hIiEvPT_S1_S1_S1_"
133 // CHECK-DAG: "_ZGVbN2va16va16vv__Z1hIiEvPT_S1_S1_S1_"
134 // CHECK-DAG: "_ZGVcM4va16va16vv__Z1hIiEvPT_S1_S1_S1_"
135 // CHECK-DAG: "_ZGVcN4va16va16vv__Z1hIiEvPT_S1_S1_S1_"
136 // CHECK-DAG: "_ZGVdM4va16va16vv__Z1hIiEvPT_S1_S1_S1_"
137 // CHECK-DAG: "_ZGVdN4va16va16vv__Z1hIiEvPT_S1_S1_S1_"
138 // CHECK-DAG: "_ZGVeM8va16va16vv__Z1hIiEvPT_S1_S1_S1_"
139 // CHECK-DAG: "_ZGVeN8va16va16vv__Z1hIiEvPT_S1_S1_S1_"
140 
141 // CHECK-DAG: "_ZGVbM2va16va16vv__Z1hIfEvPT_S1_S1_S1_"
142 // CHECK-DAG: "_ZGVbN2va16va16vv__Z1hIfEvPT_S1_S1_S1_"
143 // CHECK-DAG: "_ZGVcM4va16va16vv__Z1hIfEvPT_S1_S1_S1_"
144 // CHECK-DAG: "_ZGVcN4va16va16vv__Z1hIfEvPT_S1_S1_S1_"
145 // CHECK-DAG: "_ZGVdM4va16va16vv__Z1hIfEvPT_S1_S1_S1_"
146 // CHECK-DAG: "_ZGVdN4va16va16vv__Z1hIfEvPT_S1_S1_S1_"
147 // CHECK-DAG: "_ZGVeM8va16va16vv__Z1hIfEvPT_S1_S1_S1_"
148 // CHECK-DAG: "_ZGVeN8va16va16vv__Z1hIfEvPT_S1_S1_S1_"
149 
150 // CHECK-DAG: "_ZGVbM4uus1__ZN2VV3addEii"
151 // CHECK-DAG: "_ZGVbN4uus1__ZN2VV3addEii"
152 // CHECK-DAG: "_ZGVcM8uus1__ZN2VV3addEii"
153 // CHECK-DAG: "_ZGVcN8uus1__ZN2VV3addEii"
154 // CHECK-DAG: "_ZGVdM8uus1__ZN2VV3addEii"
155 // CHECK-DAG: "_ZGVdN8uus1__ZN2VV3addEii"
156 // CHECK-DAG: "_ZGVeM16uus1__ZN2VV3addEii"
157 // CHECK-DAG: "_ZGVeN16uus1__ZN2VV3addEii"
158 
159 // CHECK-DAG: "_ZGVbM4lla16l4a4__ZN2VV6taddpfEPfRS0_"
160 // CHECK-DAG: "_ZGVbN4lla16l4a4__ZN2VV6taddpfEPfRS0_"
161 // CHECK-DAG: "_ZGVcM8lla16l4a4__ZN2VV6taddpfEPfRS0_"
162 // CHECK-DAG: "_ZGVcN8lla16l4a4__ZN2VV6taddpfEPfRS0_"
163 // CHECK-DAG: "_ZGVdM8lla16l4a4__ZN2VV6taddpfEPfRS0_"
164 // CHECK-DAG: "_ZGVdN8lla16l4a4__ZN2VV6taddpfEPfRS0_"
165 // CHECK-DAG: "_ZGVeM16lla16l4a4__ZN2VV6taddpfEPfRS0_"
166 // CHECK-DAG: "_ZGVeN16lla16l4a4__ZN2VV6taddpfEPfRS0_"
167 
168 // CHECK-DAG: "_ZGVbM4vvl8__ZN2VV4taddERA_iRi"
169 // CHECK-DAG: "_ZGVbN4vvl8__ZN2VV4taddERA_iRi"
170 // CHECK-DAG: "_ZGVcM8vvl8__ZN2VV4taddERA_iRi"
171 // CHECK-DAG: "_ZGVcN8vvl8__ZN2VV4taddERA_iRi"
172 // CHECK-DAG: "_ZGVdM8vvl8__ZN2VV4taddERA_iRi"
173 // CHECK-DAG: "_ZGVdN8vvl8__ZN2VV4taddERA_iRi"
174 // CHECK-DAG: "_ZGVeM16vvl8__ZN2VV4taddERA_iRi"
175 // CHECK-DAG: "_ZGVeN16vvl8__ZN2VV4taddERA_iRi"
176 // CHECK-DAG: "_ZGVbM4vva8v__ZN2VV4taddERA_iRi"
177 // CHECK-DAG: "_ZGVbN4vva8v__ZN2VV4taddERA_iRi"
178 // CHECK-DAG: "_ZGVcM8vva8v__ZN2VV4taddERA_iRi"
179 // CHECK-DAG: "_ZGVcN8vva8v__ZN2VV4taddERA_iRi"
180 // CHECK-DAG: "_ZGVdM8vva8v__ZN2VV4taddERA_iRi"
181 // CHECK-DAG: "_ZGVdN8vva8v__ZN2VV4taddERA_iRi"
182 // CHECK-DAG: "_ZGVeM16vva8v__ZN2VV4taddERA_iRi"
183 // CHECK-DAG: "_ZGVeN16vva8v__ZN2VV4taddERA_iRi"
184 
185 // CHECK-DAG: "_ZGVbM4vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
186 // CHECK-DAG: "_ZGVbN4vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
187 // CHECK-DAG: "_ZGVcM8vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
188 // CHECK-DAG: "_ZGVcN8vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
189 // CHECK-DAG: "_ZGVdM8vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
190 // CHECK-DAG: "_ZGVdN8vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
191 // CHECK-DAG: "_ZGVeM16vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
192 // CHECK-DAG: "_ZGVeN16vva32l16a16__ZN3TVVILi16EfE6taddpfEPfRS1_"
193 
194 // CHECK-DAG: "_ZGVbM4uu__ZN3TVVILi16EfE4taddEi"
195 // CHECK-DAG: "_ZGVbN4uu__ZN3TVVILi16EfE4taddEi"
196 // CHECK-DAG: "_ZGVcM8uu__ZN3TVVILi16EfE4taddEi"
197 // CHECK-DAG: "_ZGVcN8uu__ZN3TVVILi16EfE4taddEi"
198 // CHECK-DAG: "_ZGVdM8uu__ZN3TVVILi16EfE4taddEi"
199 // CHECK-DAG: "_ZGVdN8uu__ZN3TVVILi16EfE4taddEi"
200 // CHECK-DAG: "_ZGVeM16uu__ZN3TVVILi16EfE4taddEi"
201 // CHECK-DAG: "_ZGVeN16uu__ZN3TVVILi16EfE4taddEi"
202 // CHECK-DAG: "_ZGVbM4vv__ZN3TVVILi16EfE4taddEi"
203 // CHECK-DAG: "_ZGVbN4vv__ZN3TVVILi16EfE4taddEi"
204 // CHECK-DAG: "_ZGVcM8vv__ZN3TVVILi16EfE4taddEi"
205 // CHECK-DAG: "_ZGVcN8vv__ZN3TVVILi16EfE4taddEi"
206 // CHECK-DAG: "_ZGVdM8vv__ZN3TVVILi16EfE4taddEi"
207 // CHECK-DAG: "_ZGVdN8vv__ZN3TVVILi16EfE4taddEi"
208 // CHECK-DAG: "_ZGVeM16vv__ZN3TVVILi16EfE4taddEi"
209 // CHECK-DAG: "_ZGVeN16vv__ZN3TVVILi16EfE4taddEi"
210 
211 // CHECK-DAG: "_ZGVbM64va128l64__Z3fooILi64EEvRAT__iRPf"
212 // CHECK-DAG: "_ZGVbN64va128l64__Z3fooILi64EEvRAT__iRPf"
213 // CHECK-DAG: "_ZGVcM64va128l64__Z3fooILi64EEvRAT__iRPf"
214 // CHECK-DAG: "_ZGVcN64va128l64__Z3fooILi64EEvRAT__iRPf"
215 // CHECK-DAG: "_ZGVdM64va128l64__Z3fooILi64EEvRAT__iRPf"
216 // CHECK-DAG: "_ZGVdN64va128l64__Z3fooILi64EEvRAT__iRPf"
217 // CHECK-DAG: "_ZGVeM64va128l64__Z3fooILi64EEvRAT__iRPf"
218 // CHECK-DAG: "_ZGVeN64va128l64__Z3fooILi64EEvRAT__iRPf"
219 
220 // CHECK-DAG: "_ZGVbM4vv__Z3bar2VVPf"
221 // CHECK-DAG: "_ZGVbN4vv__Z3bar2VVPf"
222 // CHECK-DAG: "_ZGVcM8vv__Z3bar2VVPf"
223 // CHECK-DAG: "_ZGVcN8vv__Z3bar2VVPf"
224 // CHECK-DAG: "_ZGVdM8vv__Z3bar2VVPf"
225 // CHECK-DAG: "_ZGVdN8vv__Z3bar2VVPf"
226 // CHECK-DAG: "_ZGVeM16vv__Z3bar2VVPf"
227 // CHECK-DAG: "_ZGVeN16vv__Z3bar2VVPf"
228 // CHECK-DAG: "_ZGVbN4vva32__Z3bar2VVPf"
229 // CHECK-DAG: "_ZGVcN8vva32__Z3bar2VVPf"
230 // CHECK-DAG: "_ZGVdN8vva32__Z3bar2VVPf"
231 // CHECK-DAG: "_ZGVeN16vva32__Z3bar2VVPf"
232 
233 // CHECK-DAG: "_ZGVbM4vv__Z3baz2VVPi"
234 // CHECK-DAG: "_ZGVbN4vv__Z3baz2VVPi"
235 // CHECK-DAG: "_ZGVcM8vv__Z3baz2VVPi"
236 // CHECK-DAG: "_ZGVcN8vv__Z3baz2VVPi"
237 // CHECK-DAG: "_ZGVdM8vv__Z3baz2VVPi"
238 // CHECK-DAG: "_ZGVdN8vv__Z3baz2VVPi"
239 // CHECK-DAG: "_ZGVeM16vv__Z3baz2VVPi"
240 // CHECK-DAG: "_ZGVeN16vv__Z3baz2VVPi"
241 // CHECK-DAG: "_ZGVbN4vva16__Z3baz2VVPi"
242 // CHECK-DAG: "_ZGVcN8vva16__Z3baz2VVPi"
243 // CHECK-DAG: "_ZGVdN8vva16__Z3baz2VVPi"
244 // CHECK-DAG: "_ZGVeN16vva16__Z3baz2VVPi"
245 
246 // CHECK-DAG: "_ZGVbM2vv__Z3bay2VVRPd"
247 // CHECK-DAG: "_ZGVbN2vv__Z3bay2VVRPd"
248 // CHECK-DAG: "_ZGVcM4vv__Z3bay2VVRPd"
249 // CHECK-DAG: "_ZGVcN4vv__Z3bay2VVRPd"
250 // CHECK-DAG: "_ZGVdM4vv__Z3bay2VVRPd"
251 // CHECK-DAG: "_ZGVdN4vv__Z3bay2VVRPd"
252 // CHECK-DAG: "_ZGVeM8vv__Z3bay2VVRPd"
253 // CHECK-DAG: "_ZGVeN8vv__Z3bay2VVRPd"
254 // CHECK-DAG: "_ZGVbN2vva16__Z3bay2VVRPd"
255 // CHECK-DAG: "_ZGVcN4vva16__Z3bay2VVRPd"
256 // CHECK-DAG: "_ZGVdN4vva16__Z3bay2VVRPd"
257 // CHECK-DAG: "_ZGVeN8vva16__Z3bay2VVRPd"
258 
259 // CHECK-DAG: "_ZGVbM4us2u__Z3bax2VVPdi"
260 // CHECK-DAG: "_ZGVcM8us2u__Z3bax2VVPdi"
261 // CHECK-DAG: "_ZGVdM8us2u__Z3bax2VVPdi"
262 // CHECK-DAG: "_ZGVeM16us2u__Z3bax2VVPdi"
263 // CHECK-DAG: "_ZGVbM4vvv__Z3bax2VVPdi"
264 // CHECK-DAG: "_ZGVbN4vvv__Z3bax2VVPdi"
265 // CHECK-DAG: "_ZGVcM8vvv__Z3bax2VVPdi"
266 // CHECK-DAG: "_ZGVcN8vvv__Z3bax2VVPdi"
267 // CHECK-DAG: "_ZGVdM8vvv__Z3bax2VVPdi"
268 // CHECK-DAG: "_ZGVdN8vvv__Z3bax2VVPdi"
269 // CHECK-DAG: "_ZGVeM16vvv__Z3bax2VVPdi"
270 // CHECK-DAG: "_ZGVeN16vvv__Z3bax2VVPdi"
271 
272 // CHECK-DAG: "_ZGVbM4ua16vl1__Z3fooPffi"
273 // CHECK-DAG: "_ZGVbN4ua16vl1__Z3fooPffi"
274 // CHECK-DAG: "_ZGVcM8ua16vl1__Z3fooPffi"
275 // CHECK-DAG: "_ZGVcN8ua16vl1__Z3fooPffi"
276 // CHECK-DAG: "_ZGVdM8ua16vl1__Z3fooPffi"
277 // CHECK-DAG: "_ZGVdN8ua16vl1__Z3fooPffi"
278 // CHECK-DAG: "_ZGVeM16ua16vl1__Z3fooPffi"
279 // CHECK-DAG: "_ZGVeN16ua16vl1__Z3fooPffi"
280 
281 // CHECK-DAG: "_ZGVbN2v__Z3food"
282 // CHECK-DAG: "_ZGVcN4v__Z3food"
283 // CHECK-DAG: "_ZGVdN4v__Z3food"
284 // CHECK-DAG: "_ZGVeN8v__Z3food"
285 
286 // CHECK-NOT: "_ZGV{{.+}}__Z1fRA_i
287 
288 #endif
289