diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-05-12 01:46:01 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-05-12 01:46:01 +0000 |
| commit | a92fd0bebb9ed9175f1fb235f3ee1775bdf61cce (patch) | |
| tree | cfcea84db39b8f325dffc63873fa336ccf8a6758 /llvm/include | |
| parent | 5750a3fa20614580c7c726817b87022f5c5ac18a (diff) | |
| download | bcm5719-llvm-a92fd0bebb9ed9175f1fb235f3ee1775bdf61cce.tar.gz bcm5719-llvm-a92fd0bebb9ed9175f1fb235f3ee1775bdf61cce.zip | |
[APInt] Add a utility method to change the bit width and storage size of an APInt.
Summary:
This adds a resize method to APInt that manages deleting/allocating storage for an APInt and changes its bit width. Use this to simplify code in copy assignment and divide.
The assignment code in particular was overly complicated. Treating every possible case as a separate implementation. I'm also pretty sure the clearUnusedBits code at the end was unnecessary. Since we always copying whole words from the source APInt. All unused bits should be clear in the source.
Reviewers: hans, RKSimon
Reviewed By: RKSimon
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D33073
llvm-svn: 302863
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index f1b039e16dc..52f1c0892c2 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -157,6 +157,11 @@ private: return isSingleWord() ? U.VAL : U.pVal[whichWord(bitPosition)]; } + /// Utility method to change the bit width of this APInt to new bit width, + /// allocating and/or deallocating as necessary. There is no guarantee on the + /// value of any bits upon return. Caller should populate the bits after. + void reallocate(unsigned NewBitWidth); + /// \brief Convert a char array into an APInt /// /// \param radix 2, 8, 10, 16, or 36 |

