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

Unified Diff: crosstest/test_bitmanip.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: review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crosstest/test_bitmanip.h ('k') | crosstest/test_bitmanip.def » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/test_bitmanip.cpp
diff --git a/crosstest/test_bitmanip.cpp b/crosstest/test_bitmanip.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2ebe8a479a47ce184be1af1e3ae4c3d72f1e0682
--- /dev/null
+++ b/crosstest/test_bitmanip.cpp
@@ -0,0 +1,40 @@
+//===- subzero/crosstest/test_bitmanip.cpp - Implementation for tests. ----===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This aims to test that all the bit manipulation intrinsics work, via
+// cross-testing. This calls wrappers (my_{ctlz,cttz,ctpop} around the
+// intrinsics (llvm.{ctlz,cttz,ctpop}.*).
+//===----------------------------------------------------------------------===//
+
+#include <stdint.h>
+
+#include <cstdlib>
+
+#include "test_bitmanip.h"
+
+#define X(inst, type) \
+ type test_##inst(type a) { return my_##inst(a); } \
+ type test_alloca_##inst(type a) { \
+ const size_t buf_size = 8; \
+ type buf[buf_size]; \
+ for (size_t i = 0; i < buf_size; ++i) { \
+ buf[i] = my_##inst(a); \
+ } \
+ type sum = 0; \
+ for (size_t i = 0; i < buf_size; ++i) { \
+ sum += buf[i]; \
+ } \
+ return sum; \
+ } \
+ type test_const_##inst(type ignored) { \
+ return my_##inst(static_cast<type>(0x12340)); \
+ }
+
+FOR_ALL_BMI_OP_TYPES(X)
+#undef X
« no previous file with comments | « crosstest/test_bitmanip.h ('k') | crosstest/test_bitmanip.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698