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

Side by Side Diff: crosstest/test_icmp_main.cpp

Issue 877003003: Subzero: Use a "known" version of clang-format. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a clang-format blacklist. Fix formatting "errors". Created 5 years, 10 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_global_main.cpp ('k') | crosstest/test_select_main.cpp » ('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_icmp_main.cpp - Driver for tests. -----------===// 1 //===- subzero/crosstest/test_icmp_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 icmp bitcode instruction 10 // Driver for cross testing the icmp bitcode instruction
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 /* crosstest.py --test=test_icmp.cpp --test=test_icmp_i1vec.ll \ 14 /* crosstest.py --test=test_icmp.cpp --test=test_icmp_i1vec.ll \
15 --driver=test_icmp_main.cpp --prefix=Subzero_ --output=test_icmp */ 15 --driver=test_icmp_main.cpp --prefix=Subzero_ --output=test_icmp */
16 16
17 #include <climits> // CHAR_BIT 17 #include <climits> // CHAR_BIT
18 #include <cstring> // memcmp, memset 18 #include <cstring> // memcmp, memset
19 #include <stdint.h> 19 #include <stdint.h>
20 #include <iostream> 20 #include <iostream>
21 21
22 // Include test_icmp.h twice - once normally, and once within the 22 // Include test_icmp.h twice - once normally, and once within the
23 // Subzero_ namespace, corresponding to the llc and Subzero translated 23 // Subzero_ namespace, corresponding to the llc and Subzero translated
24 // object files, respectively. 24 // object files, respectively.
25 #include "test_icmp.h" 25 #include "test_icmp.h"
26 namespace Subzero_ { 26 namespace Subzero_ {
27 #include "test_icmp.h" 27 #include "test_icmp.h"
28 } 28 }
29 29
30 volatile unsigned Values[] = { 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 30 volatile unsigned Values[] = {
31 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, 31 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001,
32 0x7e, 0x7f, 0x80, 0x81, 32 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81,
33 0xfe, 0xff, 0x100, 0x101, 33 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff,
34 0x7ffe, 0x7fff, 0x8000, 0x8001, 34 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001,
35 0xfffe, 0xffff, 0x10000, 0x10001, }; 35 };
36 const static size_t NumValues = sizeof(Values) / sizeof(*Values); 36 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
37 37
38 template <typename TypeUnsigned, typename TypeSigned> 38 template <typename TypeUnsigned, typename TypeSigned>
39 void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { 39 void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
40 typedef bool (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); 40 typedef bool (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
41 typedef bool (*FuncTypeSigned)(TypeSigned, TypeSigned); 41 typedef bool (*FuncTypeSigned)(TypeSigned, TypeSigned);
42 static struct { 42 static struct {
43 const char *Name; 43 const char *Name;
44 FuncTypeUnsigned FuncLlc; 44 FuncTypeUnsigned FuncLlc;
45 FuncTypeUnsigned FuncSz; 45 FuncTypeUnsigned FuncSz;
46 } Funcs[] = { 46 } Funcs[] = {
47 #define X(cmp, op) \ 47 #define X(cmp, op) \
48 { \ 48 { \
49 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ 49 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
50 (FuncTypeUnsigned)Subzero_::icmp##cmp \ 50 (FuncTypeUnsigned)Subzero_::icmp##cmp \
51 } \ 51 } \
52 , 52 ,
53 ICMP_U_TABLE 53 ICMP_U_TABLE
54 #undef X 54 #undef X
55 #define X(cmp, op) \ 55 #define X(cmp, op) \
56 { \ 56 { \
57 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \ 57 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned) icmp##cmp, \
58 (FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp \ 58 (FuncTypeUnsigned)(FuncTypeSigned) Subzero_::icmp##cmp \
59 } \ 59 } \
60 , 60 ,
61 ICMP_S_TABLE 61 ICMP_S_TABLE
62 #undef X 62 #undef X
63 }; 63 };
64 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 64 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
65 65
66 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { 66 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) {
67 // This is the "normal" version of the loop nest, for 32-bit or 67 // This is the "normal" version of the loop nest, for 32-bit or
68 // narrower types. 68 // narrower types.
69 for (size_t f = 0; f < NumFuncs; ++f) { 69 for (size_t f = 0; f < NumFuncs; ++f) {
70 for (size_t i = 0; i < NumValues; ++i) { 70 for (size_t i = 0; i < NumValues; ++i) {
71 for (size_t j = 0; j < NumValues; ++j) { 71 for (size_t j = 0; j < NumValues; ++j) {
72 TypeUnsigned Value1 = Values[i]; 72 TypeUnsigned Value1 = Values[i];
73 TypeUnsigned Value2 = Values[j]; 73 TypeUnsigned Value2 = Values[j];
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #define X(cmp, op) \ 134 #define X(cmp, op) \
135 { \ 135 { \
136 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ 136 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
137 (FuncTypeUnsigned)Subzero_::icmp##cmp \ 137 (FuncTypeUnsigned)Subzero_::icmp##cmp \
138 } \ 138 } \
139 , 139 ,
140 ICMP_U_TABLE 140 ICMP_U_TABLE
141 #undef X 141 #undef X
142 #define X(cmp, op) \ 142 #define X(cmp, op) \
143 { \ 143 { \
144 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \ 144 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned) icmp##cmp, \
145 (FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp \ 145 (FuncTypeUnsigned)(FuncTypeSigned) Subzero_::icmp##cmp \
146 } \ 146 } \
147 , 147 ,
148 ICMP_S_TABLE 148 ICMP_S_TABLE
149 #undef X 149 #undef X
150 }; 150 };
151 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 151 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
152 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; 152 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements;
153 for (size_t f = 0; f < NumFuncs; ++f) { 153 for (size_t f = 0; f < NumFuncs; ++f) {
154 PRNG Index; 154 PRNG Index;
155 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { 155 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
156 // Initialize the test vectors. 156 // Initialize the test vectors.
157 TypeUnsigned Value1, Value2; 157 TypeUnsigned Value1, Value2;
158 for (size_t j = 0; j < NumElementsInType;) { 158 for (size_t j = 0; j < NumElementsInType;) {
159 Value1[j] = Values[Index() % NumValues]; 159 Value1[j] = Values[Index() % NumValues];
160 Value2[j] = Values[Index() % NumValues]; 160 Value2[j] = Values[Index() % NumValues];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 typedef typename Vectors<T>::Ty Ty; 199 typedef typename Vectors<T>::Ty Ty;
200 typedef Ty (*FuncType)(Ty, Ty); 200 typedef Ty (*FuncType)(Ty, Ty);
201 static struct { 201 static struct {
202 const char *Name; 202 const char *Name;
203 FuncType FuncLlc; 203 FuncType FuncLlc;
204 FuncType FuncSz; 204 FuncType FuncSz;
205 } Funcs[] = { 205 } Funcs[] = {
206 #define X(cmp, op) \ 206 #define X(cmp, op) \
207 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \ 207 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \
208 , 208 ,
209 ICMP_U_TABLE 209 ICMP_U_TABLE ICMP_S_TABLE};
210 ICMP_S_TABLE
211 };
212 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 210 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
213 const static size_t NumElements = Vectors<T>::NumElements; 211 const static size_t NumElements = Vectors<T>::NumElements;
214 const static size_t MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING = 8; 212 const static size_t MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING = 8;
215 213
216 // Check if the type is small enough to try all possible input pairs. 214 // Check if the type is small enough to try all possible input pairs.
217 if (NumElements <= MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING) { 215 if (NumElements <= MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING) {
218 for (size_t f = 0; f < NumFuncs; ++f) { 216 for (size_t f = 0; f < NumFuncs; ++f) {
219 Ty Value1, Value2; 217 Ty Value1, Value2;
220 memset(&Value1, 0, sizeof(Value1)); 218 memset(&Value1, 0, sizeof(Value1));
221 for (bool IsValue1Done = false; !IsValue1Done; 219 for (bool IsValue1Done = false; !IsValue1Done;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); 278 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures);
281 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); 279 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures);
282 testsVecI1<v4i1>(TotalTests, Passes, Failures); 280 testsVecI1<v4i1>(TotalTests, Passes, Failures);
283 testsVecI1<v8i1>(TotalTests, Passes, Failures); 281 testsVecI1<v8i1>(TotalTests, Passes, Failures);
284 testsVecI1<v16i1>(TotalTests, Passes, Failures); 282 testsVecI1<v16i1>(TotalTests, Passes, Failures);
285 283
286 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 284 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
287 << " Failures=" << Failures << "\n"; 285 << " Failures=" << Failures << "\n";
288 return Failures; 286 return Failures;
289 } 287 }
OLDNEW
« no previous file with comments | « crosstest/test_global_main.cpp ('k') | crosstest/test_select_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698