summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/APInt.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-02-20 13:00:06 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-02-20 13:00:06 +0000
commitad4da0fc321230261b4d0387f0ec216eb8aa50ca (patch)
tree46df094a9b70df155db7ba54ad220991d7bc86de /include/llvm/ADT/APInt.h
parent52981c4b6016d9f0e295e0771ec0a50dd073b4b3 (diff)
downloadllvm-ad4da0fc321230261b4d0387f0ec216eb8aa50ca.tar.gz
llvm-ad4da0fc321230261b4d0387f0ec216eb8aa50ca.tar.bz2
llvm-ad4da0fc321230261b4d0387f0ec216eb8aa50ca.tar.xz
Move the SplatByte helper to APInt and generalize it a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r--include/llvm/ADT/APInt.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index 41234da662..13b353c93b 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -505,6 +505,17 @@ public:
return getAllOnesValue(numBits).lshr(numBits - loBitsSet);
}
+ /// \brief Return a value containing V broadcasted over NewLen bits.
+ static APInt getSplat(unsigned NewLen, const APInt &V) {
+ assert(NewLen >= V.getBitWidth() && "Can't splat to smaller bit width!");
+
+ APInt Val = V.zextOrSelf(NewLen);
+ for (unsigned I = V.getBitWidth(); I < NewLen; I <<= 1)
+ Val |= Val << I;
+
+ return Val;
+ }
+
/// \brief Determine if two APInts have the same value, after zero-extending
/// one of them (if needed!) to ensure that the bit-widths match.
static bool isSameValue(const APInt &I1, const APInt &I2) {