summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-12-13 20:47:34 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-12-13 20:47:34 +0000
commit4497d963fba10b74949e74c50bd14e6f7c12f721 (patch)
tree6eb29c35a362a2af72ea812406ab6ed6c2898424 /llvm/lib/Support/APInt.cpp
parent49806f4dbe6dee00ae67833752c48d050a610178 (diff)
downloadbcm5719-llvm-4497d963fba10b74949e74c50bd14e6f7c12f721.tar.gz
bcm5719-llvm-4497d963fba10b74949e74c50bd14e6f7c12f721.zip
[block-freq] Add the APInt method extractBit.
llvm-svn: 197271
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 89f96bd5774..731c8cc9cae 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -607,6 +607,14 @@ void APInt::flipBit(unsigned bitPosition) {
else setBit(bitPosition);
}
+bool APInt::extractBit(unsigned bitPosition) const {
+ assert(bitPosition < BitWidth && "Out of the bit-width range!");
+ if (isSingleWord())
+ return VAL & maskBit(bitPosition);
+ else
+ return pVal[whichWord(bitPosition)] & maskBit(bitPosition);
+}
+
unsigned APInt::getBitsNeeded(StringRef str, uint8_t radix) {
assert(!str.empty() && "Invalid string length");
assert((radix == 10 || radix == 8 || radix == 16 || radix == 2 ||
OpenPOWER on IntegriCloud