PandA-2024.02
Public Member Functions | Data Fields | Private Member Functions | Private Attributes | Static Private Attributes | Friends
Loop Class Reference

#include <loop.hpp>

Collaboration diagram for Loop:
Collaboration graph
[legend]

Public Member Functions

 Loop (const BBGraphRef g)
 Constructor for empty loop (used for irreducible) More...
 
 Loop (const BBGraphRef _bb_graph, vertex _header_block)
 Constructor for reducible loop. More...
 
unsigned int GetId () const
 returns the loop id More...
 
bool is_innermost () const
 tells if the loop is innermost More...
 
bool IsReducible () const
 tells if the loop is reducible More...
 
vertex GetHeader () const
 returns loop header More...
 
CustomOrderedSet< vertexget_entries () const
 return the alternative entries of a loop More...
 
void add_entry (vertex v)
 add an entry of the loop More...
 
const LoopRef Parent () const
 returns the parent loop More...
 
void add_block (vertex block)
 adds a block to this loop More...
 
size_t num_blocks () const
 returns the number of basic blocks belonging to this loop More...
 
const CustomUnorderedSet< vertex > & get_blocks () const
 returns the blocks More...
 
size_t num_exits () const
 
std::list< vertex >::const_iterator exit_block_iter_begin () const
 
std::list< vertex >::const_iterator exit_block_iter_end () const
 
size_t num_landing_pads () const
 
const CustomUnorderedSet< vertexGetLandingPadBlocks () const
 Return the landing pads of the loops. More...
 
vertex primary_landing_pad () const
 
void SetParent (LoopRef parent)
 Sets parent for this loop. More...
 
void AddChild (LoopRef child)
 Adds a child loop. More...
 
const CustomOrderedSet< LoopConstRef > & GetChildren () const
 Returns the children of this loop in the loop forest. More...
 
void get_recursively_bb (CustomUnorderedSet< vertex > &ret) const
 Returns the basic blocks which belong to this loop and to loop nested in this loop. More...
 
OpVertexSet GetRecursivelyOps (const OpGraphConstRef op_graph) const
 Returns the operation which belongs to this loop or to a nested loop. More...
 
const std::map< vertex, CustomUnorderedSet< vertex > > & get_exit_landing_association () const
 Returns the map exit_landing_association. More...
 
void add_sp_back_edge (vertex vs, vertex vd)
 add a spanning tree back edge More...
 
bool is_sp_back_edge (vertex vs, vertex vd) const
 check if a pair of vertex is a spanning tree back edge for the loop More...
 
CustomOrderedSet< std::pair< vertex, vertex > > get_sp_back_edges () const
 return the list of spanning tree back edges More...
 

Data Fields

unsigned int depth
 Nesting depth of this loop. More...
 
int loop_type
 loop type More...
 
long long footprint_size
 loop memory footprint More...
 
long long instruction_size
 loop instruction footprint More...
 
vertex body_start
 body start basic block (at the moment defined only for SIMPLE_LOOP & WHILE_LOOP) More...
 
unsigned int main_iv
 the main induction variable of countable loop; More...
 
tree_nodeRef init
 value of the initialization of the induction variable More...
 
unsigned int init_gimple_id
 The index of the gimple tree node containing the initialization of the induction variable; right operand can be different from initialization_tree_node_id because of assignments chain. More...
 
unsigned int inc_id
 The node id containing the increment statement. More...
 
integer_cst_t increment
 Increment of induction variable. More...
 
tree_nodeRef increment_tn
 Increment of induction variable. More...
 
integer_cst_t lower_bound
 Initial value of induction variable defined when loop_type is COUNTABLE_LOOP. More...
 
integer_cst_t upper_bound
 Final value of induction variable defined when loop_type is COUNTABLE_LOOP. More...
 
tree_nodeRef upper_bound_tn
 Final value of induction variable. More...
 
bool close_interval
 flag for induction variable close interval defined when loop_type is COUNTABLE_LOOP More...
 

Private Member Functions

void ComputeLandingPadExits ()
 compute landing pad exits More...
 

Private Attributes

const BBGraphRef g
 The basic block control flow graph. More...
 
bool is_innermost_loop
 tells if there aren't loop nested in this More...
 
refcount< Loopparent_loop
 Parent loop. More...
 
CustomOrderedSet< LoopConstRef > children
 Child loops. More...
 
CustomUnorderedSet< vertexblocks
 Blocks which belong to this loop. More...
 
std::list< vertexexits
 exit blocks for this loop More...
 
CustomUnorderedSet< vertexlanding_pads
 landing_pads for this loop More...
 
vertex primary_landing_pad_block
 ??? More...
 
vertex header_block
 the header of the loop More...
 
CustomOrderedSet< vertexalternative_entries
 in case the loop is irreducible the loop has multiple entries while for reducible loops the entry is just one More...
 
unsigned int loop_id
 the id of the loop More...
 
std::map< vertex, CustomUnorderedSet< vertex > > exit_landing_association
 Map storing the association between an exit basic block and the corresponding landing pads. More...
 
CustomOrderedSet< std::pair< vertex, vertex > > sp_back_edges
 set of vertex pairs describing a spanning tree back edge for the loop More...
 

Static Private Attributes

static unsigned int curr_unused_irreducible_id = std::numeric_limits<unsigned int>::max()
 used to label irreducible loops More...
 

Friends

class Loops
 Friend definition of loop. More...
 
class add_loop_nop
 Definition of friend class add_loop_nop. More...
 

Detailed Description

Definition at line 153 of file loop.hpp.

Constructor & Destructor Documentation

◆ Loop() [1/2]

Loop::Loop ( const BBGraphRef  g)
explicit

Constructor for empty loop (used for irreducible)

Parameters
gis the basic block control flow grah

Definition at line 63 of file loop.cpp.

◆ Loop() [2/2]

Loop::Loop ( const BBGraphRef  _bb_graph,
vertex  _header_block 
)

Constructor for reducible loop.

Parameters
gis the basic block control flow graph
headeris the header basic block

Definition at line 95 of file loop.cpp.

References add_block(), alternative_entries, BBGraph::CGetBBNodeInfo(), g, and loop_id.

Here is the call graph for this function:

Member Function Documentation

◆ add_block()

void Loop::add_block ( vertex  block)

adds a block to this loop

Parameters
blockis the basic block to be added

Definition at line 282 of file loop.cpp.

References blocks.

Referenced by add_entry(), Loops::DetectReducibleLoop(), Loop(), and Loops::tarjan_scc().

Here is the caller graph for this function:

◆ add_entry()

void Loop::add_entry ( vertex  v)
inline

◆ add_sp_back_edge()

void Loop::add_sp_back_edge ( vertex  vs,
vertex  vd 
)
inline

add a spanning tree back edge

Definition at line 383 of file loop.hpp.

◆ AddChild()

void Loop::AddChild ( LoopRef  child)

Adds a child loop.

Parameters
childis the child loop

Definition at line 287 of file loop.cpp.

References children.

Referenced by add_entry(), Loops::DetectReducibleLoop(), and Loops::tarjan_scc().

Here is the caller graph for this function:

◆ ComputeLandingPadExits()

void Loop::ComputeLandingPadExits ( )
private

compute landing pad exits

Definition at line 249 of file loop.cpp.

References exit_landing_association, exits, g, get_recursively_bb(), landing_pads, and lenet_tvm::target.

Here is the call graph for this function:

◆ exit_block_iter_begin()

std::list< vertex >::const_iterator Loop::exit_block_iter_begin ( ) const

Definition at line 166 of file loop.cpp.

References exits.

Referenced by add_entry(), and Vectorize::DuplicateIncrement().

Here is the caller graph for this function:

◆ exit_block_iter_end()

std::list< vertex >::const_iterator Loop::exit_block_iter_end ( ) const

Definition at line 171 of file loop.cpp.

References exits.

Referenced by add_entry().

Here is the caller graph for this function:

◆ get_blocks()

const CustomUnorderedSet< vertex > & Loop::get_blocks ( ) const

returns the blocks

Returns
the blocks

Definition at line 156 of file loop.cpp.

References blocks.

Referenced by add_entry().

Here is the caller graph for this function:

◆ get_entries()

CustomOrderedSet<vertex> Loop::get_entries ( ) const
inline

return the alternative entries of a loop

Definition at line 292 of file loop.hpp.

References alternative_entries.

◆ get_exit_landing_association()

const std::map< vertex, CustomUnorderedSet< vertex > > & Loop::get_exit_landing_association ( ) const

Returns the map exit_landing_association.

Returns
the map exit_landing_association

Definition at line 317 of file loop.cpp.

References exit_landing_association.

Referenced by add_entry().

Here is the caller graph for this function:

◆ get_recursively_bb()

void Loop::get_recursively_bb ( CustomUnorderedSet< vertex > &  ret) const

Returns the basic blocks which belong to this loop and to loop nested in this loop.

Parameters
retis the returned set of basic block of this loop and of its children

Definition at line 292 of file loop.cpp.

References blocks, and children.

Referenced by add_entry(), ComputeLandingPadExits(), and GetRecursivelyOps().

Here is the caller graph for this function:

◆ get_sp_back_edges()

CustomOrderedSet<std::pair<vertex, vertex> > Loop::get_sp_back_edges ( ) const
inline

return the list of spanning tree back edges

Definition at line 397 of file loop.hpp.

References sp_back_edges.

◆ GetChildren()

const CustomOrderedSet< LoopConstRef > & Loop::GetChildren ( ) const

Returns the children of this loop in the loop forest.

Definition at line 322 of file loop.cpp.

References children.

Referenced by add_entry().

Here is the caller graph for this function:

◆ GetHeader()

vertex Loop::GetHeader ( ) const

returns loop header

Returns
returns loop header

Definition at line 136 of file loop.cpp.

References header_block.

Referenced by Vectorize::DuplicateIncrement().

Here is the caller graph for this function:

◆ GetId()

unsigned int Loop::GetId ( ) const

returns the loop id

Returns
the loop id

Definition at line 131 of file loop.cpp.

References loop_id.

Referenced by Loops::tarjan_scc().

Here is the caller graph for this function:

◆ GetLandingPadBlocks()

const CustomUnorderedSet< vertex > Loop::GetLandingPadBlocks ( ) const

Return the landing pads of the loops.

Parameters
thebasic block landing pads of the loop

Definition at line 181 of file loop.cpp.

References landing_pads.

Referenced by add_entry().

Here is the caller graph for this function:

◆ GetRecursivelyOps()

OpVertexSet Loop::GetRecursivelyOps ( const OpGraphConstRef  op_graph) const

Returns the operation which belongs to this loop or to a nested loop.

Parameters
op_graphis the operation graph
Returns
the contained operations

Definition at line 302 of file loop.cpp.

References BBGraph::CGetBBNodeInfo(), g, get_recursively_bb(), and THROW_ASSERT.

Referenced by add_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_innermost()

bool Loop::is_innermost ( ) const

tells if the loop is innermost

Returns
true if the loop is innermost

Definition at line 141 of file loop.cpp.

References children.

◆ is_sp_back_edge()

bool Loop::is_sp_back_edge ( vertex  vs,
vertex  vd 
) const
inline

check if a pair of vertex is a spanning tree back edge for the loop

Definition at line 390 of file loop.hpp.

◆ IsReducible()

bool Loop::IsReducible ( ) const

tells if the loop is reducible

Returns
true if the loop is reducible

Definition at line 146 of file loop.cpp.

References header_block, and NULL_VERTEX.

Referenced by Vectorize::DuplicateIncrement().

Here is the caller graph for this function:

◆ num_blocks()

size_t Loop::num_blocks ( ) const

returns the number of basic blocks belonging to this loop

Returns
the number of basic blocks

Definition at line 151 of file loop.cpp.

References blocks.

Referenced by add_entry().

Here is the caller graph for this function:

◆ num_exits()

size_t Loop::num_exits ( ) const

Definition at line 161 of file loop.cpp.

References exits.

Referenced by add_entry(), and Vectorize::DuplicateIncrement().

Here is the caller graph for this function:

◆ num_landing_pads()

size_t Loop::num_landing_pads ( ) const

Definition at line 176 of file loop.cpp.

References landing_pads.

Referenced by add_entry().

Here is the caller graph for this function:

◆ Parent()

const LoopRef Loop::Parent ( ) const

returns the parent loop

Returns
the parent loop if this loop is nested, NULL otherwise

Definition at line 239 of file loop.cpp.

References parent_loop.

Referenced by add_entry(), and Loops::DetectReducibleLoop().

Here is the caller graph for this function:

◆ primary_landing_pad()

vertex Loop::primary_landing_pad ( ) const

Definition at line 186 of file loop.cpp.

References g, landing_pads, NULL_VERTEX, and lenet_tvm::target.

Referenced by add_entry().

Here is the caller graph for this function:

◆ SetParent()

void Loop::SetParent ( LoopRef  parent)

Sets parent for this loop.

Parameters
parentis the parent loop

Definition at line 244 of file loop.cpp.

References refcount< T >::get(), and parent_loop.

Referenced by add_entry(), and Loops::DetectReducibleLoop().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ add_loop_nop

friend class add_loop_nop
friend

Definition of friend class add_loop_nop.

Definition at line 403 of file loop.hpp.

◆ Loops

friend class Loops
friend

Friend definition of loop.

Definition at line 157 of file loop.hpp.

Field Documentation

◆ alternative_entries

CustomOrderedSet<vertex> Loop::alternative_entries
private

in case the loop is irreducible the loop has multiple entries while for reducible loops the entry is just one

Definition at line 190 of file loop.hpp.

Referenced by get_entries(), and Loop().

◆ blocks

CustomUnorderedSet<vertex> Loop::blocks
private

Blocks which belong to this loop.

Definition at line 175 of file loop.hpp.

Referenced by add_block(), Loops::BuildZeroLoop(), get_blocks(), get_recursively_bb(), and num_blocks().

◆ body_start

vertex Loop::body_start

body start basic block (at the moment defined only for SIMPLE_LOOP & WHILE_LOOP)

Definition at line 218 of file loop.hpp.

◆ children

CustomOrderedSet<LoopConstRef> Loop::children
private

Child loops.

Definition at line 172 of file loop.hpp.

Referenced by AddChild(), Loops::BuildZeroLoop(), get_recursively_bb(), GetChildren(), and is_innermost().

◆ close_interval

bool Loop::close_interval

flag for induction variable close interval defined when loop_type is COUNTABLE_LOOP

Definition at line 252 of file loop.hpp.

◆ curr_unused_irreducible_id

unsigned int Loop::curr_unused_irreducible_id = std::numeric_limits<unsigned int>::max()
staticprivate

used to label irreducible loops

Header include.

Definition at line 199 of file loop.hpp.

◆ depth

unsigned int Loop::depth

Nesting depth of this loop.

Definition at line 206 of file loop.hpp.

Referenced by Loops::computeDepth().

◆ exit_landing_association

std::map<vertex, CustomUnorderedSet<vertex> > Loop::exit_landing_association
private

Map storing the association between an exit basic block and the corresponding landing pads.

Definition at line 196 of file loop.hpp.

Referenced by ComputeLandingPadExits(), and get_exit_landing_association().

◆ exits

std::list<vertex> Loop::exits
private

exit blocks for this loop

Definition at line 178 of file loop.hpp.

Referenced by ComputeLandingPadExits(), exit_block_iter_begin(), exit_block_iter_end(), and num_exits().

◆ footprint_size

long long Loop::footprint_size

loop memory footprint

Definition at line 212 of file loop.hpp.

◆ g

const BBGraphRef Loop::g
private

The basic block control flow graph.

Definition at line 163 of file loop.hpp.

Referenced by ComputeLandingPadExits(), GetRecursivelyOps(), Loop(), and primary_landing_pad().

◆ header_block

vertex Loop::header_block
private

the header of the loop

Definition at line 187 of file loop.hpp.

Referenced by GetHeader(), and IsReducible().

◆ inc_id

unsigned int Loop::inc_id

The node id containing the increment statement.

Definition at line 231 of file loop.hpp.

◆ increment

integer_cst_t Loop::increment

Increment of induction variable.

Definition at line 234 of file loop.hpp.

◆ increment_tn

tree_nodeRef Loop::increment_tn

Increment of induction variable.

Definition at line 237 of file loop.hpp.

◆ init

tree_nodeRef Loop::init

value of the initialization of the induction variable

Definition at line 224 of file loop.hpp.

◆ init_gimple_id

unsigned int Loop::init_gimple_id

The index of the gimple tree node containing the initialization of the induction variable; right operand can be different from initialization_tree_node_id because of assignments chain.

Definition at line 228 of file loop.hpp.

◆ instruction_size

long long Loop::instruction_size

loop instruction footprint

Definition at line 215 of file loop.hpp.

◆ is_innermost_loop

bool Loop::is_innermost_loop
private

tells if there aren't loop nested in this

Definition at line 166 of file loop.hpp.

Referenced by Loops::BuildZeroLoop().

◆ landing_pads

CustomUnorderedSet<vertex> Loop::landing_pads
private

landing_pads for this loop

Definition at line 181 of file loop.hpp.

Referenced by ComputeLandingPadExits(), GetLandingPadBlocks(), num_landing_pads(), and primary_landing_pad().

◆ loop_id

unsigned int Loop::loop_id
private

the id of the loop

Definition at line 193 of file loop.hpp.

Referenced by GetId(), and Loop().

◆ loop_type

int Loop::loop_type

loop type

Definition at line 209 of file loop.hpp.

◆ lower_bound

integer_cst_t Loop::lower_bound

Initial value of induction variable defined when loop_type is COUNTABLE_LOOP.

Definition at line 241 of file loop.hpp.

◆ main_iv

unsigned int Loop::main_iv

the main induction variable of countable loop;

Definition at line 221 of file loop.hpp.

◆ parent_loop

refcount<Loop> Loop::parent_loop
private

Parent loop.

Definition at line 169 of file loop.hpp.

Referenced by Parent(), and SetParent().

◆ primary_landing_pad_block

vertex Loop::primary_landing_pad_block
private

???

Definition at line 184 of file loop.hpp.

◆ sp_back_edges

CustomOrderedSet<std::pair<vertex, vertex> > Loop::sp_back_edges
private

set of vertex pairs describing a spanning tree back edge for the loop

Definition at line 202 of file loop.hpp.

Referenced by get_sp_back_edges().

◆ upper_bound

integer_cst_t Loop::upper_bound

Final value of induction variable defined when loop_type is COUNTABLE_LOOP.

Definition at line 245 of file loop.hpp.

◆ upper_bound_tn

tree_nodeRef Loop::upper_bound_tn

Final value of induction variable.

Definition at line 248 of file loop.hpp.


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:03:57 for PandA-2024.02 by doxygen 1.8.13