[llvm-commits] [llvm] r67428 - in /llvm/trunk/include/llvm/ADT: DepthFirstIterator.h SparseBitVector.h

Chris Lattner sabre at nondot.org
Fri Mar 20 22:40:09 PDT 2009


Author: lattner
Date: Sat Mar 21 00:40:09 2009
New Revision: 67428

URL: http://llvm.org/viewvc/llvm-project?rev=67428&view=rev
Log:
add some inline methods for infix operators on sparse vectors,
tidy some df iteration stuff, patch by John Mosby!

Modified:
    llvm/trunk/include/llvm/ADT/DepthFirstIterator.h
    llvm/trunk/include/llvm/ADT/SparseBitVector.h

Modified: llvm/trunk/include/llvm/ADT/DepthFirstIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DepthFirstIterator.h?rev=67428&r1=67427&r2=67428&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/DepthFirstIterator.h (original)
+++ llvm/trunk/include/llvm/ADT/DepthFirstIterator.h Sat Mar 21 00:40:09 2009
@@ -200,14 +200,12 @@
 
 template <class T>
 idf_iterator<T> idf_begin(const T& G) {
-  Inverse<T> DummyG;
-  return idf_iterator<T>::begin(DummyG);
+  return idf_iterator<T>::begin(Inverse<T>(G));
 }
 
 template <class T>
 idf_iterator<T> idf_end(const T& G){
-  Inverse<T> DummyG;
-  return idf_iterator<T>::end(DummyG);
+  return idf_iterator<T>::end(Inverse<T>(G));
 }
 
 // Provide global definitions of external inverse depth first iterators...
@@ -221,14 +219,12 @@
 
 template <class T, class SetTy>
 idf_ext_iterator<T, SetTy> idf_ext_begin(const T& G, SetTy &S) {
-  Inverse<T> DummyG(G);
-  return idf_ext_iterator<T, SetTy>::begin(DummyG, S);
+  return idf_ext_iterator<T, SetTy>::begin(Inverse<T>(G), S);
 }
 
 template <class T, class SetTy>
 idf_ext_iterator<T, SetTy> idf_ext_end(const T& G, SetTy &S) {
-  Inverse<T> DummyG(G);
-  return idf_ext_iterator<T, SetTy>::end(DummyG, S);
+  return idf_ext_iterator<T, SetTy>::end(Inverse<T>(G), S);
 }
 
 } // End llvm namespace

Modified: llvm/trunk/include/llvm/ADT/SparseBitVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseBitVector.h?rev=67428&r1=67427&r2=67428&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/SparseBitVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SparseBitVector.h Sat Mar 21 00:40:09 2009
@@ -460,6 +460,11 @@
     CurrElementIter = Elements.begin ();
   }
 
+  // Clear.
+  void clear() {
+    Elements.clear();
+  }
+
   // Assignment
   SparseBitVector& operator=(const SparseBitVector& RHS) {
     Elements.clear();
@@ -836,7 +841,36 @@
 template <unsigned ElementSize>
 inline bool operator &=(SparseBitVector<ElementSize> &LHS,
                         const SparseBitVector<ElementSize> *RHS) {
-  return LHS &= (*RHS);
+  return LHS &= *RHS;
+}
+
+// Convenience functions for infix union, intersection, difference operators.
+
+template <unsigned ElementSize>
+inline SparseBitVector<ElementSize>
+operator|(const SparseBitVector<ElementSize> &LHS,
+          const SparseBitVector<ElementSize> &RHS) {
+  SparseBitVector<ElementSize> Result(LHS);
+  Result |= RHS;
+  return Result;
+}
+
+template <unsigned ElementSize>
+inline SparseBitVector<ElementSize>
+operator&(const SparseBitVector<ElementSize> &LHS,
+          const SparseBitVector<ElementSize> &RHS) {
+  SparseBitVector<ElementSize> Result(LHS);
+  Result &= RHS;
+  return Result;
+}
+
+template <unsigned ElementSize>
+inline SparseBitVector<ElementSize>
+operator-(const SparseBitVector<ElementSize> &LHS,
+          const SparseBitVector<ElementSize> &RHS) {
+  SparseBitVector<ElementSize> Result;
+  Result.intersectWithComplement(LHS, RHS);
+  return Result;
 }
 
 
@@ -849,10 +883,8 @@
   for (bi = LHS.begin(); bi != LHS.end(); ++bi) {
     out << *bi << " ";
   }
-    out << " ]\n";
-}
+  out << " ]\n";
 }
-
-
+} // end namespace llvm
 
 #endif





More information about the llvm-commits mailing list