mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
[APInt] Add an isSplat helper and use it in some places.
To complement getSplat. This is more general than the binary decomposition method as it also handles non-pow2 splat sizes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233195 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -672,6 +672,14 @@ hash_code llvm::hash_value(const APInt &Arg) {
|
||||
return hash_combine_range(Arg.pVal, Arg.pVal + Arg.getNumWords());
|
||||
}
|
||||
|
||||
bool APInt::isSplat(unsigned SplatSizeInBits) const {
|
||||
assert(getBitWidth() % SplatSizeInBits == 0 &&
|
||||
"SplatSizeInBits must divide width!");
|
||||
// We can check that all parts of an integer are equal by making use of a
|
||||
// little trick: rotate and check if it's still the same value.
|
||||
return *this == rotl(SplatSizeInBits);
|
||||
}
|
||||
|
||||
/// HiBits - This function returns the high "numBits" bits of this APInt.
|
||||
APInt APInt::getHiBits(unsigned numBits) const {
|
||||
return APIntOps::lshr(*this, BitWidth - numBits);
|
||||
|
Reference in New Issue
Block a user