12#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SEEDCOLLECTOR_H
13#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SEEDCOLLECTOR_H
72 assert(It !=
end() &&
"Instruction not in the bundle!");
73 auto Idx = It -
begin();
77 void setUsed(
unsigned ElementIdx,
unsigned Sz = 1,
bool VerifyUnused =
true) {
80 for (
unsigned Idx :
seq<unsigned>(ElementIdx, ElementIdx + Sz)) {
82 "Already marked as used!");
89 bool isUsed(
unsigned Element)
const {
100 getSlice(
unsigned StartIdx,
unsigned MaxVecRegBits,
bool ForcePowOf2);
118 OS.
indent(2) << ElmIdx <<
". ";
140 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
141 std::is_same<LoadOrStoreT, StoreInst>::value,
142 "Expected LoadInst or StoreInst!");
144 "Expected Load or Store instructions!");
152 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
153 std::is_same<LoadOrStoreT, StoreInst>::value,
154 "Expected LoadInst or StoreInst!");
179 using KeyT = std::tuple<Value *, Type *, Instruction::Opcode>;
194 template <
typename LoadOrStoreT>
195 KeyT getKey(LoadOrStoreT *LSI,
bool AllowDiffTypes)
const;
201 BundleMapT *Map =
nullptr;
233 : Map(&Map), MapIt(MapIt), Vec(Vec), VecIdx(VecIdx) {}
235 assert(Vec !=
nullptr &&
"Already at end!");
236 return *(*Vec)[VecIdx];
240 while (Vec && VecIdx < Vec->
size() && this->
operator*().allUsed())
246 if (VecIdx >= Vec->size()) {
247 assert(MapIt != Map->end() &&
"Already at end!");
250 if (MapIt != Map->end())
251 Vec = &MapIt->second;
265 assert(Map ==
Other.Map &&
"Iterator of different objects!");
266 return MapIt ==
Other.MapIt && VecIdx ==
Other.VecIdx;
271 template <
typename LoadOrStoreT>
272 void insert(LoadOrStoreT *LSI,
bool AllowDiffTypes);
281 iterator(Bundles, Bundles.begin(), &Bundles.begin()->second, 0);
286 unsigned size()
const {
return Bundles.size(); }
307 unsigned totalNumSeedGroups()
const {
308 return StoreSeeds.size() + LoadSeeds.size();
313 bool CollectStores,
bool CollectLoads,
314 bool AllowDiffTypes =
false);
318 return {StoreSeeds.begin(), StoreSeeds.end()};
321 return {LoadSeeds.begin(), LoadSeeds.end()};
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
#define LLVM_TEMPLATE_ABI
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An instruction for reading from memory.
This class implements a map that also provides access to all stored values in a deterministic order.
typename SmallVector< std::pair< KeyT, ValT >, 0 >::iterator iterator
typename SmallVector< std::pair< KeyT, ValT >, 0 >::const_iterator const_iterator
The main scalar evolution driver.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
An ID for a registered callback.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Specialization of SeedBundle for memory access instructions.
MemSeedBundle(SmallVector< Instruction * > &&SV, ScalarEvolution &SE)
void insert(sandboxir::Instruction *I, ScalarEvolution &SE) override
MemSeedBundle(LoadOrStoreT *MemI)
A set of candidate Instructions for vectorizing together.
SeedBundle & operator=(const SeedBundle &)=delete
SmallVector< Instruction * >::iterator iterator
bool isUsed(unsigned Element) const
\Returns whether or not Element has been used.
SmallVector< Instruction * > Seeds
void setUsed(unsigned ElementIdx, unsigned Sz=1, bool VerifyUnused=true)
LLVM_ABI ArrayRef< Instruction * > getSlice(unsigned StartIdx, unsigned MaxVecRegBits, bool ForcePowOf2)
\Returns a slice of seed elements, starting at the element StartIdx, with a total size <= MaxVecRegBi...
void insertAt(iterator Pos, Instruction *I)
Insert I into position P.
unsigned getNumUnusedBits() const
const_iterator begin() const
unsigned NumUnusedBits
Tracks the remaining bits available to vectorize.
SeedBundle(const SeedBundle &)=delete
No need to allow copies.
void setUsed(Instruction *I)
Marks instruction I "used" within the bundle.
SeedBundle(SmallVector< Instruction * > &&L)
virtual void insert(Instruction *I, ScalarEvolution &SE)=0
SeedBundle(Instruction *I)
Initialize a bundle with I.
unsigned getFirstUnusedElementIdx() const
std::size_t size() const
\Returns the number of seed elements in the bundle.
SmallVector< Instruction * >::const_iterator const_iterator
Instruction * operator[](unsigned Idx) const
BitVector UsedLanes
The lanes that we have already vectorized.
const_iterator end() const
unsigned UsedLaneCount
Tracks used lanes for constant-time accessor.
void dump(raw_ostream &OS) const
LLVM_DUMP_METHOD void dump() const
iterator_range< SeedContainer::iterator > getLoadSeeds()
LLVM_ABI SeedCollector(BasicBlock *BB, ScalarEvolution &SE, bool CollectStores, bool CollectLoads, bool AllowDiffTypes=false)
iterator_range< SeedContainer::iterator > getStoreSeeds()
bool operator==(const iterator &Other) const
iterator(BundleMapT &Map, BundleMapT::iterator MapIt, ValT *Vec, int VecIdx)
Iterates over the Map of SeedBundle Vectors, starting at MapIt, and Vec at VecIdx,...
std::ptrdiff_t difference_type
std::input_iterator_tag iterator_category
bool operator!=(const iterator &Other) const
Class to conveniently track Seeds within SeedBundles.
void print(raw_ostream &OS) const
bool erase(const KeyT &Key)
void insert(LoadOrStoreT *LSI, bool AllowDiffTypes)
SeedContainer(ScalarEvolution &SE)
BundleMapT::const_iterator const_iterator
LLVM_DUMP_METHOD void dump() const
LLVM_ABI bool erase(Instruction *I)
static bool atLowerAddress(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns true if I0 accesses a memory location lower than I1.
static unsigned getNumBits(Type *Ty, const DataLayout &DL)
\Returns the number of bits of Ty.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
MemSeedBundle< sandboxir::LoadInst > LoadSeedBundle
MemSeedBundle< sandboxir::StoreInst > StoreSeedBundle
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
Implement std::hash so that hash_code can be used in STL containers.