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

Side by Side Diff: crosstest/test_cast_main.cpp

Issue 435353002: Subzero: Fix and clean up some cross tests. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Fix newlines and filename Created 6 years, 4 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
« no previous file with comments | « crosstest/test_cast.cpp ('k') | crosstest/test_fcmp.def » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/crosstest/test_cast_main.cpp - Driver for tests ------------===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Driver for crosstesting cast operations.
11 //
12 //===----------------------------------------------------------------------===//
13
1 /* crosstest.py --test=test_cast.cpp --test=test_cast_to_u1.ll \ 14 /* crosstest.py --test=test_cast.cpp --test=test_cast_to_u1.ll \
2 --driver=test_cast_main.cpp --prefix=Subzero_ --output=test_cast */ 15 --driver=test_cast_main.cpp --prefix=Subzero_ --output=test_cast */
3 16
4 #include <cstring> 17 #include <cstring>
5 #include <iostream> 18 #include <iostream>
6 #include <stdint.h> 19 #include <stdint.h>
7 20
8 // Include test_cast.h twice - once normally, and once within the 21 // Include test_cast.h twice - once normally, and once within the
9 // Subzero_ namespace, corresponding to the llc and Subzero translated 22 // Subzero_ namespace, corresponding to the llc and Subzero translated
10 // object files, respectively. 23 // object files, respectively.
(...skipping 18 matching lines...) Expand all
29 << "<" XSTR(FromCName) ", " XSTR(ToCName) ">(" << Input \ 42 << "<" XSTR(FromCName) ", " XSTR(ToCName) ">(" << Input \
30 << "): sz=" << ResultSz << " llc=" << ResultLlc << "\n"; \ 43 << "): sz=" << ResultSz << " llc=" << ResultLlc << "\n"; \
31 } \ 44 } \
32 } while (0) 45 } while (0)
33 46
34 template <typename FromType> 47 template <typename FromType>
35 void testValue(FromType Val, size_t &TotalTests, size_t &Passes, 48 void testValue(FromType Val, size_t &TotalTests, size_t &Passes,
36 size_t &Failures) { 49 size_t &Failures) {
37 COMPARE(cast, FromType, bool, Val); 50 COMPARE(cast, FromType, bool, Val);
38 COMPARE(cast, FromType, uint8_t, Val); 51 COMPARE(cast, FromType, uint8_t, Val);
39 COMPARE(cast, FromType, int8_t, Val); 52 COMPARE(cast, FromType, myint8_t, Val);
40 COMPARE(cast, FromType, uint16_t, Val); 53 COMPARE(cast, FromType, uint16_t, Val);
41 COMPARE(cast, FromType, int16_t, Val); 54 COMPARE(cast, FromType, int16_t, Val);
42 COMPARE(cast, FromType, uint32_t, Val); 55 COMPARE(cast, FromType, uint32_t, Val);
43 COMPARE(cast, FromType, int32_t, Val); 56 COMPARE(cast, FromType, int32_t, Val);
44 COMPARE(cast, FromType, uint64_t, Val); 57 COMPARE(cast, FromType, uint64_t, Val);
45 COMPARE(cast, FromType, int64_t, Val); 58 COMPARE(cast, FromType, int64_t, Val);
46 COMPARE(cast, FromType, float, Val); 59 COMPARE(cast, FromType, float, Val);
47 COMPARE(cast, FromType, double, Val); 60 COMPARE(cast, FromType, double, Val);
48 } 61 }
49 62
50 int main(int argc, char **argv) { 63 int main(int argc, char **argv) {
51 size_t TotalTests = 0; 64 size_t TotalTests = 0;
52 size_t Passes = 0; 65 size_t Passes = 0;
53 size_t Failures = 0; 66 size_t Failures = 0;
54 67
55 volatile bool ValsUi1[] = { false, true }; 68 volatile bool ValsUi1[] = { false, true };
56 static const size_t NumValsUi1 = sizeof(ValsUi1) / sizeof(*ValsUi1); 69 static const size_t NumValsUi1 = sizeof(ValsUi1) / sizeof(*ValsUi1);
57 volatile uint8_t ValsUi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff }; 70 volatile uint8_t ValsUi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
58 static const size_t NumValsUi8 = sizeof(ValsUi8) / sizeof(*ValsUi8); 71 static const size_t NumValsUi8 = sizeof(ValsUi8) / sizeof(*ValsUi8);
59 72
60 volatile int8_t ValsSi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff }; 73 volatile myint8_t ValsSi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
61 static const size_t NumValsSi8 = sizeof(ValsSi8) / sizeof(*ValsSi8); 74 static const size_t NumValsSi8 = sizeof(ValsSi8) / sizeof(*ValsSi8);
62 75
63 volatile uint16_t ValsUi16[] = { 0, 1, 0x7e, 0x7f, 0x80, 76 volatile uint16_t ValsUi16[] = { 0, 1, 0x7e, 0x7f, 0x80,
64 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 77 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
65 0x8000, 0x8001, 0xfffe, 0xffff }; 78 0x8000, 0x8001, 0xfffe, 0xffff };
66 static const size_t NumValsUi16 = sizeof(ValsUi16) / sizeof(*ValsUi16); 79 static const size_t NumValsUi16 = sizeof(ValsUi16) / sizeof(*ValsUi16);
67 80
68 volatile int16_t ValsSi16[] = { 0, 1, 0x7e, 0x7f, 0x80, 81 volatile int16_t ValsSi16[] = { 0, 1, 0x7e, 0x7f, 0x80,
69 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 82 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
70 0x8000, 0x8001, 0xfffe, 0xffff }; 83 0x8000, 0x8001, 0xfffe, 0xffff };
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 157
145 for (size_t i = 0; i < NumValsUi1; ++i) { 158 for (size_t i = 0; i < NumValsUi1; ++i) {
146 bool Val = ValsUi1[i]; 159 bool Val = ValsUi1[i];
147 testValue<bool>(Val, TotalTests, Passes, Failures); 160 testValue<bool>(Val, TotalTests, Passes, Failures);
148 } 161 }
149 for (size_t i = 0; i < NumValsUi8; ++i) { 162 for (size_t i = 0; i < NumValsUi8; ++i) {
150 uint8_t Val = ValsUi8[i]; 163 uint8_t Val = ValsUi8[i];
151 testValue<uint8_t>(Val, TotalTests, Passes, Failures); 164 testValue<uint8_t>(Val, TotalTests, Passes, Failures);
152 } 165 }
153 for (size_t i = 0; i < NumValsSi8; ++i) { 166 for (size_t i = 0; i < NumValsSi8; ++i) {
154 int8_t Val = ValsSi8[i]; 167 myint8_t Val = ValsSi8[i];
155 testValue<int8_t>(Val, TotalTests, Passes, Failures); 168 testValue<myint8_t>(Val, TotalTests, Passes, Failures);
156 } 169 }
157 for (size_t i = 0; i < NumValsUi16; ++i) { 170 for (size_t i = 0; i < NumValsUi16; ++i) {
158 uint16_t Val = ValsUi16[i]; 171 uint16_t Val = ValsUi16[i];
159 testValue<uint16_t>(Val, TotalTests, Passes, Failures); 172 testValue<uint16_t>(Val, TotalTests, Passes, Failures);
160 } 173 }
161 for (size_t i = 0; i < NumValsSi16; ++i) { 174 for (size_t i = 0; i < NumValsSi16; ++i) {
162 int16_t Val = ValsSi16[i]; 175 int16_t Val = ValsSi16[i];
163 testValue<int16_t>(Val, TotalTests, Passes, Failures); 176 testValue<int16_t>(Val, TotalTests, Passes, Failures);
164 } 177 }
165 for (size_t i = 0; i < NumValsUi32; ++i) { 178 for (size_t i = 0; i < NumValsUi32; ++i) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 int64_t cvtftosi64(float a) { return (int64_t)a; } 229 int64_t cvtftosi64(float a) { return (int64_t)a; }
217 uint64_t cvtdtoui64(double a) { return (uint64_t)a; } 230 uint64_t cvtdtoui64(double a) { return (uint64_t)a; }
218 uint64_t cvtftoui64(float a) { return (uint64_t)a; } 231 uint64_t cvtftoui64(float a) { return (uint64_t)a; }
219 float cvtui64tof(uint64_t a) { return (float)a; } 232 float cvtui64tof(uint64_t a) { return (float)a; }
220 double cvtui64tod(uint64_t a) { return (double)a; } 233 double cvtui64tod(uint64_t a) { return (double)a; }
221 float cvtsi64tof(int64_t a) { return (float)a; } 234 float cvtsi64tof(int64_t a) { return (float)a; }
222 float cvtui32tof(uint32_t a) { return (float)a; } 235 float cvtui32tof(uint32_t a) { return (float)a; }
223 double cvtui32tod(uint32_t a) { return (double)a; } 236 double cvtui32tod(uint32_t a) { return (double)a; }
224 double cvtsi64tod(int64_t a) { return (double)a; } 237 double cvtsi64tod(int64_t a) { return (double)a; }
225 } 238 }
OLDNEW
« no previous file with comments | « crosstest/test_cast.cpp ('k') | crosstest/test_fcmp.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698