[ARM] Support for ARMv6-Z / ARMv6-ZK missing
[oota-llvm.git] / include / llvm / Support / Recycler.h
index 3f235b6e72f407009739b4344ffd0085d2254334..e97f36a735fdf64ece518c5afac4200565b19dd6 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "llvm/ADT/ilist.h"
 #include "llvm/Support/AlignOf.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 
 namespace llvm {
@@ -34,7 +36,8 @@ struct RecyclerStruct {
 };
 
 template<>
-struct ilist_traits<RecyclerStruct> : ilist_default_traits<RecyclerStruct> {
+struct ilist_traits<RecyclerStruct> :
+    public ilist_default_traits<RecyclerStruct> {
   static RecyclerStruct *getPrev(const RecyclerStruct *t) { return t->Prev; }
   static RecyclerStruct *getNext(const RecyclerStruct *t) { return t->Next; }
   static void setPrev(RecyclerStruct *t, RecyclerStruct *p) { t->Prev = p; }
@@ -46,8 +49,12 @@ struct ilist_traits<RecyclerStruct> : ilist_default_traits<RecyclerStruct> {
   }
   static void destroySentinel(RecyclerStruct *) {}
 
+  RecyclerStruct *provideInitialHead() const { return createSentinel(); }
+  RecyclerStruct *ensureHead(RecyclerStruct*) const { return createSentinel(); }
+  static void noteHead(RecyclerStruct*, RecyclerStruct*) {}
+
   static void deleteNode(RecyclerStruct *) {
-    assert(0 && "Recycler's ilist_traits shouldn't see a deleteNode call!");
+    llvm_unreachable("Recycler's ilist_traits shouldn't see a deleteNode call!");
   }
 };
 
@@ -81,12 +88,21 @@ public:
     }
   }
 
+  /// Special case for BumpPtrAllocator which has an empty Deallocate()
+  /// function.
+  ///
+  /// There is no need to traverse the free list, pulling all the objects into
+  /// cache.
+  void clear(BumpPtrAllocator&) {
+    FreeList.clearAndLeakNodesUnsafely();
+  }
+
   template<class SubClass, class AllocatorType>
   SubClass *Allocate(AllocatorType &Allocator) {
-    assert(sizeof(SubClass) <= Size &&
-           "Recycler allocation size is less than object size!");
-    assert(AlignOf<SubClass>::Alignment <= Align &&
-           "Recycler allocation alignment is less than object alignment!");
+    static_assert(AlignOf<SubClass>::Alignment <= Align,
+                  "Recycler allocation alignment is less than object align!");
+    static_assert(sizeof(SubClass) <= Size,
+                  "Recycler allocation size is less than object size!");
     return !FreeList.empty() ?
            reinterpret_cast<SubClass *>(FreeList.remove(FreeList.begin())) :
            static_cast<SubClass *>(Allocator.Allocate(Size, Align));