OLD | NEW |
1 //===- subzero/crosstest/test_icmp_main.cpp - Driver for tests. -----------===// | 1 //===- subzero/crosstest/test_icmp_main.cpp - Driver for tests. -----------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // Driver for cross testing the icmp bitcode instruction | 10 // Driver for cross testing the icmp bitcode instruction |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // Include test_icmp.h twice - once normally, and once within the | 22 // Include test_icmp.h twice - once normally, and once within the |
23 // Subzero_ namespace, corresponding to the llc and Subzero translated | 23 // Subzero_ namespace, corresponding to the llc and Subzero translated |
24 // object files, respectively. | 24 // object files, respectively. |
25 #include "test_icmp.h" | 25 #include "test_icmp.h" |
26 | 26 |
27 namespace Subzero_ { | 27 namespace Subzero_ { |
28 #include "test_icmp.h" | 28 #include "test_icmp.h" |
29 } | 29 } |
30 | 30 |
| 31 #include "insertelement.h" |
31 #include "xdefs.h" | 32 #include "xdefs.h" |
32 | 33 |
33 volatile unsigned Values[] = { | 34 volatile unsigned Values[] = { |
34 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001, | 35 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001, |
35 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81, | 36 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81, |
36 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff, | 37 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff, |
37 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001, | 38 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001, |
38 }; | 39 }; |
39 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 40 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
40 | 41 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 191 } |
191 } | 192 } |
192 } | 193 } |
193 } | 194 } |
194 } | 195 } |
195 | 196 |
196 const static size_t MaxTestsPerFunc = 100000; | 197 const static size_t MaxTestsPerFunc = 100000; |
197 | 198 |
198 template <typename TypeUnsignedLabel, typename TypeSignedLabel> | 199 template <typename TypeUnsignedLabel, typename TypeSignedLabel> |
199 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 200 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
200 #if !defined(ARM32) && !defined(NONSFI) | 201 #if !defined(ARM32) |
201 // TODO(jpp): remove this once vector support is implemented. | 202 // TODO(jpp): remove this once vector support is implemented. |
202 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; | 203 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; |
203 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; | 204 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; |
| 205 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned; |
| 206 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned; |
204 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); | 207 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); |
205 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); | 208 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); |
206 static struct { | 209 static struct { |
207 const char *Name; | 210 const char *Name; |
208 FuncTypeUnsigned FuncLlc; | 211 FuncTypeUnsigned FuncLlc; |
209 FuncTypeUnsigned FuncSz; | 212 FuncTypeUnsigned FuncSz; |
210 } Funcs[] = { | 213 } Funcs[] = { |
211 #define X(cmp, op) \ | 214 #define X(cmp, op) \ |
212 { \ | 215 { \ |
213 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ | 216 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ |
(...skipping 11 matching lines...) Expand all Loading... |
225 ICMP_S_TABLE | 228 ICMP_S_TABLE |
226 #undef X | 229 #undef X |
227 }; | 230 }; |
228 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 231 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
229 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; | 232 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; |
230 for (size_t f = 0; f < NumFuncs; ++f) { | 233 for (size_t f = 0; f < NumFuncs; ++f) { |
231 PRNG Index; | 234 PRNG Index; |
232 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { | 235 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { |
233 // Initialize the test vectors. | 236 // Initialize the test vectors. |
234 TypeUnsigned Value1, Value2; | 237 TypeUnsigned Value1, Value2; |
235 for (size_t j = 0; j < NumElementsInType;) { | 238 for (size_t j = 0; j < NumElementsInType; ++j) { |
236 Value1[j] = Values[Index() % NumValues]; | 239 setElement(Value1, j, Values[Index() % NumValues]); |
237 Value2[j] = Values[Index() % NumValues]; | 240 setElement(Value2, j, Values[Index() % NumValues]); |
238 ++j; | |
239 } | 241 } |
240 // Perform the test. | 242 // Perform the test. |
241 TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2); | 243 TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2); |
242 TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2); | 244 TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2); |
243 ++TotalTests; | 245 ++TotalTests; |
244 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { | 246 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { |
245 ++Passes; | 247 ++Passes; |
246 } else { | 248 } else { |
247 ++Failures; | 249 ++Failures; |
248 std::cout << "test" << Funcs[f].Name | 250 std::cout << "test" << Funcs[f].Name |
249 << Vectors<TypeUnsignedLabel>::TypeName << "(" | 251 << Vectors<TypeUnsignedLabel>::TypeName << "(" |
250 << vectAsString<TypeUnsignedLabel>(Value1) << "," | 252 << vectAsString<TypeUnsignedLabel>(Value1) << "," |
251 << vectAsString<TypeUnsignedLabel>(Value2) | 253 << vectAsString<TypeUnsignedLabel>(Value2) |
252 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) | 254 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) |
253 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) | 255 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) |
254 << "\n"; | 256 << "\n"; |
255 } | 257 } |
256 } | 258 } |
257 } | 259 } |
258 #endif // !ARM32 && !NONSFI | 260 #endif // !ARM32 |
259 } | 261 } |
260 | 262 |
261 // Return true on wraparound | 263 // Return true on wraparound |
262 template <typename T> bool incrementI1Vector(typename Vectors<T>::Ty &Vect) { | 264 template <typename T> |
| 265 bool __attribute__((noinline)) |
| 266 incrementI1Vector(typename Vectors<T>::Ty &Vect) { |
263 size_t Pos = 0; | 267 size_t Pos = 0; |
264 const static size_t NumElements = Vectors<T>::NumElements; | 268 const static size_t NumElements = Vectors<T>::NumElements; |
265 for (Pos = 0; Pos < NumElements; ++Pos) { | 269 for (Pos = 0; Pos < NumElements; ++Pos) { |
266 if (Vect[Pos] == 0) { | 270 if (Vect[Pos] == 0) { |
267 Vect[Pos] = 1; | 271 Vect[Pos] = 1; |
268 break; | 272 break; |
269 } | 273 } |
270 Vect[Pos] = 0; | 274 Vect[Pos] = 0; |
271 } | 275 } |
272 return (Pos == NumElements); | 276 return (Pos == NumElements); |
273 } | 277 } |
274 | 278 |
275 template <typename T> | 279 template <typename T> |
276 void testsVecI1(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 280 void testsVecI1(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
277 #if !defined(ARM32) && !defined(NONSFI) | 281 #if !defined(ARM32) |
278 // TODO(jpp): remove this once vector support is implemented. | 282 // TODO(jpp): remove this once vector support is implemented. |
279 typedef typename Vectors<T>::Ty Ty; | 283 typedef typename Vectors<T>::Ty Ty; |
280 typedef Ty (*FuncType)(Ty, Ty); | 284 typedef Ty (*FuncType)(Ty, Ty); |
281 static struct { | 285 static struct { |
282 const char *Name; | 286 const char *Name; |
283 FuncType FuncLlc; | 287 FuncType FuncLlc; |
284 FuncType FuncSz; | 288 FuncType FuncSz; |
285 } Funcs[] = { | 289 } Funcs[] = { |
286 #define X(cmp, op) \ | 290 #define X(cmp, op) \ |
287 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \ | 291 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \ |
(...skipping 29 matching lines...) Expand all Loading... |
317 } | 321 } |
318 } | 322 } |
319 } | 323 } |
320 } else { | 324 } else { |
321 for (size_t f = 0; f < NumFuncs; ++f) { | 325 for (size_t f = 0; f < NumFuncs; ++f) { |
322 PRNG Index; | 326 PRNG Index; |
323 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { | 327 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { |
324 Ty Value1, Value2; | 328 Ty Value1, Value2; |
325 // Initialize the test vectors. | 329 // Initialize the test vectors. |
326 for (size_t j = 0; j < NumElements; ++j) { | 330 for (size_t j = 0; j < NumElements; ++j) { |
327 Value1[j] = Index() % 2; | 331 setElement(Value1, j, Index() % 2); |
328 Value2[j] = Index() % 2; | 332 setElement(Value2, j, Index() % 2); |
329 } | 333 } |
330 // Perform the test. | 334 // Perform the test. |
331 Ty ResultSz = Funcs[f].FuncSz(Value1, Value2); | 335 Ty ResultSz = Funcs[f].FuncSz(Value1, Value2); |
332 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2); | 336 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2); |
333 ++TotalTests; | 337 ++TotalTests; |
334 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { | 338 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { |
335 ++Passes; | 339 ++Passes; |
336 } else { | 340 } else { |
337 ++Failures; | 341 ++Failures; |
338 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "(" | 342 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "(" |
339 << vectAsString<T>(Value1) << "," << vectAsString<T>(Value2) | 343 << vectAsString<T>(Value1) << "," << vectAsString<T>(Value2) |
340 << "): sz=" << vectAsString<T>(ResultSz) | 344 << "): sz=" << vectAsString<T>(ResultSz) |
341 << " llc=" << vectAsString<T>(ResultLlc) << "\n"; | 345 << " llc=" << vectAsString<T>(ResultLlc) << "\n"; |
342 } | 346 } |
343 } | 347 } |
344 } | 348 } |
345 } | 349 } |
346 #endif // !ARM32 && !NONSFI | 350 #endif // !ARM32 |
347 } | 351 } |
348 | 352 |
349 #ifdef X8664_STACK_HACK | 353 #ifdef X8664_STACK_HACK |
350 extern "C" int wrapped_main(int argc, char *argv[]) { | 354 extern "C" int wrapped_main(int argc, char *argv[]) { |
351 #else // !defined(X8664_STACK_HACK) | 355 #else // !defined(X8664_STACK_HACK) |
352 int main(int argc, char *argv[]) { | 356 int main(int argc, char *argv[]) { |
353 #endif // X8664_STACK_HACK | 357 #endif // X8664_STACK_HACK |
354 size_t TotalTests = 0; | 358 size_t TotalTests = 0; |
355 size_t Passes = 0; | 359 size_t Passes = 0; |
356 size_t Failures = 0; | 360 size_t Failures = 0; |
(...skipping 10 matching lines...) Expand all Loading... |
367 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); | 371 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); |
368 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); | 372 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); |
369 testsVecI1<v4i1>(TotalTests, Passes, Failures); | 373 testsVecI1<v4i1>(TotalTests, Passes, Failures); |
370 testsVecI1<v8i1>(TotalTests, Passes, Failures); | 374 testsVecI1<v8i1>(TotalTests, Passes, Failures); |
371 testsVecI1<v16i1>(TotalTests, Passes, Failures); | 375 testsVecI1<v16i1>(TotalTests, Passes, Failures); |
372 | 376 |
373 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 377 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
374 << " Failures=" << Failures << "\n"; | 378 << " Failures=" << Failures << "\n"; |
375 return Failures; | 379 return Failures; |
376 } | 380 } |
OLD | NEW |