Index: crosstest/test_bitmanip.cpp |
diff --git a/crosstest/test_bitmanip.cpp b/crosstest/test_bitmanip.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1249b4feae624613864b9dfcb310fc2e3bfcf1ce |
--- /dev/null |
+++ b/crosstest/test_bitmanip.cpp |
@@ -0,0 +1,41 @@ |
+//===- subzero/crosstest/test_bitmanip.cpp - Implementation for tests --===// |
Jim Stichnoth
2014/07/14 23:20:45
Space it out to 80 cols :)
jvoung (off chromium)
2014/07/15 21:30:22
Done.
|
+// |
+// 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 uses a wrapper around the GCC __builtins to access |
wala
2014/07/15 00:16:31
Where were the GCC __builtins? I don't see them.
jvoung (off chromium)
2014/07/15 21:30:23
These are only using the wrappers, but the builtin
|
+// the NaCl intrinsics. |
+// |
+//===----------------------------------------------------------------------===// |
+ |
+#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 |