llvm.org GIT mirror llvm / 38ca8aa
[APInt] Move the single word cases of the bitwise operators inline. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298894 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
2 changed file(s) with 36 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
219219 /// out-of-line slow case for flipAllBits.
220220 void flipAllBitsSlowCase();
221221
222 /// out-of-line slow case for operator&=.
223 APInt& AndAssignSlowCase(const APInt& RHS);
224
225 /// out-of-line slow case for operator|=.
226 APInt& OrAssignSlowCase(const APInt& RHS);
227
228 /// out-of-line slow case for operator^=.
229 APInt& XorAssignSlowCase(const APInt& RHS);
230
222231 public:
223232 /// \name Constructors
224233 /// @{
692701 /// assigned to *this.
693702 ///
694703 /// \returns *this after ANDing with RHS.
695 APInt &operator&=(const APInt &RHS);
704 APInt &operator&=(const APInt &RHS) {
705 assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
706 if (isSingleWord()) {
707 VAL &= RHS.VAL;
708 return *this;
709 }
710 return AndAssignSlowCase(RHS);
711 }
696712
697713 /// \brief Bitwise AND assignment operator.
698714 ///
715731 /// assigned *this;
716732 ///
717733 /// \returns *this after ORing with RHS.
718 APInt &operator|=(const APInt &RHS);
734 APInt &operator|=(const APInt &RHS) {
735 assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
736 if (isSingleWord()) {
737 VAL |= RHS.VAL;
738 return *this;
739 }
740 return OrAssignSlowCase(RHS);
741 }
719742
720743 /// \brief Bitwise OR assignment operator.
721744 ///
738761 /// assigned to *this.
739762 ///
740763 /// \returns *this after XORing with RHS.
741 APInt &operator^=(const APInt &RHS);
764 APInt &operator^=(const APInt &RHS) {
765 assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
766 if (isSingleWord()) {
767 VAL ^= RHS.VAL;
768 return *this;
769 }
770 return XorAssignSlowCase(RHS);
771 }
742772
743773 /// \brief Bitwise XOR assignment operator.
744774 ///
405405 return *this;
406406 }
407407
408 APInt& APInt::operator&=(const APInt& RHS) {
409 assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
410 if (isSingleWord()) {
411 VAL &= RHS.VAL;
412 return *this;
413 }
408 APInt& APInt::AndAssignSlowCase(const APInt& RHS) {
414409 unsigned numWords = getNumWords();
415410 for (unsigned i = 0; i < numWords; ++i)
416411 pVal[i] &= RHS.pVal[i];
417412 return *this;
418413 }
419414
420 APInt& APInt::operator|=(const APInt& RHS) {
421 assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
422 if (isSingleWord()) {
423 VAL |= RHS.VAL;
424 return *this;
425 }
415 APInt& APInt::OrAssignSlowCase(const APInt& RHS) {
426416 unsigned numWords = getNumWords();
427417 for (unsigned i = 0; i < numWords; ++i)
428418 pVal[i] |= RHS.pVal[i];
429419 return *this;
430420 }
431421
432 APInt& APInt::operator^=(const APInt& RHS) {
433 assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
434 if (isSingleWord()) {
435 VAL ^= RHS.VAL;
436 return *this;
437 }
422 APInt& APInt::XorAssignSlowCase(const APInt& RHS) {
438423 unsigned numWords = getNumWords();
439424 for (unsigned i = 0; i < numWords; ++i)
440425 pVal[i] ^= RHS.pVal[i];