diff options
Diffstat (limited to 'include/llvm/ADT/SmallBitVector.h')
| -rw-r--r-- | include/llvm/ADT/SmallBitVector.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/include/llvm/ADT/SmallBitVector.h b/include/llvm/ADT/SmallBitVector.h index 346fb1ca43dc..5c774b90ee3d 100644 --- a/include/llvm/ADT/SmallBitVector.h +++ b/include/llvm/ADT/SmallBitVector.h @@ -310,11 +310,47 @@ public: } // Intersection, union, disjoint union. - BitVector &operator&=(const SmallBitVector &RHS); // TODO: implement + SmallBitVector &operator&=(const SmallBitVector &RHS) { + resize(std::max(size(), RHS.size())); + if (isSmall()) + setSmallBits(getSmallBits() & RHS.getSmallBits()); + else if (!RHS.isSmall()) + X.getPointer()->operator&=(*RHS.X.getPointer()); + else { + SmallBitVector Copy = RHS; + Copy.resize(size()); + X.getPointer()->operator&=(*Copy.X.getPointer()); + } + return *this; + } - BitVector &operator|=(const SmallBitVector &RHS); // TODO: implement + SmallBitVector &operator|=(const SmallBitVector &RHS) { + resize(std::max(size(), RHS.size())); + if (isSmall()) + setSmallBits(getSmallBits() | RHS.getSmallBits()); + else if (!RHS.isSmall()) + X.getPointer()->operator|=(*RHS.X.getPointer()); + else { + SmallBitVector Copy = RHS; + Copy.resize(size()); + X.getPointer()->operator|=(*Copy.X.getPointer()); + } + return *this; + } - BitVector &operator^=(const SmallBitVector &RHS); // TODO: implement + SmallBitVector &operator^=(const SmallBitVector &RHS) { + resize(std::max(size(), RHS.size())); + if (isSmall()) + setSmallBits(getSmallBits() ^ RHS.getSmallBits()); + else if (!RHS.isSmall()) + X.getPointer()->operator^=(*RHS.X.getPointer()); + else { + SmallBitVector Copy = RHS; + Copy.resize(size()); + X.getPointer()->operator^=(*Copy.X.getPointer()); + } + return *this; + } // Assignment operator. const SmallBitVector &operator=(const SmallBitVector &RHS) { |
