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 | 5bb504f4ea73fc46b4fb64d4ba970aafde1381b7 (patch) | |
tree | c5418a0810049b6e5e2b9d6a2fc3276992088bc8 /lib | |
parent | a23bd2e761f528e91e2b4d14cc495b7afde3b4f2 (diff) | |
download | llvm-5bb504f4ea73fc46b4fb64d4ba970aafde1381b7.tar.gz llvm-5bb504f4ea73fc46b4fb64d4ba970aafde1381b7.tar.bz2 llvm-5bb504f4ea73fc46b4fb64d4ba970aafde1381b7.tar.xz |
[block-freq] Add the APInt method extractBit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197271 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/APInt.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 89f96bd577..731c8cc9ca 100644 --- a/lib/Support/APInt.cpp +++ b/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 || |