Go to the documentation of this file.
15 #ifndef LLVM_ADT_SMALLPTRSET_H
16 #define LLVM_ADT_SMALLPTRSET_H
26 #include <initializer_list>
78 assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
79 "Initial size must be a power of two!");
101 return shrink_and_clear();
116 return reinterpret_cast<void*
>(-1);
126 std::pair<const void *const *, bool>
insert_imp(
const void *Ptr) {
129 const void **LastTombstone =
nullptr;
132 const void *
Value = *APtr;
134 return std::make_pair(APtr,
false);
136 LastTombstone = APtr;
140 if (LastTombstone !=
nullptr) {
141 *LastTombstone = Ptr;
144 return std::make_pair(LastTombstone,
true);
155 return insert_imp_big(Ptr);
167 const void **Loc =
const_cast<const void **
>(
P);
168 assert(*Loc == Ptr &&
"broken find!");
177 const void *
const *
find_imp(
const void * Ptr)
const {
188 auto *Bucket = FindBucketFor(Ptr);
197 std::pair<const void *const *, bool> insert_imp_big(
const void *Ptr);
199 const void *
const *FindBucketFor(
const void *Ptr)
const;
200 void shrink_and_clear();
203 void Grow(
unsigned NewSize);
266 template <
typename PtrTy>
288 return PtrTraits::getFromVoidPointer(
const_cast<void *
>(
Bucket[-1]));
291 return PtrTraits::getFromVoidPointer(
const_cast<void*
>(*
Bucket));
320 template<
unsigned N,
bool isPowerTwo>
334 struct RoundUpToPowerOfTwo {
343 template <
typename PtrType>
365 std::pair<iterator, bool>
insert(PtrType Ptr) {
366 auto p =
insert_imp(PtrTraits::getAsVoidPointer(Ptr));
367 return std::make_pair(makeIterator(
p.first),
p.second);
380 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
387 return makeIterator(
find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)));
393 template <
typename IterT>
399 void insert(std::initializer_list<PtrType> IL) {
400 insert(IL.begin(), IL.end());
412 iterator makeIterator(
const void *
const *
P)
const {
423 template <
typename PtrType>
426 if (
LHS.size() !=
RHS.size())
429 for (
const auto *KV :
LHS)
439 template <
typename PtrType>
449 template<
class PtrType,
unsigned SmallSize>
454 static_assert(SmallSize <= 32,
"SmallSize should be small");
461 const void *SmallStorage[SmallSizePowTwo];
469 template<
typename It>
475 :
BaseT(SmallStorage, SmallSizePowTwo) {
476 this->
insert(IL.begin(), IL.end());
496 this->
insert(IL.begin(), IL.end());
511 template<
class T,
unsigned N>
518 #endif // LLVM_ADT_SMALLPTRSET_H
std::pair< const void *const *, bool > insert_imp(const void *Ptr)
insert_imp - This returns true if the pointer was new to the set, false if it was already in the set.
SmallPtrSetImplBase & operator=(const SmallPtrSetImplBase &)=delete
void swap(SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
This is an optimization pass for GlobalISel generic memory operations.
SmallPtrSet< PtrType, SmallSize > & operator=(const SmallPtrSet< PtrType, SmallSize > &RHS)
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false.
unsigned NumNonEmpty
Number of elements in CurArray that contain a value or are a tombstone.
SmallPtrSetIteratorImpl - This is the common base class shared between all instances of SmallPtrSetIt...
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s,...
void swap(SmallPtrSet< PtrType, SmallSize > &RHS)
swap - Swaps the elements of two sets.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
SmallPtrSet(std::initializer_list< PtrType > IL)
bool shouldReverseIterate()
bool operator==(const SmallPtrSetIteratorImpl &RHS) const
bool erase_imp(const void *Ptr)
erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return fa...
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
bool operator!=(uint64_t V1, const APInt &V2)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same we currently get code like const It could be done with a smaller encoding like local tee $pop5 local $pop6 WebAssembly registers are implicitly initialized to zero Explicit zeroing is therefore often redundant and could be optimized away Small indices may use smaller encodings than large indices WebAssemblyRegColoring and or WebAssemblyRegRenumbering should sort registers according to their usage frequency to maximize the usage of smaller encodings Many cases of irreducible control flow could be transformed more optimally than via the transform in WebAssemblyFixIrreducibleControlFlow cpp It may also be worthwhile to do transforms before register particularly when duplicating to allow register coloring to be aware of the duplication WebAssemblyRegStackify could use AliasAnalysis to reorder loads and stores more aggressively WebAssemblyRegStackify is currently a greedy algorithm This means that
alloca< 16 x float >, align 16 %tmp2=alloca< 16 x float >, align 16 store< 16 x float > %A,< 16 x float > *%tmp %s=bitcast< 16 x float > *%tmp to i8 *%s2=bitcast< 16 x float > *%tmp2 to i8 *call void @llvm.memcpy.i64(i8 *%s, i8 *%s2, i64 64, i32 16) %R=load< 16 x float > *%tmp2 ret< 16 x float > %R } declare void @llvm.memcpy.i64(i8 *nocapture, i8 *nocapture, i64, i32) nounwind which compiles to:_foo:subl $140, %esp movaps %xmm3, 112(%esp) movaps %xmm2, 96(%esp) movaps %xmm1, 80(%esp) movaps %xmm0, 64(%esp) movl 60(%esp), %eax movl %eax, 124(%esp) movl 56(%esp), %eax movl %eax, 120(%esp) movl 52(%esp), %eax< many many more 32-bit copies > movaps(%esp), %xmm0 movaps 16(%esp), %xmm1 movaps 32(%esp), %xmm2 movaps 48(%esp), %xmm3 addl $140, %esp ret On Nehalem, it may even be cheaper to just use movups when unaligned than to fall back to lower-granularity chunks. Implement processor-specific optimizations for parity with GCC on these processors. GCC does two optimizations:1. ix86_pad_returns inserts a noop before ret instructions if immediately preceded by a conditional branch or is the target of a jump. 2. ix86_avoid_jump_misspredicts inserts noops in cases where a 16-byte block of code contains more than 3 branches. The first one is done for all AMDs, Core2, and "Generic" The second one is done for:Atom, Pentium Pro, all AMDs, Pentium 4, Nocona, Core 2, and "Generic" Testcase:int x(int a) { return(a &0xf0)> >4 tmp
the resulting code requires compare and branches when and if * p
RoundUpToPowerOfTwo - This is a helper template that rounds N up to the next power of two (which mean...
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const PtrTy operator*() const
SmallPtrSetIterator(const void *const *BP, const void *const *E, const DebugEpochBase &Epoch)
unsigned NumTombstones
Number of tombstones in CurArray.
const void ** EndPointer() const
SmallPtrSetIterator< PtrType > iterator
const void *const * Bucket
iterator find(ConstPtrType Ptr) const
void AdvanceIfNotValid()
AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket that is.
SmallPtrSetIterator & operator++()
std::ptrdiff_t difference_type
bool isHandleInSync() const
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
const void ** CurArray
CurArray - This is the current set of buckets.
bool operator!=(const SmallPtrSetIteratorImpl &RHS) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
static void * getTombstoneMarker()
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool operator==(uint64_t V1, const APInt &V2)
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static void * getEmptyMarker()
void insert(std::initializer_list< PtrType > IL)
SmallPtrSetIterator operator++(int)
SmallPtrSet< PtrType, SmallSize > & operator=(std::initializer_list< PtrType > IL)
SmallPtrSet(const SmallPtrSet &that)
SmallPtrSetImpl(const SmallPtrSetImpl &)=delete
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
const void ** SmallArray
SmallArray - Points to a fixed size set of buckets, used in 'small mode'.
SmallPtrSet(SmallPtrSet &&that)
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS)
LLVM_NODISCARD bool empty() const
void insert(IterT I, IterT E)
std::forward_iterator_tag iterator_category
iterator insert(iterator, PtrType Ptr)
Insert the given pointer with an iterator hint that is ignored.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
const void *const * find_imp(const void *Ptr) const
Returns the raw pointer needed to construct an iterator.
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
bool contains(ConstPtrType Ptr) const
RoundUpToPowerOfTwoH - If N is not a power of two, increase it.
SmallPtrSetIteratorImpl(const void *const *BP, const void *const *E)
LLVM Value Representation.
void CopyFrom(const SmallPtrSetImplBase &RHS)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.