OLD | NEW |
1 //===- subzero/crosstest/test_bitmanip_main.cpp - Driver for tests. -------===// | 1 //===- subzero/crosstest/test_bitmanip_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 bit manipulation intrinsics. | 10 // Driver for cross testing bit manipulation intrinsics. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 57 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
58 | 58 |
59 template <typename Type> | 59 template <typename Type> |
60 void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 60 void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
61 typedef Type (*FuncType)(Type); | 61 typedef Type (*FuncType)(Type); |
62 static struct { | 62 static struct { |
63 const char *Name; | 63 const char *Name; |
64 FuncType FuncLlc; | 64 FuncType FuncLlc; |
65 FuncType FuncSz; | 65 FuncType FuncSz; |
66 } Funcs[] = { | 66 } Funcs[] = { |
67 #define X(inst) \ | 67 #define X(inst) \ |
68 { \ | 68 { STR(inst), test_##inst, Subzero_::test_##inst } \ |
69 STR(inst), test_##inst, Subzero_::test_##inst \ | 69 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \ |
70 }, \ | 70 {STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst}, |
71 { \ | 71 BMI_OPS |
72 STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst \ | |
73 }, \ | |
74 { \ | |
75 STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst \ | |
76 }, | |
77 BMI_OPS | |
78 #undef X | 72 #undef X |
79 }; | 73 }; |
80 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 74 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
81 | 75 |
82 for (size_t f = 0; f < NumFuncs; ++f) { | 76 for (size_t f = 0; f < NumFuncs; ++f) { |
83 for (size_t i = 0; i < NumValues; ++i) { | 77 for (size_t i = 0; i < NumValues; ++i) { |
84 Type Value = static_cast<Type>(Values[i]); | 78 Type Value = static_cast<Type>(Values[i]); |
85 ++TotalTests; | 79 ++TotalTests; |
86 Type ResultSz = Funcs[f].FuncSz(Value); | 80 Type ResultSz = Funcs[f].FuncSz(Value); |
87 Type ResultLlc = Funcs[f].FuncLlc(Value); | 81 Type ResultLlc = Funcs[f].FuncLlc(Value); |
88 if (ResultSz == ResultLlc) { | 82 if (ResultSz == ResultLlc) { |
89 ++Passes; | 83 ++Passes; |
90 } else { | 84 } else { |
91 ++Failures; | 85 ++Failures; |
92 std::cout << "test_" << Funcs[f].Name | 86 std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type)) |
93 << (CHAR_BIT * sizeof(Type)) << "(" | 87 << "(" << static_cast<uint64_t>(Value) |
94 << static_cast<uint64_t>(Value) | |
95 << "): sz=" << static_cast<uint64_t>(ResultSz) | 88 << "): sz=" << static_cast<uint64_t>(ResultSz) |
96 << " llc=" << static_cast<uint64_t>(ResultLlc) | 89 << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n"; |
97 << "\n"; | |
98 } | 90 } |
99 } | 91 } |
100 } | 92 } |
101 } | 93 } |
102 | 94 |
103 template <typename Type> | 95 template <typename Type> |
104 void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 96 void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
105 typedef Type (*FuncType)(Type); | 97 typedef Type (*FuncType)(Type); |
106 static struct { | 98 static struct { |
107 const char *Name; | 99 const char *Name; |
(...skipping 30 matching lines...) Expand all Loading... |
138 testBitManip<uint32_t>(TotalTests, Passes, Failures); | 130 testBitManip<uint32_t>(TotalTests, Passes, Failures); |
139 testBitManip<uint64_t>(TotalTests, Passes, Failures); | 131 testBitManip<uint64_t>(TotalTests, Passes, Failures); |
140 testByteSwap<uint16_t>(TotalTests, Passes, Failures); | 132 testByteSwap<uint16_t>(TotalTests, Passes, Failures); |
141 testByteSwap<uint32_t>(TotalTests, Passes, Failures); | 133 testByteSwap<uint32_t>(TotalTests, Passes, Failures); |
142 testByteSwap<uint64_t>(TotalTests, Passes, Failures); | 134 testByteSwap<uint64_t>(TotalTests, Passes, Failures); |
143 | 135 |
144 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 136 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
145 << " Failures=" << Failures << "\n"; | 137 << " Failures=" << Failures << "\n"; |
146 return Failures; | 138 return Failures; |
147 } | 139 } |
OLD | NEW |