summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Holzammer <andreas.holzammer@kdab.com>2013-02-26 14:22:17 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-01 13:53:26 +0100
commit09004dbcb93f197a88b2f7ba386b4a3e8ace8c1f (patch)
tree97a24180f494e6cdd2e7070910c614ef7aa81253
parente2fce942aaa21b1b75cd13afe751b1ba1aa81894 (diff)
downloadqtjsbackend-09004dbcb93f197a88b2f7ba386b4a3e8ace8c1f.tar.gz
[V8]Implement some compiler intrinsic functions
Implement CountTrailingZeros and CountLeadingZeros Change-Id: I1cb3af7cdb95c9b4f0aa4405be1b480f0c961012 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r--src/3rdparty/v8/src/compiler-intrinsics.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/3rdparty/v8/src/compiler-intrinsics.h b/src/3rdparty/v8/src/compiler-intrinsics.h
index b73e8ac..c1693b0 100644
--- a/src/3rdparty/v8/src/compiler-intrinsics.h
+++ b/src/3rdparty/v8/src/compiler-intrinsics.h
@@ -28,6 +28,10 @@
#ifndef V8_COMPILER_INTRINSICS_H_
#define V8_COMPILER_INTRINSICS_H_
+#if defined(_WIN32_WCE)
+#include <cmnintrin.h>
+#endif
+
namespace v8 {
namespace internal {
@@ -58,7 +62,7 @@ int CompilerIntrinsics::CountSetBits(uint32_t value) {
return __builtin_popcount(value);
}
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && !defined(_WIN32_WCE)
#pragma intrinsic(_BitScanForward)
#pragma intrinsic(_BitScanReverse)
@@ -75,6 +79,21 @@ int CompilerIntrinsics::CountLeadingZeros(uint32_t value) {
return 31 - static_cast<int>(result);
}
+#elif defined(_WIN32_WCE)
+int CompilerIntrinsics::CountTrailingZeros(uint32_t value) {
+ // taken from http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightFloatCast
+ float f = (float)(value & -value); // cast the least significant bit in v to a float
+ return (*(uint32_t *)&f >> 23) - 0x7f;
+}
+
+int CompilerIntrinsics::CountLeadingZeros(uint32_t value) {
+ return _CountLeadingZeros(value);
+}
+#else
+#error Unsupported compiler
+#endif
+
+#if defined(_MSC_VER)
int CompilerIntrinsics::CountSetBits(uint32_t value) {
// Manually count set bits.
value = ((value >> 1) & 0x55555555) + (value & 0x55555555);
@@ -84,9 +103,6 @@ int CompilerIntrinsics::CountSetBits(uint32_t value) {
value = ((value >> 16) & 0x0000ffff) + (value & 0x0000ffff);
return value;
}
-
-#else
-#error Unsupported compiler
#endif
} } // namespace v8::internal