Go to the documentation of this file.
28 #ifndef LLVM_ADT_GENERICCYCLEINFO_H
29 #define LLVM_ADT_GENERICCYCLEINFO_H
50 using BlockT =
typename ContextT::BlockT;
66 std::vector<std::unique_ptr<GenericCycle>> Children;
70 std::vector<BlockT *> Blocks;
84 ParentCycle =
nullptr;
87 void appendEntry(
BlockT *Block) { Entries.push_back(Block); }
88 void appendBlock(
BlockT *Block) { Blocks.push_back(Block); }
200 for (
auto *Entry : Entries) {
204 Out << Ctx.print(Entry);
213 for (
auto *Block : Blocks) {
217 Out <<
' ' << Ctx.print(Block);
224 template <
typename ContextT>
class GenericCycleInfo {
226 using BlockT =
typename ContextT::BlockT;
242 std::vector<std::unique_ptr<CycleT>> TopLevelCycles;
280 const_toplevel_iterator_base> {
293 return const_toplevel_iterator{TopLevelCycles.begin()};
296 return const_toplevel_iterator{TopLevelCycles.end()};
301 const_toplevel_iterator{TopLevelCycles.end()});
316 return Ref->child_begin();
341 template <
typename BlockT>
345 template <
typename BlockT>
352 #endif // LLVM_ADT_GENERICCYCLEINFO_H
CycleT * getTopLevelParentCycle(const BlockT *Block) const
const_child_iterator child_begin() const
BlockT * getHeader() const
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
typename SSAContext ::FunctionT FunctionT
const_toplevel_iterator toplevel_begin() const
iterator_range< const_block_iterator > blocks() const
const GenericCycle * getParentCycle() const
const_toplevel_iterator()=default
static NodeRef getEntryNode(NodeRef Graph)
Printable printEntries(const ContextT &Ctx) const
const_child_iterator_base I
unsigned getCycleDepth(const BlockT *Block) const
get the depth for the cycle which containing a given block.
CRTP base class for adapting an iterator to a different type.
iterator_range< const_entry_iterator > entries() const
bool validateTree() const
Methods for debug and self-test.
const_child_iterator()=default
const_toplevel_iterator(const_toplevel_iterator_base I)
const const_child_iterator_base & wrapped() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void clear(coro::Shape &Shape)
BlockT * getCyclePreheader() const
Return the preheader block for this cycle.
void moveToNewParent(CycleT *NewParent, CycleT *Child)
Move Child to NewParent by manipulating Children vectors.
@ Ref
The access may reference the value stored in memory.
GenericCycle< ContextT > CycleT
(vector float) vec_cmpeq(*A, *B) C
typename std::vector< std::unique_ptr< GenericCycle > >::const_iterator const_child_iterator_base
Iteration over child cycles.
const_child_iterator child_end() const
static ChildIteratorType child_begin(NodeRef Ref)
GenericCycleInfo & operator=(GenericCycleInfo &&)=default
typename SmallVectorImpl< BlockT * >::const_iterator const_entry_iterator
Iteration over entry blocks.
const_block_iterator block_begin() const
into llvm powi allowing the code generator to produce balanced multiplication trees First
GenericCycle * operator*() const
A possibly irreducible generalization of a Loop.
This class implements an extremely fast bulk output stream that can only output to a stream.
const const_child_iterator_base & wrapped()
const_block_iterator block_end() const
size_t getNumEntries() const
Helper class for computing cycle information.
void compute(FunctionT &F)
Compute the cycle info for a function.
unsigned getDepth() const
const ContextT & getSSAContext() const
CycleT * getCycle(const BlockT *Block) const
Find the innermost cycle containing a given block.
const_child_iterator(const_child_iterator_base I)
size_t getNumBlocks() const
const SmallVectorImpl< BlockT * > & getEntries() const
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
const_toplevel_iterator toplevel_end() const
const const_toplevel_iterator_base & wrapped()
CycleT * operator*() const
typename ContextT::FunctionT FunctionT
Cycle information for a function.
FunctionT * getFunction() const
void getExitBlocks(SmallVectorImpl< BlockT * > &TmpStorage) const
Return all of the successor blocks of this cycle.
typename std::vector< BlockT * >::const_iterator const_block_iterator
Iteration over blocks in the cycle (including entry blocks).
static ChildIteratorType child_end(NodeRef Ref)
GenericCycleInfo()=default
ChildIteratorT nodes_iterator
iterator_range< const_toplevel_iterator > toplevel_cycles() const
void print(raw_ostream &Out) const
Print the cycle info.
bool isEntry(BlockT *Block) const
Return whether Block is an entry block of the cycle.
bool isReducible() const
Whether the cycle is a natural loop.
BlockT * getCyclePredecessor() const
If the cycle has exactly one entry with exactly one predecessor, return it, otherwise return nullptr.
Printable print(const ContextT &Ctx) const
void clear()
Reset the object to its initial state.
size_t getNumChildren() const
iterator_range< const_child_iterator > children() const
typename SSAContext ::BlockT BlockT
Simple wrapper around std::function<void(raw_ostream&)>.
typename ContextT::BlockT BlockT
A range adaptor for a pair of iterators.
GenericCycle * getParentCycle()
typename std::vector< std::unique_ptr< CycleT > >::const_iterator const_toplevel_iterator_base
Iteration over top-level cycles.
GraphTraits for iterating over a sub-tree of the CycleT tree.
bool contains(const BlockT *Block) const
Return whether Block is contained in the cycle.