12#ifndef LLVM_ADT_PAGEDVECTOR_H
13#define LLVM_ADT_PAGEDVECTOR_H
43 static_assert(
PageSize > 1,
"PageSize must be greater than 0. Most likely "
44 "you want it to be greater than 16.");
63 assert(
A &&
"Allocator cannot be nullptr");
91 std::uninitialized_value_construct_n(PagePtr,
PageSize);
130 size_t NewLastPage = (NewSize - 1) /
PageSize;
131 if (NewSize <
Size) {
132 for (
size_t I = NewLastPage + 1,
N = PageToDataPtrs.
size();
I <
N; ++
I) {
133 T *Page = PageToDataPtrs[
I];
138 Allocator.getPointer()->Deallocate(Page);
143 PageToDataPtrs.
resize(NewLastPage + 1);
152 for (
T *Page : PageToDataPtrs) {
158 Allocator.getPointer()->Deallocate(Page);
163 PageToDataPtrs.clear();
180 : PV(PV), ElementIdx(ElementIdx) {}
189 while (ElementIdx < PV->
Size &&
190 !PV->PageToDataPtrs[ElementIdx /
PageSize])
192 if (ElementIdx > PV->Size)
193 ElementIdx = PV->Size;
208 T *PagePtr = PV->PageToDataPtrs[ElementIdx /
PageSize];
209 return PagePtr[ElementIdx %
PageSize];
218 [[nodiscard]]
size_t getIndex()
const {
return ElementIdx; }
228 ElementIdx == PV->Size ||
229 (ElementIdx < PV->
Size && PV->PageToDataPtrs[ElementIdx /
PageSize]));
232 bool equals(
const MaterializedIterator &
Other)
const {
236 return ElementIdx ==
Other.ElementIdx;
247 for (
size_t ElementIdx = 0; ElementIdx <
Size; ElementIdx +=
PageSize)
248 if (PageToDataPtrs[ElementIdx /
PageSize])
260 return {materialized_begin(), materialized_end()};
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static void clear(coro::Shape &Shape)
std::optional< std::vector< StOtherPiece > > Other
static cl::opt< int > PageSize("imp-null-check-page-size", cl::desc("The page size of the target in bytes"), cl::init(4096), cl::Hidden)
This file defines the PointerIntPair class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Allocate memory in an ever growing pool, as if by bump-pointer.
Iterator on all the elements of the vector which have actually being constructed.
MaterializedIterator & operator++()
Pre-increment operator.
std::ptrdiff_t difference_type
T const & operator*() const
std::forward_iterator_tag iterator_category
friend bool operator!=(const MaterializedIterator &LHS, const MaterializedIterator &RHS)
MaterializedIterator(PagedVector const *PV, size_t ElementIdx)
MaterializedIterator operator++(int)
friend bool operator==(const MaterializedIterator &LHS, const MaterializedIterator &RHS)
Equality operator.
A vector that allocates memory in pages.
MaterializedIterator materialized_end() const
PagedVector(BumpPtrAllocator *A)
PagedVector & operator=(const PagedVector &)=delete
size_t size() const
Return the size of the vector.
PagedVector & operator=(PagedVector &&)=delete
T & operator[](size_t Index) const
Look up an element at position Index.
MaterializedIterator materialized_begin() const
Iterators over the materialized elements of the vector.
void resize(size_t NewSize)
Resize the vector.
PagedVector(const PagedVector &)=delete
PagedVector()
Default constructor.
PagedVector(PagedVector &&)=delete
llvm::iterator_range< MaterializedIterator > materialized() const
size_t capacity() const
Return the capacity of the vector.
void clear()
Clear the vector, i.e.
PointerIntPair - This class implements a pair of a pointer and small integer.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.