diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-12-13 20:47:34 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-12-13 20:47:34 +0000 |
commit | 4497d963fba10b74949e74c50bd14e6f7c12f721 (patch) | |
tree | 6eb29c35a362a2af72ea812406ab6ed6c2898424 /llvm/lib/Support/APInt.cpp | |
parent | 49806f4dbe6dee00ae67833752c48d050a610178 (diff) | |
download | bcm5719-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.cpp | 8 |
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 || |