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

Side by Side Diff: crosstest/test_bitmanip_main.cpp

Issue 595093002: Handle "inplace" ops and unary ops w/ assembler (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: format Created 6 years, 3 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_bitmanip.cpp ('k') | src/IceInstX8632.h » ('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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 << "): sz=" << static_cast<uint64_t>(ResultSz) 95 << "): sz=" << static_cast<uint64_t>(ResultSz)
96 << " llc=" << static_cast<uint64_t>(ResultLlc) 96 << " llc=" << static_cast<uint64_t>(ResultLlc)
97 << "\n"; 97 << "\n";
98 } 98 }
99 } 99 }
100 } 100 }
101 } 101 }
102 102
103 template <typename Type> 103 template <typename Type>
104 void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) { 104 void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) {
105 for (size_t i = 0; i < NumValues; ++i) { 105 typedef Type (*FuncType)(Type);
106 Type Value = static_cast<Type>(Values[i]); 106 static struct {
107 ++TotalTests; 107 const char *Name;
108 Type ResultSz = test_bswap(Value); 108 FuncType FuncLlc;
109 Type ResultLlc = Subzero_::test_bswap(Value); 109 FuncType FuncSz;
110 if (ResultSz == ResultLlc) { 110 } Funcs[] = {
111 ++Passes; 111 {"bswap", test_bswap, Subzero_::test_bswap},
112 } else { 112 {"bswap_alloca", test_bswap_alloca, Subzero_::test_bswap_alloca}};
113 ++Failures; 113 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
114 std::cout << "test_bswap" << (CHAR_BIT * sizeof(Type)) << "(" 114 for (size_t f = 0; f < NumFuncs; ++f) {
115 << static_cast<uint64_t>(Value) 115 for (size_t i = 0; i < NumValues; ++i) {
116 << "): sz=" << static_cast<uint64_t>(ResultSz) 116 Type Value = static_cast<Type>(Values[i]);
117 << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n"; 117 ++TotalTests;
118 Type ResultSz = Funcs[f].FuncSz(Value);
119 Type ResultLlc = Funcs[f].FuncLlc(Value);
120 if (ResultSz == ResultLlc) {
121 ++Passes;
122 } else {
123 ++Failures;
124 std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
125 << "(" << static_cast<uint64_t>(Value)
126 << "): sz=" << static_cast<uint64_t>(ResultSz)
127 << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n";
128 }
118 } 129 }
119 } 130 }
120 } 131 }
121 132
122 int main(int argc, char **argv) { 133 int main(int argc, char **argv) {
123 size_t TotalTests = 0; 134 size_t TotalTests = 0;
124 size_t Passes = 0; 135 size_t Passes = 0;
125 size_t Failures = 0; 136 size_t Failures = 0;
126 137
127 testBitManip<uint32_t>(TotalTests, Passes, Failures); 138 testBitManip<uint32_t>(TotalTests, Passes, Failures);
128 testBitManip<uint64_t>(TotalTests, Passes, Failures); 139 testBitManip<uint64_t>(TotalTests, Passes, Failures);
129 testByteSwap<uint16_t>(TotalTests, Passes, Failures); 140 testByteSwap<uint16_t>(TotalTests, Passes, Failures);
130 testByteSwap<uint32_t>(TotalTests, Passes, Failures); 141 testByteSwap<uint32_t>(TotalTests, Passes, Failures);
131 testByteSwap<uint64_t>(TotalTests, Passes, Failures); 142 testByteSwap<uint64_t>(TotalTests, Passes, Failures);
132 143
133 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 144 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
134 << " Failures=" << Failures << "\n"; 145 << " Failures=" << Failures << "\n";
135 return Failures; 146 return Failures;
136 } 147 }
OLDNEW
« no previous file with comments | « crosstest/test_bitmanip.cpp ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698