14#ifndef LLVM_SUPPORT_ARRAYRECYCLER_H
15#define LLVM_SUPPORT_ARRAYRECYCLER_H
35 static_assert(
Align >=
alignof(FreeList),
"Object underaligned");
36 static_assert(
sizeof(
T) >=
sizeof(FreeList),
"Objects are too small");
43 T *pop(
unsigned Idx) {
44 if (Idx >= Bucket.size())
46 FreeList *Entry = Bucket[Idx];
50 Bucket[Idx] = Entry->Next;
52 return reinterpret_cast<T*
>(Entry);
56 void push(
unsigned Idx,
T *
Ptr) {
57 assert(
Ptr &&
"Cannot recycle NULL pointer");
58 FreeList *Entry =
reinterpret_cast<FreeList*
>(
Ptr);
59 if (Idx >= Bucket.size())
60 Bucket.resize(
size_t(Idx) + 1);
61 Entry->Next = Bucket[Idx];
79 static Capacity
get(
size_t N) {
84 size_t getSize()
const {
return size_t(1u) << Index; }
98 assert(Bucket.empty() &&
"Non-empty ArrayRecycler deleted!");
103 template<
class AllocatorType>
105 for (; !Bucket.empty(); Bucket.pop_back())
106 while (
T *
Ptr = pop(Bucket.size() - 1))
124 template<
class AllocatorType>
127 if (
T *
Ptr = pop(Cap.getBucket()))
138 push(Cap.getBucket(),
Ptr);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
#define __asan_poison_memory_region(p, size)
#define __asan_unpoison_memory_region(p, size)
#define __msan_allocated_memory(p, size)
This file defines the SmallVector class.
static unsigned getSize(unsigned Kind)
Capacity getNext() const
Get the next larger capacity.
size_t getSize() const
Get the number of elements in an array with this capacity.
static Capacity get(size_t N)
Get the capacity of an array that can hold at least N elements.
unsigned getBucket() const
Get the bucket number for this capacity.
Recycle small arrays allocated from a BumpPtrAllocator.
T * allocate(Capacity Cap, AllocatorType &Allocator)
Allocate an array of at least the requested capacity.
void clear(BumpPtrAllocator &)
Special case for BumpPtrAllocator which has an empty Deallocate() function.
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_64_Ceil(uint64_t Value)
Return the ceil log base 2 of the specified value, 64 if the value is zero.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
FunctionAddr VTableAddr Next
This struct is a compact representation of a valid (non-zero power of two) alignment.