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

Side by Side Diff: crosstest/test_bitmanip_main.cpp

Issue 974113002: Subzero: Rerun clang-format after LLVM 3.6 merge. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 9 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_arith_main.cpp ('k') | crosstest/test_calling_conv_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_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 10 matching lines...) Expand all
21 21
22 // Include test_bitmanip.h twice - once normally, and once within the 22 // Include test_bitmanip.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_bitmanip.h" 25 #include "test_bitmanip.h"
26 namespace Subzero_ { 26 namespace Subzero_ {
27 #include "test_bitmanip.h" 27 #include "test_bitmanip.h"
28 } 28 }
29 29
30 volatile uint64_t Values[] = { 30 volatile uint64_t Values[] = {
31 0, 1, 31 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 0x8000, 0x8001,
jvoung (off chromium) 2015/03/04 00:57:52 ah... I guess there's no good workaround to keep t
Jim Stichnoth 2015/03/04 01:06:10 Yeah - probably the best layout would be 1 value p
32 0x7e, 0x7f, 32 0xfffe, 0xffff, 0xc0de, 0xabcd, 0xdcba, 0x007fffff /*Max subnormal + */,
33 0x80, 0x81, 33 0x00800000 /*Min+ */, 0x7f7fffff /*Max+ */, 0x7f800000 /*+Inf*/,
34 0xfe, 0xff, 34 0xff800000 /*-Inf*/, 0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/, 0x7ffffffe,
35 0x7ffe, 0x7fff, 35 0x7fffffff, 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, 0x12345678,
36 0x8000, 0x8001, 36 0xabcd1234, 0x1234dcba, 0x100000000ll, 0x100000001ll, 0x123456789abcdef1ll,
37 0xfffe, 0xffff, 37 0x987654321ab1fedcll, 0x000fffffffffffffll /*Max subnormal + */,
38 0xc0de, 0xabcd,
39 0xdcba, 0x007fffff /*Max subnormal + */,
40 0x00800000 /*Min+ */, 0x7f7fffff /*Max+ */,
41 0x7f800000 /*+Inf*/, 0xff800000 /*-Inf*/,
42 0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/,
43 0x7ffffffe, 0x7fffffff,
44 0x80000000, 0x80000001,
45 0xfffffffe, 0xffffffff,
46 0x12345678, 0xabcd1234,
47 0x1234dcba, 0x100000000ll,
48 0x100000001ll, 0x123456789abcdef1ll,
49 0x987654321ab1fedcll, 0x000fffffffffffffll /*Max subnormal + */,
50 0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */, 38 0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */,
51 0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/, 39 0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/,
52 0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/, 40 0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/,
53 0x7ffffffffffffffell, 0x7fffffffffffffffll, 41 0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll,
54 0x8000000000000000ll, 0x8000000000000001ll, 42 0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll};
55 0xfffffffffffffffell, 0xffffffffffffffffll};
56 43
57 const static size_t NumValues = sizeof(Values) / sizeof(*Values); 44 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
58 45
59 template <typename Type> 46 template <typename Type>
60 void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) { 47 void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) {
61 typedef Type (*FuncType)(Type); 48 typedef Type (*FuncType)(Type);
62 static struct { 49 static struct {
63 const char *Name; 50 const char *Name;
64 FuncType FuncLlc; 51 FuncType FuncLlc;
65 FuncType FuncSz; 52 FuncType FuncSz;
66 } Funcs[] = { 53 } Funcs[] = {
67 #define X(inst) \ 54 #define X(inst) \
68 { STR(inst), test_##inst, Subzero_::test_##inst } \ 55 { STR(inst), test_##inst, Subzero_::test_##inst } \
69 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \ 56 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \
70 {STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst}, 57 {STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst},
71 BMI_OPS 58 BMI_OPS
72 #undef X 59 #undef X
73 }; 60 };
74 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 61 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
75 62
76 for (size_t f = 0; f < NumFuncs; ++f) { 63 for (size_t f = 0; f < NumFuncs; ++f) {
77 for (size_t i = 0; i < NumValues; ++i) { 64 for (size_t i = 0; i < NumValues; ++i) {
78 Type Value = static_cast<Type>(Values[i]); 65 Type Value = static_cast<Type>(Values[i]);
79 ++TotalTests; 66 ++TotalTests;
80 Type ResultSz = Funcs[f].FuncSz(Value); 67 Type ResultSz = Funcs[f].FuncSz(Value);
81 Type ResultLlc = Funcs[f].FuncLlc(Value); 68 Type ResultLlc = Funcs[f].FuncLlc(Value);
82 if (ResultSz == ResultLlc) { 69 if (ResultSz == ResultLlc) {
83 ++Passes; 70 ++Passes;
84 } else { 71 } else {
85 ++Failures; 72 ++Failures;
86 std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type)) 73 std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
87 << "(" << static_cast<uint64_t>(Value) 74 << "(" << static_cast<uint64_t>(Value)
88 << "): sz=" << static_cast<uint64_t>(ResultSz) 75 << "): sz=" << static_cast<uint64_t>(ResultSz)
89 << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n"; 76 << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n";
90 } 77 }
91 } 78 }
92 } 79 }
93 } 80 }
94 81
95 template <typename Type> 82 template <typename Type>
96 void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) { 83 void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) {
97 typedef Type (*FuncType)(Type); 84 typedef Type (*FuncType)(Type);
98 static struct { 85 static struct {
99 const char *Name; 86 const char *Name;
100 FuncType FuncLlc; 87 FuncType FuncLlc;
101 FuncType FuncSz; 88 FuncType FuncSz;
102 } Funcs[] = { 89 } Funcs[] = {
103 {"bswap", test_bswap, Subzero_::test_bswap}, 90 {"bswap", test_bswap, Subzero_::test_bswap},
104 {"bswap_alloca", test_bswap_alloca, Subzero_::test_bswap_alloca}}; 91 {"bswap_alloca", test_bswap_alloca, Subzero_::test_bswap_alloca}};
105 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 92 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
106 for (size_t f = 0; f < NumFuncs; ++f) { 93 for (size_t f = 0; f < NumFuncs; ++f) {
107 for (size_t i = 0; i < NumValues; ++i) { 94 for (size_t i = 0; i < NumValues; ++i) {
108 Type Value = static_cast<Type>(Values[i]); 95 Type Value = static_cast<Type>(Values[i]);
109 ++TotalTests; 96 ++TotalTests;
110 Type ResultSz = Funcs[f].FuncSz(Value); 97 Type ResultSz = Funcs[f].FuncSz(Value);
111 Type ResultLlc = Funcs[f].FuncLlc(Value); 98 Type ResultLlc = Funcs[f].FuncLlc(Value);
112 if (ResultSz == ResultLlc) { 99 if (ResultSz == ResultLlc) {
113 ++Passes; 100 ++Passes;
114 } else { 101 } else {
(...skipping 15 matching lines...) Expand all
130 testBitManip<uint32_t>(TotalTests, Passes, Failures); 117 testBitManip<uint32_t>(TotalTests, Passes, Failures);
131 testBitManip<uint64_t>(TotalTests, Passes, Failures); 118 testBitManip<uint64_t>(TotalTests, Passes, Failures);
132 testByteSwap<uint16_t>(TotalTests, Passes, Failures); 119 testByteSwap<uint16_t>(TotalTests, Passes, Failures);
133 testByteSwap<uint32_t>(TotalTests, Passes, Failures); 120 testByteSwap<uint32_t>(TotalTests, Passes, Failures);
134 testByteSwap<uint64_t>(TotalTests, Passes, Failures); 121 testByteSwap<uint64_t>(TotalTests, Passes, Failures);
135 122
136 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 123 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
137 << " Failures=" << Failures << "\n"; 124 << " Failures=" << Failures << "\n";
138 return Failures; 125 return Failures;
139 } 126 }
OLDNEW
« no previous file with comments | « crosstest/test_arith_main.cpp ('k') | crosstest/test_calling_conv_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698