diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-04-13 19:19:07 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-04-13 19:19:07 +0000 |
commit | 57ae4f5f01b6f8edf678d77ab935f3662993065d (patch) | |
tree | cd149b09994e203bf21c75ce93ee76169b116a22 /include/llvm/ADT/APInt.h | |
parent | 4beccb897dc4851c61aaa7577d9a0aed0bac78bc (diff) | |
download | llvm-57ae4f5f01b6f8edf678d77ab935f3662993065d.tar.gz llvm-57ae4f5f01b6f8edf678d77ab935f3662993065d.tar.bz2 llvm-57ae4f5f01b6f8edf678d77ab935f3662993065d.tar.xz |
Implement a getBitsNeeded method to determine how many bits are needed to
represent a string in binary form by an APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35968 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r-- | include/llvm/ADT/APInt.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index d9470ee3c8..e232550fdf 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -840,6 +840,12 @@ public: assert(getActiveBits() <= 64 && "Too many bits for int64_t"); return int64_t(pVal[0]); } + + /// This method determines how many bits are required to hold the APInt + /// equivalent of the string given by \p str of length \p slen. + /// @brief Get bits required for string value. + static uint32_t getBitsNeeded(const char* str, uint32_t slen, uint8_t radix); + /// countLeadingZeros - This function is an APInt version of the /// countLeadingZeros_{32,64} functions in MathExtras.h. It counts the number /// of zeros from the most significant bit to the first one bit. |