/// \brief Set a given bit to 1.
///
/// Set the given bit to 1 whose position is given as "bitPosition".
- void setBit(unsigned bitPosition);
+ void setBit(unsigned BitPosition) {
+ assert(BitPosition <= BitWidth && "BitPosition out of range");
+ WordType Mask = maskBit(BitPosition);
+ if (isSingleWord())
+ VAL |= Mask;
+ else
+ pVal[whichWord(BitPosition)] |= Mask;
+ }
/// Set the sign bit to 1.
void setSignBit() {
/// \brief Set a given bit to 0.
///
/// Set the given bit to 0 whose position is given as "bitPosition".
- void clearBit(unsigned bitPosition);
+ void clearBit(unsigned BitPosition) {
+ assert(BitPosition <= BitWidth && "BitPosition out of range");
+ WordType Mask = ~maskBit(BitPosition);
+ if (isSingleWord())
+ VAL &= Mask;
+ else
+ pVal[whichWord(BitPosition)] &= Mask;
+ }
/// Set the sign bit to 0.
void clearSignBit() {
return tcCompare(pVal, RHS.pVal, getNumWords());
}
-void APInt::setBit(unsigned bitPosition) {
- if (isSingleWord())
- VAL |= maskBit(bitPosition);
- else
- pVal[whichWord(bitPosition)] |= maskBit(bitPosition);
-}
-
void APInt::setBitsSlowCase(unsigned loBit, unsigned hiBit) {
unsigned loWord = whichWord(loBit);
unsigned hiWord = whichWord(hiBit);
pVal[word] = WORD_MAX;
}
-/// Set the given bit to 0 whose position is given as "bitPosition".
-/// @brief Set a given bit to 0.
-void APInt::clearBit(unsigned bitPosition) {
- if (isSingleWord())
- VAL &= ~maskBit(bitPosition);
- else
- pVal[whichWord(bitPosition)] &= ~maskBit(bitPosition);
-}
-
/// @brief Toggle every bit to its opposite value.
void APInt::flipAllBitsSlowCase() {
tcComplement(pVal, getNumWords());