Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/crosstest/test_arith_main.cpp - Driver for tests -----------===// | 1 //===- subzero/crosstest/test_arith_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 crosstesting arithmetic operations | 10 // Driver for crosstesting arithmetic operations |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 } else { | 132 } else { |
| 133 ResultSz = Funcs[f].FuncSzSigned(Value1, Value2); | 133 ResultSz = Funcs[f].FuncSzSigned(Value1, Value2); |
| 134 ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2); | 134 ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2); |
| 135 } | 135 } |
| 136 if (ResultSz == ResultLlc) { | 136 if (ResultSz == ResultLlc) { |
| 137 ++Passes; | 137 ++Passes; |
| 138 } else { | 138 } else { |
| 139 ++Failures; | 139 ++Failures; |
| 140 std::cout << "test" << Funcs[f].Name | 140 std::cout << "test" << Funcs[f].Name |
| 141 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1 | 141 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1 |
| 142 << ", " << Value2 << "): sz=" << (unsigned)ResultSz | 142 << ", " << Value2 << "): sz=" << (uint64)ResultSz |
| 143 << " llc=" << (unsigned)ResultLlc << "\n"; | 143 << " llc=" << (uint64)ResultLlc << "\n"; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 const static size_t MaxTestsPerFunc = 100000; | 153 const static size_t MaxTestsPerFunc = 100000; |
| 154 | 154 |
| 155 template <typename TypeUnsignedLabel, typename TypeSignedLabel> | 155 template <typename TypeUnsignedLabel, typename TypeSignedLabel> |
| 156 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 156 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
| 157 #ifndef ARM32 | |
|
Jim Stichnoth
2015/09/24 05:57:13
I'd like to see TODOs on all these "#ifndef ARM32"
John
2015/09/24 21:28:39
Done.
| |
| 157 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; | 158 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; |
| 158 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; | 159 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; |
| 159 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned; | 160 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned; |
| 160 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned; | 161 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned; |
| 161 | 162 |
| 162 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); | 163 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); |
| 163 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); | 164 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); |
| 164 volatile unsigned Values[] = INT_VALUE_ARRAY; | 165 volatile unsigned Values[] = INT_VALUE_ARRAY; |
| 165 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 166 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
| 166 static struct { | 167 static struct { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 std::cout << "test" << Funcs[f].Name << "v" << NumElementsInType << "i" | 224 std::cout << "test" << Funcs[f].Name << "v" << NumElementsInType << "i" |
| 224 << (CHAR_BIT * sizeof(ElementTypeUnsigned)) << "(" | 225 << (CHAR_BIT * sizeof(ElementTypeUnsigned)) << "(" |
| 225 << vectAsString<TypeUnsignedLabel>(Value1) << "," | 226 << vectAsString<TypeUnsignedLabel>(Value1) << "," |
| 226 << vectAsString<TypeUnsignedLabel>(Value2) | 227 << vectAsString<TypeUnsignedLabel>(Value2) |
| 227 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) | 228 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) |
| 228 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) | 229 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) |
| 229 << "\n"; | 230 << "\n"; |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 } | 233 } |
| 234 #endif // ARM32 | |
| 233 } | 235 } |
| 234 | 236 |
| 235 template <typename Type> | 237 template <typename Type> |
| 236 void testsFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 238 void testsFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
| 237 static const Type NegInf = -1.0 / 0.0; | 239 static const Type NegInf = -1.0 / 0.0; |
| 238 static const Type PosInf = 1.0 / 0.0; | 240 static const Type PosInf = 1.0 / 0.0; |
| 239 static const Type Nan = 0.0 / 0.0; | 241 static const Type Nan = 0.0 / 0.0; |
| 240 static const Type NegNan = -0.0 / 0.0; | 242 static const Type NegNan = -0.0 / 0.0; |
| 241 volatile Type Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); | 243 volatile Type Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); |
| 242 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 244 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 } else { | 300 } else { |
| 299 ++Failures; | 301 ++Failures; |
| 300 std::cout << std::fixed << "test_fabs" << (CHAR_BIT * sizeof(Type)) << "(" | 302 std::cout << std::fixed << "test_fabs" << (CHAR_BIT * sizeof(Type)) << "(" |
| 301 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc | 303 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc |
| 302 << "\n"; | 304 << "\n"; |
| 303 } | 305 } |
| 304 } | 306 } |
| 305 } | 307 } |
| 306 | 308 |
| 307 void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 309 void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
| 310 #ifndef ARM32 | |
| 308 static const float NegInf = -1.0 / 0.0; | 311 static const float NegInf = -1.0 / 0.0; |
| 309 static const float PosInf = 1.0 / 0.0; | 312 static const float PosInf = 1.0 / 0.0; |
| 310 static const float Nan = 0.0 / 0.0; | 313 static const float Nan = 0.0 / 0.0; |
| 311 static const float NegNan = -0.0 / 0.0; | 314 static const float NegNan = -0.0 / 0.0; |
| 312 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); | 315 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); |
| 313 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 316 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
| 314 typedef v4f32 (*FuncType)(v4f32, v4f32); | 317 typedef v4f32 (*FuncType)(v4f32, v4f32); |
| 315 static struct { | 318 static struct { |
| 316 const char *Name; | 319 const char *Name; |
| 317 FuncType FuncLlc; | 320 FuncType FuncLlc; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 ++Passes; | 359 ++Passes; |
| 357 } else { | 360 } else { |
| 358 ++Failures; | 361 ++Failures; |
| 359 std::cout << "test_fabs_v4f32" | 362 std::cout << "test_fabs_v4f32" |
| 360 << "(" << vectAsString<v4f32>(Value1) | 363 << "(" << vectAsString<v4f32>(Value1) |
| 361 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc" | 364 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc" |
| 362 << vectAsString<v4f32>(ResultLlc) << "\n"; | 365 << vectAsString<v4f32>(ResultLlc) << "\n"; |
| 363 } | 366 } |
| 364 } | 367 } |
| 365 } | 368 } |
| 369 #endif // ARM32 | |
| 366 } | 370 } |
| 367 | 371 |
| 368 #ifdef X8664_STACK_HACK | 372 #ifdef X8664_STACK_HACK |
| 369 extern "C" int wrapped_main(int argc, char *argv[]) { | 373 extern "C" int wrapped_main(int argc, char *argv[]) { |
| 370 #else // !defined(X8664_STACK_HACK) | 374 #else // !defined(X8664_STACK_HACK) |
| 371 int main(int argc, char *argv[]) { | 375 int main(int argc, char *argv[]) { |
| 372 #endif // X8664_STACK_HACK | 376 #endif // X8664_STACK_HACK |
| 373 size_t TotalTests = 0; | 377 size_t TotalTests = 0; |
| 374 size_t Passes = 0; | 378 size_t Passes = 0; |
| 375 size_t Failures = 0; | 379 size_t Failures = 0; |
| 376 | 380 |
| 377 testsInt<bool, bool>(TotalTests, Passes, Failures); | 381 testsInt<bool, bool>(TotalTests, Passes, Failures); |
| 378 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures); | 382 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures); |
| 379 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures); | 383 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures); |
| 380 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures); | 384 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures); |
| 381 testsInt<uint64, int64>(TotalTests, Passes, Failures); | 385 testsInt<uint64, int64>(TotalTests, Passes, Failures); |
| 382 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures); | 386 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures); |
| 383 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); | 387 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); |
| 384 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); | 388 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); |
| 385 testsFp<float>(TotalTests, Passes, Failures); | 389 testsFp<float>(TotalTests, Passes, Failures); |
| 386 testsFp<double>(TotalTests, Passes, Failures); | 390 testsFp<double>(TotalTests, Passes, Failures); |
| 387 testsVecFp(TotalTests, Passes, Failures); | 391 testsVecFp(TotalTests, Passes, Failures); |
| 388 | 392 |
| 389 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 393 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
| 390 << " Failures=" << Failures << "\n"; | 394 << " Failures=" << Failures << "\n"; |
| 391 return Failures; | 395 return Failures; |
| 392 } | 396 } |
| OLD | NEW |