LLVM  8.0.1
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. More...
 
void clear (BumpPtrAllocator &)
 Special case for BumpPtrAllocator which has an empty Deallocate() function. More...
 
template<class AllocatorType >
Tallocate (Capacity Cap, AllocatorType &Allocator)
 Allocate an array of at least the requested capacity. More...
 
void deallocate (Capacity Cap, T *Ptr)
 Deallocate an array with the specified Capacity. More...
 

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 29 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 96 of file ArrayRecycler.h.

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 126 of file ArrayRecycler.h.

Referenced by llvm::MachineFunction::allocateOperandArray(), and llvm::GVNExpression::BasicExpression::allocateOperands().

◆ 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 105 of file ArrayRecycler.h.

Referenced by llvm::GVNExpression::Expression::dump(), and llvm::MachineFunction::~MachineFunction().

◆ 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 116 of file ArrayRecycler.h.

◆ 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 138 of file ArrayRecycler.h.

Referenced by llvm::MachineFunction::deallocateOperandArray(), and llvm::GVNExpression::BasicExpression::deallocateOperands().


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