| 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
|
|
|