summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SparseBitVector.h
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-04-07 17:38:23 +0000
committerOwen Anderson <resistor@mac.com>2008-04-07 17:38:23 +0000
commit412821284f16a683e9b734baf2b6c9b4635857f2 (patch)
treee3f2af37f3b0f3acebe01267c3c4c001d1c2261e /include/llvm/ADT/SparseBitVector.h
parentf02a8070eb01075993129d32ac264c651be55d62 (diff)
downloadllvm-412821284f16a683e9b734baf2b6c9b4635857f2.tar.gz
llvm-412821284f16a683e9b734baf2b6c9b4635857f2.tar.bz2
llvm-412821284f16a683e9b734baf2b6c9b4635857f2.tar.xz
Add operator= implementations to SparseBitVector, allowing it to be used in GVN. This results
in both time and memory savings for GVN. For example, one testcase went from 10.5s to 6s with this patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SparseBitVector.h')
-rw-r--r--include/llvm/ADT/SparseBitVector.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h
index 1ed28607ef..4c28682d39 100644
--- a/include/llvm/ADT/SparseBitVector.h
+++ b/include/llvm/ADT/SparseBitVector.h
@@ -89,6 +89,14 @@ public:
ElementIndex = RHS.ElementIndex;
std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits);
}
+
+ // Assignment
+ SparseBitVectorElement& operator=(const SparseBitVectorElement& RHS) {
+ ElementIndex = RHS.ElementIndex;
+ std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits);
+
+ return *this;
+ }
// Comparison.
bool operator==(const SparseBitVectorElement &RHS) const {
@@ -483,6 +491,21 @@ public:
CurrElementIter = Elements.begin ();
}
+
+ // Assignment
+ SparseBitVector& operator=(const SparseBitVector& RHS) {
+ Elements.clear();
+
+ ElementListConstIter ElementIter = RHS.Elements.begin();
+ while (ElementIter != RHS.Elements.end()) {
+ Elements.push_back(SparseBitVectorElement<ElementSize>(*ElementIter));
+ ++ElementIter;
+ }
+
+ CurrElementIter = Elements.begin ();
+
+ return *this;
+ }
// Test, Reset, and Set a bit in the bitmap.
bool test(unsigned Idx) {