12#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SEEDCOLLECTOR_H
13#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SEEDCOLLECTOR_H
60 for (
unsigned ElmIdx : seq<unsigned>(0,
Seeds.size()))
71 assert(It !=
end() &&
"Instruction not in the bundle!");
76 void setUsed(
unsigned ElementIdx,
unsigned Sz = 1,
bool VerifyUnused =
true) {
79 for (
unsigned Idx : seq<unsigned>(ElementIdx, ElementIdx + Sz)) {
81 "Already marked as used!");
88 bool isUsed(
unsigned Element)
const {
99 getSlice(
unsigned StartIdx,
unsigned MaxVecRegBits,
bool ForcePowOf2);
117 OS.indent(2) << ElmIdx <<
". ";
139 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
140 std::is_same<LoadOrStoreT, StoreInst>::value,
141 "Expected LoadInst or StoreInst!");
143 "Expected Load or Store instructions!");
146 cast<LoadOrStoreT>(I1), SE);
151 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
152 std::is_same<LoadOrStoreT, StoreInst>::value,
153 "Expected LoadInst or StoreInst!");
154 assert(isa<LoadOrStoreT>(MemI) &&
"Expected Load or Store!");
157 assert(isa<LoadOrStoreT>(
I) &&
"Expected a Store or a Load!");
160 cast<LoadOrStoreT>(I1), SE);
178 using KeyT = std::tuple<Value *, Type *, Instruction::Opcode>;
193 template <
typename LoadOrStoreT> KeyT getKey(LoadOrStoreT *LSI)
const;
231 : Map(&Map), MapIt(MapIt), Vec(Vec), VecIdx(VecIdx) {}
233 assert(Vec !=
nullptr &&
"Already at end!");
234 return *(*Vec)[VecIdx];
238 while (Vec && VecIdx < Vec->
size() && this->
operator*().allUsed())
244 if (VecIdx >= Vec->
size()) {
245 assert(MapIt != Map->end() &&
"Already at end!");
248 if (MapIt != Map->end())
249 Vec = &MapIt->second;
263 assert(Map ==
Other.Map &&
"Iterator of different objects!");
264 return MapIt ==
Other.MapIt && VecIdx ==
Other.VecIdx;
269 template <
typename LoadOrStoreT>
void insert(LoadOrStoreT *LSI);
298 unsigned totalNumSeedGroups()
const {
299 return StoreSeeds.
size() + LoadSeeds.
size();
307 return {StoreSeeds.
begin(), StoreSeeds.
end()};
310 return {LoadSeeds.
begin(), LoadSeeds.
end()};
This file implements the BitVector class.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool test(unsigned Idx) const
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
size_type size() const
size - Returns the number of bits in this bitvector.
typename VectorType::iterator iterator
VectorType::iterator erase(typename VectorType::iterator Iterator)
Remove the element given by Iterator.
typename VectorType::const_iterator const_iterator
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
The main scalar evolution driver.
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 class implements an extremely fast bulk output stream that can only output to a stream.
Contains a list of sandboxir::Instruction's.
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
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)
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.
MutableArrayRef< Instruction * > getSlice(unsigned StartIdx, unsigned MaxVecRegBits, bool ForcePowOf2)
\Returns a slice of seed elements, starting at the element StartIdx, with a total size <= MaxVecRegBi...
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.
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()
iterator_range< SeedContainer::iterator > getStoreSeeds()
void print(raw_ostream &OS) const
LLVM_DUMP_METHOD void dump() const
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
void insert(LoadOrStoreT *LSI)
bool erase(const KeyT &Key)
SeedContainer(ScalarEvolution &SE)
BundleMapT::const_iterator const_iterator
LLVM_DUMP_METHOD void dump() const
bool erase(Instruction *I)
static unsigned getNumBits(Value *V, const DataLayout &DL)
\Returns the number of bits required to represent the operands or return value of V in DL.
static bool atLowerAddress(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns true if I0 accesses a memory location lower than I1.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.