diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-09-30 16:08:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-30 16:08:00 -0700 |
commit | 2f6939a2cecc37691a1e474ff15a7801f9509cfb (patch) | |
tree | d994f14cb68e95d675d0ac3943c8087c77129b3e /src/passes/OptimizeInstructions.cpp | |
parent | b91603f65c45139ad49dfa257749d100117b763d (diff) | |
download | binaryen-2f6939a2cecc37691a1e474ff15a7801f9509cfb.tar.gz binaryen-2f6939a2cecc37691a1e474ff15a7801f9509cfb.tar.bz2 binaryen-2f6939a2cecc37691a1e474ff15a7801f9509cfb.zip |
Clean up support/bits.h (#3177)
Use overloads instead of templates where applicable and change function names
from PascalCase to camelCase. Also puts the functions in the Bits namespace to
avoid naming conflicts.
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 55af9a34d..dc38933a6 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -304,7 +304,7 @@ struct OptimizeInstructions if (matches(curr, unary(Abstract::EqZ, binary(&inner, Abstract::RemS, any(), ival(&c)))) && - IsPowerOf2((uint64_t)c->value.getInteger())) { + Bits::isPowerOf2((uint64_t)c->value.getInteger())) { inner->op = Abstract::getBinary(c->type, Abstract::And); c->value = c->value.sub(Literal::makeFromInt32(1, c->type)); return curr; @@ -407,7 +407,7 @@ struct OptimizeInstructions // forcing them to zero like we do in the zero-extend. int32_t constValue = c->value.geti32(); auto upperConstValue = constValue & ~Bits::lowBitMask(bits); - uint32_t count = PopCount(upperConstValue); + uint32_t count = Bits::popCount(upperConstValue); auto constSignBit = constValue & (1 << (bits - 1)); if ((count > 0 && count < 32 - bits) || (constSignBit && count == 0)) { @@ -529,7 +529,7 @@ struct OptimizeInstructions Bits::getMaxBits(binary->left, this) <= 31) { binary->op = op; } - if (IsPowerOf2((uint32_t)c)) { + if (Bits::isPowerOf2((uint32_t)c)) { switch (binary->op) { case MulInt32: return optimizePowerOf2Mul(binary, (uint32_t)c); @@ -550,7 +550,7 @@ struct OptimizeInstructions Bits::getMaxBits(binary->left, this) <= 63) { binary->op = op; } - if (IsPowerOf2((uint64_t)c)) { + if (Bits::isPowerOf2((uint64_t)c)) { switch (binary->op) { case MulInt64: return optimizePowerOf2Mul(binary, (uint64_t)c); @@ -976,8 +976,8 @@ private: continue; } else if (binary->op == ShlInt32) { if (auto* c = binary->right->dynCast<Const>()) { - seekStack.emplace_back(binary->left, - mul * Pow2(Bits::getEffectiveShifts(c))); + seekStack.emplace_back( + binary->left, mul * Bits::pow2(Bits::getEffectiveShifts(c))); continue; } } else if (binary->op == MulInt32) { @@ -1206,7 +1206,7 @@ private: static_assert(std::is_same<T, uint32_t>::value || std::is_same<T, uint64_t>::value, "type mismatch"); - auto shifts = CountTrailingZeroes<T>(c); + auto shifts = Bits::countTrailingZeroes(c); binary->op = std::is_same<T, uint32_t>::value ? ShlInt32 : ShlInt64; binary->right->cast<Const>()->value = Literal(static_cast<T>(shifts)); return binary; @@ -1221,7 +1221,7 @@ private: static_assert(std::is_same<T, uint32_t>::value || std::is_same<T, uint64_t>::value, "type mismatch"); - auto shifts = CountTrailingZeroes<T>(c); + auto shifts = Bits::countTrailingZeroes(c); binary->op = std::is_same<T, uint32_t>::value ? ShrUInt32 : ShrUInt64; binary->right->cast<Const>()->value = Literal(static_cast<T>(shifts)); return binary; @@ -1310,7 +1310,7 @@ private: binary(Abstract::Ne, binary(&inner, Abstract::RemS, any(), ival(&c)), ival(0))) && - IsPowerOf2((uint64_t)c->value.getInteger())) { + Bits::isPowerOf2((uint64_t)c->value.getInteger())) { inner->op = Abstract::getBinary(c->type, Abstract::And); c->value = c->value.sub(Literal::makeFromInt32(1, c->type)); return curr; |