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

Side by Side Diff: crosstest/test_bitmanip_main.cpp

Issue 390443005: Lower bitmanip intrinsics, assuming absence of BMI/SSE4.2 for now. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: stuff Created 6 years, 5 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
OLDNEW
(Empty)
1 //===- subzero/crosstest/test_bitmanip_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 cross testing atomic intrinsics, via the sync builtins.
wala 2014/07/15 00:16:31 Incorrect description.
jvoung (off chromium) 2014/07/15 21:30:23 Oops copy-paste! Done.
11 //
12 //===----------------------------------------------------------------------===//
13
14 /* crosstest.py --test=test_bitmanip.cpp --test=test_bitmanip_intrin.ll \
15 --driver=test_bitmanip_main.cpp --prefix=Subzero_ --output=test_bitmanip */
16
17 #include <pthread.h>
wala 2014/07/15 00:16:31 Is <pthread.h> ever used (also <cstdlib> below)?
jvoung (off chromium) 2014/07/15 21:30:23 Done.
18 #include <stdint.h>
19
20 #include <climits>
21 #include <cstdlib>
22 #include <iostream>
23
24 // Include test_bitmanip.h twice - once normally, and once within the
25 // Subzero_ namespace, corresponding to the llc and Subzero translated
26 // object files, respectively.
27 #include "test_bitmanip.h"
28 namespace Subzero_ {
29 #include "test_bitmanip.h"
30 }
31
32 volatile uint64_t Values[] = {
33 0, 1, 0x7e,
34 0x7f, 0x80, 0x81,
35 0xfe, 0xff, 0x7ffe,
36 0x7fff, 0x8000, 0x8001,
37 0xfffe, 0xffff,
38 0x007fffff /*Max subnormal + */,
39 0x00800000 /*Min+ */, 0x7f7fffff /*Max+ */,
40 0x7f800000 /*+Inf*/, 0xff800000 /*-Inf*/,
41 0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/,
42 0x7ffffffe, 0x7fffffff, 0x80000000,
43 0x80000001, 0xfffffffe, 0xffffffff,
44 0x100000000ll, 0x100000001ll,
45 0x000fffffffffffffll /*Max subnormal + */,
46 0x0010000000000000ll /*Min+ */,
47 0x7fefffffffffffffll /*Max+ */,
48 0x7ff0000000000000ll /*+Inf*/,
49 0xfff0000000000000ll /*-Inf*/,
50 0x7ff0000000000001ll /*SNaN*/,
51 0x7ff8000000000000ll /*QNaN*/,
52 0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll,
53 0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll };
54
55 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
56
57 template <typename Type>
58 void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) {
59 typedef Type (*FuncType)(Type);
60 static struct {
61 const char *Name;
62 FuncType FuncLlc;
63 FuncType FuncSz;
64 } Funcs[] = {
65 #define X(inst) \
66 { \
67 STR(inst), test_##inst, Subzero_::test_##inst \
68 }, \
69 { \
70 STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst \
71 }, \
72 { \
73 STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst \
74 },
75 BMI_OPS
76 #undef X
77 };
78 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
79
80 for (size_t f = 0; f < NumFuncs; ++f) {
81 for (size_t i = 0; i < NumValues; ++i) {
82 Type Value = static_cast<Type>(Values[i]);
83 ++TotalTests;
84 Type ResultSz = Funcs[f].FuncSz(Value);
85 Type ResultLlc = Funcs[f].FuncLlc(Value);
86 if (ResultSz == ResultLlc) {
87 ++Passes;
88 } else {
89 ++Failures;
90 std::cout << "test_" << Funcs[f].Name
91 << (CHAR_BIT * sizeof(Type)) << "("
92 << static_cast<uint64_t>(Value)
93 << "): sz=" << static_cast<uint64_t>(ResultSz)
94 << " llc=" << static_cast<uint64_t>(ResultLlc)
95 << "\n";
96 }
97 }
98 }
99 }
100
101 int main(int argc, char **argv) {
102 size_t TotalTests = 0;
103 size_t Passes = 0;
104 size_t Failures = 0;
105
106 testBitManip<uint32_t>(TotalTests, Passes, Failures);
107 testBitManip<uint64_t>(TotalTests, Passes, Failures);
108
109 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
110 << " Failures=" << Failures << "\n";
111 return Failures;
112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698