OLD | NEW |
1 /* crosstest.py --test=test_fcmp.pnacl.ll --driver=test_fcmp_main.cpp \ | 1 /* crosstest.py --test=test_fcmp.pnacl.ll --driver=test_fcmp_main.cpp \ |
2 --prefix=Subzero_ --output=test_fcmp */ | 2 --prefix=Subzero_ --output=test_fcmp */ |
3 | 3 |
4 #include <cassert> | 4 #include <cassert> |
5 #include <cfloat> | 5 #include <cfloat> |
6 #include <cmath> | 6 #include <cmath> |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "test_fcmp.def" | 9 #include "test_fcmp.def" |
10 | 10 |
11 #define X(cmp) \ | 11 #define X(cmp) \ |
12 extern "C" bool fcmp##cmp##Float(float a, float b); \ | 12 extern "C" bool fcmp##cmp##Float(float a, float b); \ |
13 extern "C" bool fcmp##cmp##Double(double a, double b); \ | 13 extern "C" bool fcmp##cmp##Double(double a, double b); \ |
14 extern "C" bool Subzero_fcmp##cmp##Float(float a, float b); \ | 14 extern "C" bool Subzero_fcmp##cmp##Float(float a, float b); \ |
15 extern "C" bool Subzero_fcmp##cmp##Double(double a, double b); | 15 extern "C" bool Subzero_fcmp##cmp##Double(double a, double b); |
16 FCMP_TABLE; | 16 FCMP_TABLE; |
17 #undef X | 17 #undef X |
18 | 18 |
19 int main(int argc, char **argv) { | 19 int main(int argc, char **argv) { |
20 static const double NegInf = -1.0 / 0.0; | 20 static const double NegInf = -1.0 / 0.0; |
21 static const double Zero = 0.0; | 21 static const double Zero = 0.0; |
22 static const double Ten = 10.0; | 22 static const double Ten = 10.0; |
23 static const double PosInf = 1.0 / 0.0; | 23 static const double PosInf = 1.0 / 0.0; |
24 static const double Nan = 0.0 / 0.0; | 24 static const double Nan = 0.0 / 0.0; |
| 25 static const double NegNan = -0.0 / 0.0; |
25 assert(std::fpclassify(NegInf) == FP_INFINITE); | 26 assert(std::fpclassify(NegInf) == FP_INFINITE); |
26 assert(std::fpclassify(PosInf) == FP_INFINITE); | 27 assert(std::fpclassify(PosInf) == FP_INFINITE); |
27 assert(std::fpclassify(Nan) == FP_NAN); | 28 assert(std::fpclassify(Nan) == FP_NAN); |
| 29 assert(std::fpclassify(NegNan) == FP_NAN); |
28 assert(NegInf < Zero); | 30 assert(NegInf < Zero); |
29 assert(NegInf < PosInf); | 31 assert(NegInf < PosInf); |
30 assert(Zero < PosInf); | 32 assert(Zero < PosInf); |
31 | 33 |
32 volatile double Values[] = { NegInf, Zero, DBL_MIN, FLT_MIN, Ten, | 34 volatile double Values[] = { NegInf, -Zero, Zero, DBL_MIN, FLT_MIN, |
33 FLT_MAX, DBL_MAX, PosInf, Nan, }; | 35 Ten, FLT_MAX, DBL_MAX, PosInf, Nan, |
| 36 NegNan }; |
34 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 37 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
35 | 38 |
36 typedef bool (*FuncTypeFloat)(float, float); | 39 typedef bool (*FuncTypeFloat)(float, float); |
37 typedef bool (*FuncTypeDouble)(double, double); | 40 typedef bool (*FuncTypeDouble)(double, double); |
38 static struct { | 41 static struct { |
39 const char *Name; | 42 const char *Name; |
40 FuncTypeFloat FuncFloatSz; | 43 FuncTypeFloat FuncFloatSz; |
41 FuncTypeFloat FuncFloatLlc; | 44 FuncTypeFloat FuncFloatLlc; |
42 FuncTypeDouble FuncDoubleSz; | 45 FuncTypeDouble FuncDoubleSz; |
43 FuncTypeDouble FuncDoubleLlc; | 46 FuncTypeDouble FuncDoubleLlc; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 << " llc=" << ResultLlc << std::endl; | 92 << " llc=" << ResultLlc << std::endl; |
90 } | 93 } |
91 } | 94 } |
92 } | 95 } |
93 } | 96 } |
94 | 97 |
95 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 98 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
96 << " Failures=" << Failures << "\n"; | 99 << " Failures=" << Failures << "\n"; |
97 return Failures; | 100 return Failures; |
98 } | 101 } |
OLD | NEW |