| OLD | NEW |
| 1 //===- subzero/crosstest/test_fcmp_main.cpp - Driver for tests ------------===// | 1 //===- subzero/crosstest/test_fcmp_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 fcmp bitcode instruction | 10 // Driver for cross testing the fcmp bitcode instruction |
| 11 // | 11 // |
| 12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
| 13 | 13 |
| 14 /* crosstest.py --test=test_fcmp.pnacl.ll --driver=test_fcmp_main.cpp \ | 14 /* crosstest.py --test=test_fcmp.pnacl.ll --driver=test_fcmp_main.cpp \ |
| 15 --prefix=Subzero_ --output=test_fcmp */ | 15 --prefix=Subzero_ --output=test_fcmp */ |
| 16 | 16 |
| 17 #include <cassert> | 17 #include <cassert> |
| 18 #include <cfloat> | 18 #include <cfloat> |
| 19 #include <cmath> | 19 #include <cmath> |
| 20 #include <cstring> | 20 #include <cstring> |
| 21 #include <iostream> | 21 #include <iostream> |
| 22 | 22 |
| 23 #include "vectors.h" | 23 #include "vectors.h" |
| 24 #include "test_arith.def" |
| 24 #include "test_fcmp.def" | 25 #include "test_fcmp.def" |
| 25 | 26 |
| 26 #define X(cmp) \ | 27 #define X(cmp) \ |
| 27 extern "C" bool fcmp##cmp##Float(float a, float b); \ | 28 extern "C" bool fcmp##cmp##Float(float a, float b); \ |
| 28 extern "C" bool fcmp##cmp##Double(double a, double b); \ | 29 extern "C" bool fcmp##cmp##Double(double a, double b); \ |
| 29 extern "C" v4si32 fcmp##cmp##Vector(v4f32 a, v4f32 b); \ | 30 extern "C" v4si32 fcmp##cmp##Vector(v4f32 a, v4f32 b); \ |
| 30 extern "C" bool Subzero_fcmp##cmp##Float(float a, float b); \ | 31 extern "C" bool Subzero_fcmp##cmp##Float(float a, float b); \ |
| 31 extern "C" bool Subzero_fcmp##cmp##Double(double a, double b); \ | 32 extern "C" bool Subzero_fcmp##cmp##Double(double a, double b); \ |
| 32 extern "C" v4si32 Subzero_fcmp##cmp##Vector(v4f32 a, v4f32 b); | 33 extern "C" v4si32 Subzero_fcmp##cmp##Vector(v4f32 a, v4f32 b); |
| 33 FCMP_TABLE; | 34 FCMP_TABLE; |
| 34 #undef X | 35 #undef X |
| 35 | 36 |
| 36 volatile double *Values; | 37 volatile double *Values; |
| 37 size_t NumValues; | 38 size_t NumValues; |
| 38 | 39 |
| 39 void initializeValues() { | 40 void initializeValues() { |
| 40 static const double NegInf = -1.0 / 0.0; | 41 static const double NegInf = -1.0 / 0.0; |
| 41 static const double Zero = 0.0; | 42 static const double Zero = 0.0; |
| 42 static const double Ten = 10.0; | |
| 43 static const double PosInf = 1.0 / 0.0; | 43 static const double PosInf = 1.0 / 0.0; |
| 44 static const double Nan = 0.0 / 0.0; | 44 static const double Nan = 0.0 / 0.0; |
| 45 static const double NegNan = -0.0 / 0.0; | 45 static const double NegNan = -0.0 / 0.0; |
| 46 assert(std::fpclassify(NegInf) == FP_INFINITE); | 46 assert(std::fpclassify(NegInf) == FP_INFINITE); |
| 47 assert(std::fpclassify(PosInf) == FP_INFINITE); | 47 assert(std::fpclassify(PosInf) == FP_INFINITE); |
| 48 assert(std::fpclassify(Nan) == FP_NAN); | 48 assert(std::fpclassify(Nan) == FP_NAN); |
| 49 assert(std::fpclassify(NegNan) == FP_NAN); | 49 assert(std::fpclassify(NegNan) == FP_NAN); |
| 50 assert(NegInf < Zero); | 50 assert(NegInf < Zero); |
| 51 assert(NegInf < PosInf); | 51 assert(NegInf < PosInf); |
| 52 assert(Zero < PosInf); | 52 assert(Zero < PosInf); |
| 53 static volatile double InitValues[] = {NegInf, -Zero, Zero, DBL_MIN, | 53 static volatile double InitValues[] = |
| 54 FLT_MIN, Ten, FLT_MAX, DBL_MAX, | 54 FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); |
| 55 PosInf, Nan, NegNan}; | |
| 56 NumValues = sizeof(InitValues) / sizeof(*InitValues); | 55 NumValues = sizeof(InitValues) / sizeof(*InitValues); |
| 57 Values = InitValues; | 56 Values = InitValues; |
| 58 } | 57 } |
| 59 | 58 |
| 60 void testsScalar(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 59 void testsScalar(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
| 61 typedef bool (*FuncTypeFloat)(float, float); | 60 typedef bool (*FuncTypeFloat)(float, float); |
| 62 typedef bool (*FuncTypeDouble)(double, double); | 61 typedef bool (*FuncTypeDouble)(double, double); |
| 63 static struct { | 62 static struct { |
| 64 const char *Name; | 63 const char *Name; |
| 65 FuncTypeFloat FuncFloatSz; | 64 FuncTypeFloat FuncFloatSz; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 166 |
| 168 initializeValues(); | 167 initializeValues(); |
| 169 | 168 |
| 170 testsScalar(TotalTests, Passes, Failures); | 169 testsScalar(TotalTests, Passes, Failures); |
| 171 testsVector(TotalTests, Passes, Failures); | 170 testsVector(TotalTests, Passes, Failures); |
| 172 | 171 |
| 173 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 172 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
| 174 << " Failures=" << Failures << "\n"; | 173 << " Failures=" << Failures << "\n"; |
| 175 return Failures; | 174 return Failures; |
| 176 } | 175 } |
| OLD | NEW |