Chromium Code Reviews

Unified 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.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « crosstest/test_bitmanip.cpp ('k') | src/IceInstX8632.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/test_bitmanip_main.cpp
diff --git a/crosstest/test_bitmanip_main.cpp b/crosstest/test_bitmanip_main.cpp
index 89dc8bab3dfacb2c4d2c0bfdcdf728eed74d685b..592ad7ea7072d8a002d3d75a2ce62342db571386 100644
--- a/crosstest/test_bitmanip_main.cpp
+++ b/crosstest/test_bitmanip_main.cpp
@@ -102,19 +102,30 @@ void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) {
template <typename Type>
void testByteSwap(size_t &TotalTests, size_t &Passes, size_t &Failures) {
- for (size_t i = 0; i < NumValues; ++i) {
- Type Value = static_cast<Type>(Values[i]);
- ++TotalTests;
- Type ResultSz = test_bswap(Value);
- Type ResultLlc = Subzero_::test_bswap(Value);
- if (ResultSz == ResultLlc) {
- ++Passes;
- } else {
- ++Failures;
- std::cout << "test_bswap" << (CHAR_BIT * sizeof(Type)) << "("
- << static_cast<uint64_t>(Value)
- << "): sz=" << static_cast<uint64_t>(ResultSz)
- << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n";
+ typedef Type (*FuncType)(Type);
+ static struct {
+ const char *Name;
+ FuncType FuncLlc;
+ FuncType FuncSz;
+ } Funcs[] = {
+ {"bswap", test_bswap, Subzero_::test_bswap},
+ {"bswap_alloca", test_bswap_alloca, Subzero_::test_bswap_alloca}};
+ const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
+ for (size_t f = 0; f < NumFuncs; ++f) {
+ for (size_t i = 0; i < NumValues; ++i) {
+ Type Value = static_cast<Type>(Values[i]);
+ ++TotalTests;
+ Type ResultSz = Funcs[f].FuncSz(Value);
+ Type ResultLlc = Funcs[f].FuncLlc(Value);
+ if (ResultSz == ResultLlc) {
+ ++Passes;
+ } else {
+ ++Failures;
+ std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
+ << "(" << static_cast<uint64_t>(Value)
+ << "): sz=" << static_cast<uint64_t>(ResultSz)
+ << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n";
+ }
}
}
}
« no previous file with comments | « crosstest/test_bitmanip.cpp ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine