LLVM 19.0.0git
Classes | Public Member Functions | List of all members
llvm::ArrayRecycler< T, Align > Class Template Reference

Recycle small arrays allocated from a BumpPtrAllocator. More...

#include "llvm/Support/ArrayRecycler.h"

Inheritance diagram for llvm::ArrayRecycler< T, Align >:
Inheritance graph
[legend]

Classes

class  Capacity
 The size of an allocated array is represented by a Capacity instance. More...
 

Public Member Functions

 ~ArrayRecycler ()
 
template<class AllocatorType >
void clear (AllocatorType &Allocator)
 Release all the tracked allocations to the allocator.
 
void clear (BumpPtrAllocator &)
 Special case for BumpPtrAllocator which has an empty Deallocate() function.
 
template<class AllocatorType >
Tallocate (Capacity Cap, AllocatorType &Allocator)
 Allocate an array of at least the requested capacity.
 
void deallocate (Capacity Cap, T *Ptr)
 Deallocate an array with the specified Capacity.
 

Detailed Description

template<class T, size_t Align = alignof(T)>
class llvm::ArrayRecycler< T, Align >

Recycle small arrays allocated from a BumpPtrAllocator.

Arrays are allocated in a small number of fixed sizes. For each supported array size, the ArrayRecycler keeps a free list of available arrays.

Definition at line 28 of file ArrayRecycler.h.

Constructor & Destructor Documentation

◆ ~ArrayRecycler()

template<class T , size_t Align = alignof(T)>
llvm::ArrayRecycler< T, Align >::~ArrayRecycler ( )
inline

Definition at line 95 of file ArrayRecycler.h.

References assert(), and llvm::SmallVectorBase< Size_T >::empty().

Member Function Documentation

◆ allocate()

template<class T , size_t Align = alignof(T)>
template<class AllocatorType >
T * llvm::ArrayRecycler< T, Align >::allocate ( Capacity  Cap,
AllocatorType &  Allocator 
)
inline

Allocate an array of at least the requested capacity.

Return an existing recycled array, or allocate one from Allocator if none are available for recycling.

Definition at line 125 of file ArrayRecycler.h.

References Allocator, llvm::ArrayRecycler< T, Align >::Capacity::getBucket(), llvm::ArrayRecycler< T, Align >::Capacity::getSize(), and Ptr.

Referenced by llvm::MachineFunction::allocateOperandArray().

◆ clear() [1/2]

template<class T , size_t Align = alignof(T)>
template<class AllocatorType >
void llvm::ArrayRecycler< T, Align >::clear ( AllocatorType &  Allocator)
inline

Release all the tracked allocations to the allocator.

The recycler must be free of any tracked allocations before being deleted.

Definition at line 104 of file ArrayRecycler.h.

References Allocator, llvm::SmallVectorBase< Size_T >::empty(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), Ptr, and llvm::SmallVectorBase< Size_T >::size().

◆ clear() [2/2]

template<class T , size_t Align = alignof(T)>
void llvm::ArrayRecycler< T, Align >::clear ( BumpPtrAllocator )
inline

Special case for BumpPtrAllocator which has an empty Deallocate() function.

There is no need to traverse the free lists, pulling all the objects into cache.

Definition at line 115 of file ArrayRecycler.h.

References llvm::SmallVectorImpl< T >::clear().

◆ deallocate()

template<class T , size_t Align = alignof(T)>
void llvm::ArrayRecycler< T, Align >::deallocate ( Capacity  Cap,
T Ptr 
)
inline

Deallocate an array with the specified Capacity.

Cap must be the same capacity that was given to allocate().

Definition at line 137 of file ArrayRecycler.h.

References llvm::ArrayRecycler< T, Align >::Capacity::getBucket(), and Ptr.

Referenced by llvm::MachineFunction::deallocateOperandArray().


The documentation for this class was generated from the following file: