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

Unified Diff: src/compiler-intrinsics.cc

Issue 170383003: Merge a few A64 utils into the CompilerIntrinsics. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes and cleaning Created 6 years, 10 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 | « src/compiler-intrinsics.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler-intrinsics.cc
diff --git a/src/a64/utils-a64.cc b/src/compiler-intrinsics.cc
similarity index 66%
rename from src/a64/utils-a64.cc
rename to src/compiler-intrinsics.cc
index 7e710d770e7a32e77f65da41942ab7a7c2ce4f75..1011362d0051261c546a1ab3a52195859a357991 100644
--- a/src/a64/utils-a64.cc
+++ b/src/compiler-intrinsics.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
+// Copyright 2006-2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,59 +25,21 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#if V8_TARGET_ARCH_A64
-
-#include "a64/utils-a64.h"
-
+#include "compiler-intrinsics.h"
namespace v8 {
namespace internal {
-#define __ assm->
-
-
-int CountLeadingZeros(uint64_t value, int width) {
- // TODO(jbramley): Optimize this for A64 hosts.
- ASSERT((width == 32) || (width == 64));
- int count = 0;
- uint64_t bit_test = 1UL << (width - 1);
- while ((count < width) && ((bit_test & value) == 0)) {
- count++;
- bit_test >>= 1;
- }
- return count;
-}
-
-
-int CountLeadingSignBits(int64_t value, int width) {
- // TODO(jbramley): Optimize this for A64 hosts.
- ASSERT((width == 32) || (width == 64));
- if (value >= 0) {
- return CountLeadingZeros(value, width) - 1;
- } else {
- return CountLeadingZeros(~value, width) - 1;
- }
-}
-
-
-int CountTrailingZeros(uint64_t value, int width) {
- // TODO(jbramley): Optimize this for A64 hosts.
+int C_CountRedundantLeadingSignBits(int64_t value, int width) {
ASSERT((width == 32) || (width == 64));
- int count = 0;
- while ((count < width) && (((value >> count) & 1) == 0)) {
- count++;
- }
- return count;
+ uint64_t val = static_cast<uint64_t>((value >= 0) ? value : ~value);
+ return CountLeadingZeros(val, width) - 1;
}
-int CountSetBits(uint64_t value, int width) {
- // TODO(jbramley): Would it be useful to allow other widths? The
- // implementation already supports them.
- ASSERT((width == 32) || (width == 64));
-
+int C_CountSetBits(uint64_t value, int width) {
// Mask out unused bits to ensure that they are not counted.
- value &= (0xffffffffffffffffUL >> (64-width));
+ value &= (0xffffffffffffffffUL >> (64 - width));
// Add up the set bits.
// The algorithm works by adding pairs of bit fields together iteratively,
@@ -101,12 +63,4 @@ int CountSetBits(uint64_t value, int width) {
}
-int MaskToBit(uint64_t mask) {
- ASSERT(CountSetBits(mask, 64) == 1);
- return CountTrailingZeros(mask, 64);
-}
-
-
} } // namespace v8::internal
-
-#endif // V8_TARGET_ARCH_A64
« no previous file with comments | « src/compiler-intrinsics.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698