Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Side by Side Diff: crosstest/test_cast_main.cpp

Issue 2432373002: [SubZero] Fix f64 to/from i64 moves (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addressed review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/crosstest/test_cast_main.cpp - Driver for tests ------------===// 1 //===- subzero/crosstest/test_cast_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 cast operations. 10 // Driver for crosstesting cast operations.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 std::cout << std::fixed << XSTR(Func) << "<" << FromString \ 47 std::cout << std::fixed << XSTR(Func) << "<" << FromString \
48 << ", " XSTR(ToCName) ">(" << Input << "): "; \ 48 << ", " XSTR(ToCName) ">(" << Input << "): "; \
49 if (sizeof(ToCName) == 1) \ 49 if (sizeof(ToCName) == 1) \
50 std::cout << "sz=" << (int)ResultSz << " llc=" << (int)ResultLlc; \ 50 std::cout << "sz=" << (int)ResultSz << " llc=" << (int)ResultLlc; \
51 else \ 51 else \
52 std::cout << "sz=" << ResultSz << " llc=" << ResultLlc; \ 52 std::cout << "sz=" << ResultSz << " llc=" << ResultLlc; \
53 std::cout << "\n"; \ 53 std::cout << "\n"; \
54 } \ 54 } \
55 } while (0) 55 } while (0)
56 56
57 #ifdef MIPS32
58 #define COMPARE_MIPS(Func, FromCName, ToCName, Input, FromString) \
59 do { \
60 ToCName ResultSz, ResultLlc; \
61 ResultLlc = Func<FromCName, ToCName>(1, Input); \
62 ResultSz = Subzero_::Func<FromCName, ToCName>(1, Input); \
63 ++TotalTests; \
64 if (!memcmp(&ResultLlc, &ResultSz, sizeof(ToCName))) { \
65 ++Passes; \
66 } else { \
67 ++Failures; \
68 std::cout << std::fixed << XSTR(Func) << "<" << FromString \
69 << ", " XSTR(ToCName) ">(" << Input << "): "; \
70 if (sizeof(ToCName) == 1) \
71 std::cout << "sz=" << (int)ResultSz << " llc=" << (int)ResultLlc; \
72 else \
73 std::cout << "sz=" << ResultSz << " llc=" << ResultLlc; \
74 std::cout << "\n"; \
75 } \
76 } while (0)
77 #endif
78
57 #define COMPARE_VEC(Func, FromCName, ToCName, Input, FromString, ToString) \ 79 #define COMPARE_VEC(Func, FromCName, ToCName, Input, FromString, ToString) \
58 do { \ 80 do { \
59 ToCName ResultSz, ResultLlc; \ 81 ToCName ResultSz, ResultLlc; \
60 ResultLlc = Func<FromCName, ToCName>(Input); \ 82 ResultLlc = Func<FromCName, ToCName>(Input); \
61 ResultSz = Subzero_::Func<FromCName, ToCName>(Input); \ 83 ResultSz = Subzero_::Func<FromCName, ToCName>(Input); \
62 ++TotalTests; \ 84 ++TotalTests; \
63 if (!memcmp(&ResultLlc, &ResultSz, sizeof(ToCName))) { \ 85 if (!memcmp(&ResultLlc, &ResultSz, sizeof(ToCName))) { \
64 ++Passes; \ 86 ++Passes; \
65 } else { \ 87 } else { \
66 ++Failures; \ 88 ++Failures; \
(...skipping 15 matching lines...) Expand all
82 COMPARE(cast, FromType, uint16_t, Val, FromTypeString); 104 COMPARE(cast, FromType, uint16_t, Val, FromTypeString);
83 COMPARE(cast, FromType, int16_t, Val, FromTypeString); 105 COMPARE(cast, FromType, int16_t, Val, FromTypeString);
84 COMPARE(cast, FromType, uint32_t, Val, FromTypeString); 106 COMPARE(cast, FromType, uint32_t, Val, FromTypeString);
85 COMPARE(cast, FromType, int32_t, Val, FromTypeString); 107 COMPARE(cast, FromType, int32_t, Val, FromTypeString);
86 COMPARE(cast, FromType, uint64, Val, FromTypeString); 108 COMPARE(cast, FromType, uint64, Val, FromTypeString);
87 COMPARE(cast, FromType, int64, Val, FromTypeString); 109 COMPARE(cast, FromType, int64, Val, FromTypeString);
88 COMPARE(cast, FromType, float, Val, FromTypeString); 110 COMPARE(cast, FromType, float, Val, FromTypeString);
89 COMPARE(cast, FromType, double, Val, FromTypeString); 111 COMPARE(cast, FromType, double, Val, FromTypeString);
90 } 112 }
91 113
114 #ifdef MIPS32
115 template <typename FromType>
116 void testValueMIPS(FromType Val, size_t &TotalTests, size_t &Passes,
117 size_t &Failures, const char *FromTypeString) {
118 COMPARE_MIPS(cast, FromType, uint8_t, Val, FromTypeString);
119 COMPARE_MIPS(cast, FromType, myint8_t, Val, FromTypeString);
120 COMPARE_MIPS(cast, FromType, uint16_t, Val, FromTypeString);
121 COMPARE_MIPS(cast, FromType, int16_t, Val, FromTypeString);
122 COMPARE_MIPS(cast, FromType, uint32_t, Val, FromTypeString);
123 COMPARE_MIPS(cast, FromType, int32_t, Val, FromTypeString);
124 COMPARE_MIPS(cast, FromType, uint64, Val, FromTypeString);
125 COMPARE_MIPS(cast, FromType, int64, Val, FromTypeString);
126 COMPARE_MIPS(cast, FromType, float, Val, FromTypeString);
127 COMPARE_MIPS(cast, FromType, double, Val, FromTypeString);
128 }
129 #endif
130
92 template <typename FromType, typename ToType> 131 template <typename FromType, typename ToType>
93 void testVector(size_t &TotalTests, size_t &Passes, size_t &Failures, 132 void testVector(size_t &TotalTests, size_t &Passes, size_t &Failures,
94 const char *FromTypeString, const char *ToTypeString) { 133 const char *FromTypeString, const char *ToTypeString) {
95 const static size_t NumElementsInType = Vectors<FromType>::NumElements; 134 const static size_t NumElementsInType = Vectors<FromType>::NumElements;
96 PRNG Index; 135 PRNG Index;
97 static const float NegInf = -1.0 / 0.0; 136 static const float NegInf = -1.0 / 0.0;
98 static const float PosInf = 1.0 / 0.0; 137 static const float PosInf = 1.0 / 0.0;
99 static const float Nan = 0.0 / 0.0; 138 static const float Nan = 0.0 / 0.0;
100 static const float NegNan = -0.0 / 0.0; 139 static const float NegNan = -0.0 / 0.0;
101 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); 140 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 262 }
224 for (size_t i = 0; i < NumValsF64; ++i) { 263 for (size_t i = 0; i < NumValsF64; ++i) {
225 for (unsigned j = 0; j < 2; ++j) { 264 for (unsigned j = 0; j < 2; ++j) {
226 double Val = ValsF64[i]; 265 double Val = ValsF64[i];
227 if (j > 0) 266 if (j > 0)
228 Val = -Val; 267 Val = -Val;
229 testValue<double>(Val, TotalTests, Passes, Failures, "double"); 268 testValue<double>(Val, TotalTests, Passes, Failures, "double");
230 COMPARE(castBits, double, uint64, Val, "double"); 269 COMPARE(castBits, double, uint64, Val, "double");
231 } 270 }
232 } 271 }
272 #ifdef MIPS32
273 for (size_t i = 0; i < NumValsUi8; ++i) {
274 uint8_t Val = ValsUi8[i];
275 testValueMIPS<uint8_t>(Val, TotalTests, Passes, Failures, "uint8_t");
276 }
277 for (size_t i = 0; i < NumValsSi8; ++i) {
278 myint8_t Val = ValsSi8[i];
279 testValueMIPS<myint8_t>(Val, TotalTests, Passes, Failures, "int8_t");
280 }
281 for (size_t i = 0; i < NumValsUi16; ++i) {
282 uint16_t Val = ValsUi16[i];
283 testValueMIPS<uint16_t>(Val, TotalTests, Passes, Failures, "uint16_t");
284 }
285 for (size_t i = 0; i < NumValsSi16; ++i) {
286 int16_t Val = ValsSi16[i];
287 testValueMIPS<int16_t>(Val, TotalTests, Passes, Failures, "int16_t");
288 }
289 for (size_t i = 0; i < NumValsUi32; ++i) {
290 uint32_t Val = ValsUi32[i];
291 testValueMIPS<uint32_t>(Val, TotalTests, Passes, Failures, "uint32_t");
292 COMPARE_MIPS(castBits, uint32_t, float, Val, "uint32_t");
293 }
294 for (size_t i = 0; i < NumValsSi32; ++i) {
295 int32_t Val = ValsSi32[i];
296 testValueMIPS<int32_t>(Val, TotalTests, Passes, Failures, "int32_t");
297 }
298 for (size_t i = 0; i < NumValsUi64; ++i) {
299 uint64 Val = ValsUi64[i];
300 testValueMIPS<uint64>(Val, TotalTests, Passes, Failures, "uint64");
301 COMPARE_MIPS(castBits, uint64, double, Val, "uint64");
302 }
303 for (size_t i = 0; i < NumValsSi64; ++i) {
304 int64 Val = ValsSi64[i];
305 testValueMIPS<int64>(Val, TotalTests, Passes, Failures, "int64");
306 }
307 for (size_t i = 0; i < NumValsF32; ++i) {
308 for (unsigned j = 0; j < 2; ++j) {
309 float Val = ValsF32[i];
310 if (j > 0)
311 Val = -Val;
312 testValueMIPS<float>(Val, TotalTests, Passes, Failures, "float");
313 COMPARE_MIPS(castBits, float, uint32_t, Val, "float");
314 }
315 }
316 for (size_t i = 0; i < NumValsF64; ++i) {
317 for (unsigned j = 0; j < 2; ++j) {
318 double Val = ValsF64[i];
319 if (j > 0)
320 Val = -Val;
321 testValueMIPS<double>(Val, TotalTests, Passes, Failures, "double");
322 COMPARE_MIPS(castBits, double, uint64, Val, "double");
323 }
324 }
325 #endif
233 testVector<v4ui32, v4f32>(TotalTests, Passes, Failures, "v4ui32", "v4f32"); 326 testVector<v4ui32, v4f32>(TotalTests, Passes, Failures, "v4ui32", "v4f32");
234 testVector<v4si32, v4f32>(TotalTests, Passes, Failures, "v4si32", "v4f32"); 327 testVector<v4si32, v4f32>(TotalTests, Passes, Failures, "v4si32", "v4f32");
235 testVector<v4f32, v4si32>(TotalTests, Passes, Failures, "v4f32", "v4si32"); 328 testVector<v4f32, v4si32>(TotalTests, Passes, Failures, "v4f32", "v4si32");
236 testVector<v4f32, v4ui32>(TotalTests, Passes, Failures, "v4f32", "v4ui32"); 329 testVector<v4f32, v4ui32>(TotalTests, Passes, Failures, "v4f32", "v4ui32");
237 330
238 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 331 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
239 << " Failures=" << Failures << "\n"; 332 << " Failures=" << Failures << "\n";
240 return Failures; 333 return Failures;
241 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698