Commit e9ac0fe7 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Rename CountSetBits32 to CountPopulation32 for consistency.

R=machenbach@chromium.org

Review URL: https://codereview.chromium.org/502803002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23330 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8545f713
......@@ -17,8 +17,8 @@ namespace v8 {
namespace base {
namespace bits {
// CountSetBits32(value) returns the number of bits set in |value|.
inline uint32_t CountSetBits32(uint32_t value) {
// CountPopulation32(value) returns the number of bits set in |value|.
inline uint32_t CountPopulation32(uint32_t value) {
#if V8_HAS_BUILTIN_POPCOUNT
return __builtin_popcount(value);
#else
......@@ -47,7 +47,7 @@ inline uint32_t CountLeadingZeros32(uint32_t value) {
value = value | (value >> 4);
value = value | (value >> 8);
value = value | (value >> 16);
return CountSetBits32(~value);
return CountPopulation32(~value);
#endif
}
......
......@@ -423,7 +423,7 @@ void InstructionSelector::VisitWord32And(Node* node) {
}
if (IsSupported(ARMv7) && m.right().HasValue()) {
uint32_t value = m.right().Value();
uint32_t width = base::bits::CountSetBits32(value);
uint32_t width = base::bits::CountPopulation32(value);
uint32_t msb = base::bits::CountLeadingZeros32(value);
if (width != 0 && msb + width == 32) {
DCHECK_EQ(0, base::bits::CountTrailingZeros32(value));
......@@ -536,7 +536,7 @@ void InstructionSelector::VisitWord32Shr(Node* node) {
Int32BinopMatcher mleft(m.left().node());
if (mleft.right().HasValue()) {
uint32_t value = (mleft.right().Value() >> lsb) << lsb;
uint32_t width = base::bits::CountSetBits32(value);
uint32_t width = base::bits::CountPopulation32(value);
uint32_t msb = base::bits::CountLeadingZeros32(value);
if (msb + width + lsb == 32) {
DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(value));
......
......@@ -45,7 +45,7 @@ int BitVector::Count() const {
int count = 0;
for (int i = 0; i < data_length_; i++) {
int data = data_[i];
if (data != 0) count += base::bits::CountSetBits32(data);
if (data != 0) count += base::bits::CountPopulation32(data);
}
return count;
}
......
......@@ -1579,9 +1579,7 @@ int StackHandler::Rewind(Isolate* isolate,
// -------------------------------------------------------------------------
int NumRegs(RegList reglist) {
return base::bits::CountSetBits32(reglist);
}
int NumRegs(RegList reglist) { return base::bits::CountPopulation32(reglist); }
struct JSCallerSavedCodeData {
......
......@@ -10,13 +10,13 @@ namespace v8 {
namespace base {
namespace bits {
TEST(BitsTest, CountSetBits32) {
EXPECT_EQ(0u, CountSetBits32(0));
EXPECT_EQ(1u, CountSetBits32(1));
EXPECT_EQ(8u, CountSetBits32(0x11111111));
EXPECT_EQ(16u, CountSetBits32(0xf0f0f0f0));
EXPECT_EQ(24u, CountSetBits32(0xfff0f0ff));
EXPECT_EQ(32u, CountSetBits32(0xffffffff));
TEST(BitsTest, CountPopulation32) {
EXPECT_EQ(0u, CountPopulation32(0));
EXPECT_EQ(1u, CountPopulation32(1));
EXPECT_EQ(8u, CountPopulation32(0x11111111));
EXPECT_EQ(16u, CountPopulation32(0xf0f0f0f0));
EXPECT_EQ(24u, CountPopulation32(0xfff0f0ff));
EXPECT_EQ(32u, CountPopulation32(0xffffffff));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment