Otawa  0.10
otawa::BasicBlock Class Reference

This is the minimal definition of a basic block. More...

#include <otawa/cfg/BasicBlock.h>

Inheritance diagram for otawa::BasicBlock:
otawa::PropList otawa::CodeBasicBlock otawa::EndBasicBlock otawa::VirtualBasicBlock

Classes

class  Bundle
 A bundle, in a VLIW processors, is a group of instructions executed in parallel. More...
 
class  BundleIter
 Iterator on bundles composing a basic block. More...
 
class  EdgeIterator
 
class  InIterator
 
class  InstIter
 Iterator for instructions in the basic block. More...
 
class  OutIterator
 

Public Types

typedef InstIter InstIterator
 

Public Member Functions

 BasicBlock (void)
 Build an empty basic block. More...
 
bool isCall (void) const
 Test if the basic block is ended by a call to a sub-program. More...
 
bool isReturn (void) const
 Test if the basic block is ended by a sub-program return. More...
 
bool isTargetUnknown (void) const
 Test if the target of the branch instruction of this basic block is known or not. More...
 
bool isEntry (void) const
 Test if the basic block is the CFG entry. More...
 
bool isExit (void) const
 Test if the basic block is the CFG exit. More...
 
bool isEnd (void) const
 Test if the basic block is the CFG end, entry or exit. More...
 
bool isConditional (void) const
 Test if the BB is ended by a conditional branch. More...
 
Address address (void) const
 
Address topAddress (void) const
 
virtual int countInsts (void) const
 Count the number of instructions in the basic block. More...
 
t::uint32 size (void) const
 Get the size of the basic block. More...
 
bool isVirtual (void) const
 
unsigned long getFlags (void) const
 
int number (void) const
 Get the number hooked on this basic block, that is, value of ID_Index property. More...
 
CFGcfg (void)
 
InstfirstInst (void) const
 
InstlastInst (void) const
 Get the last instruction of a basic block. More...
 
InstcontrolInst (void) const
 Find the last control instruction of the basic block. More...
 
void print (io::Output &out) const
 Print the reference for a basic block. More...
 
void addInEdge (Edge *edge)
 Add an input edge to the basic block input list. More...
 
void addOutEdge (Edge *edge)
 Add an output edge to the basic block output list. More...
 
void removeInEdge (Edge *edge)
 Remove an input edge from the basic block input list. More...
 
void removeOutEdge (Edge *edge)
 Remove an output edge from the basic block output list. More...
 
BasicBlockgetTaken (void)
 Get the target basic block if the last branch instruction is taken. More...
 
BasicBlockgetNotTaken (void)
 Get the following basic block if the last branch instruction is not taken. More...
 
t::uint32 getBlockSize (void) const
 Compute the size of the basic block. More...
 
int countInstructions (void) const
 
PropertygetProp (const AbstractIdentifier *id) const
 Find a property by its identifier. More...
 
void setProp (Property *prop)
 Set the property in the property list removing any double. More...
 
void setProp (const AbstractIdentifier *id)
 
void removeProp (const AbstractIdentifier *id)
 Remove a property matching the given identifier. More...
 
void removeProp (const AbstractIdentifier &id)
 
PropertyextractProp (const AbstractIdentifier *id)
 Remove a property matching the given identifier and return it. More...
 
PropertyextractProp (const AbstractIdentifier &id)
 Remove a property matching the given identifier and return it. More...
 
void addProp (Property *prop)
 Add property to the list without checking of duplication. More...
 
void removeAllProp (const AbstractIdentifier *id)
 Remove all the properties matching the given identifier. More...
 
bool hasProp (const AbstractIdentifier &id) const
 Test if the property list contains a property matching the given identifier. More...
 
void clearProps (void)
 Remove all properties from the list. More...
 
void addProps (const PropList &props)
 Add all properties from the given property list, in a reverse order. More...
 

Public Attributes

Instfirst
 
t::size _size
 
unsigned long flags
 
elm::genstruct::SLList< Edge * > ins
 
elm::genstruct::SLList< Edge * > outs
 
CFG_cfg
 

Static Public Attributes

static Identifier< BasicBlock * > ID
 Identifier of the basic block pseudo-instruction. More...
 
static const PropList EMPTY
 This is an empty proplist for convenience. More...
 

Protected Member Functions

virtual ~BasicBlock (void)
 
void setTaken (BasicBlock *bb)
 Set the target basic block of the branch last instruction. More...
 
void setNotTaken (BasicBlock *bb)
 Set the following basic block. More...
 

Static Protected Attributes

static const unsigned long FLAG_Call = 0x01
 
static const unsigned long FLAG_Unknown = 0x02
 
static const unsigned long FLAG_Return = 0x04
 
static const unsigned long FLAG_Entry = 0x08
 
static const unsigned long FLAG_Exit = 0x10
 
static const unsigned long FLAG_Virtual = 0x20
 
static const unsigned long FLAG_Cond = 0x40
 
static BasicBlocknull_bb = null_bb_inst
 

Friends

class CFGBuilder
 
class CFGInfo
 
class CFG
 
class VirtualCFG
 
class Edge
 

Detailed Description

This is the minimal definition of a basic block.

Implemented concepts

Member Typedef Documentation

Constructor & Destructor Documentation

otawa::BasicBlock::~BasicBlock ( void  )
protectedvirtual
otawa::BasicBlock::BasicBlock ( void  )

Build an empty basic block.

Member Function Documentation

void otawa::BasicBlock::addInEdge ( Edge edge)
inline

Add an input edge to the basic block input list.

Parameters
edgeEdge to add.

References ins.

Referenced by otawa::Edge::Edge().

void otawa::BasicBlock::addOutEdge ( Edge edge)
inline

Add an output edge to the basic block output list.

Parameters
edgeEdge to add.

References outs.

Referenced by otawa::Edge::Edge().

void otawa::PropList::clearProps ( void  )
inherited
Inst * otawa::BasicBlock::controlInst ( void  ) const

Find the last control instruction of the basic block.

This is usually the last one but (1) delayed-branch architecture insert instructions after the control and (2) OTAWA CFG configuration system may make merge different blocks or ignore some control instructions. If no control is found, return the last instruction.

Returns
Last control instruction.

Referenced by otawa::etime::EdgeTimeBuilder::getBranchNode(), otawa::CFGChecker::processBB(), otawa::etime::StandardEventBuilder::processBB(), and otawa::BBStatCollector::processCFG().

int otawa::BasicBlock::countInsts ( void  ) const
virtual

Count the number of instructions in the basic block.

Returns
Number of instruction in the basic block.

Referenced by countInstructions(), and otawa::ipet::TrivialBBTime::processBB().

Property * otawa::PropList::extractProp ( const AbstractIdentifier id)
inherited

Remove a property matching the given identifier and return it.

Caller is responsible of the management of the obtained property.

Parameters
idIdentifier of the property to extract.

References otawa::Property::_next, and otawa::Property::next().

Referenced by otawa::script::Script::makeConfig().

Property * otawa::PropList::extractProp ( const AbstractIdentifier id)
inlineinherited

Remove a property matching the given identifier and return it.

Caller is responsible of the management of the obtained property.

Parameters
idIdentifier of the property to extract.

References otawa::PropList::extractProp().

Referenced by otawa::PropList::extractProp().

size_t otawa::BasicBlock::getBlockSize ( void  ) const
inline

Compute the size of the basic block.

Returns
Size of basic block.
Deprecated:
See BasicBlock::size().

References size().

unsigned long otawa::BasicBlock::getFlags ( void  ) const
inline
BasicBlock * otawa::BasicBlock::getNotTaken ( void  )

Get the following basic block if the last branch instruction is not taken.

Returns
Following basic block or null if the last instruction is a sub-program return.
Deprecated:
{Use Edge class instead.}

References otawa::cfgio::edge(), and EDGE_NotTaken.

BasicBlock * otawa::BasicBlock::getTaken ( void  )

Get the target basic block if the last branch instruction is taken.

Returns
Target basic block or null if the last instruction is not a branch.
Deprecated:
{Use Edge class instead.}

References otawa::cfgio::edge(), EDGE_Call, and EDGE_Taken.

bool otawa::PropList::hasProp ( const AbstractIdentifier id) const
inlineinherited

Test if the property list contains a property matching the given identifier.

Parameters
idProperty identifier to look for.
Returns
True if the list contains the matching property, false else.

References otawa::PropList::getProp().

Referenced by otawa::ipet::BasicConstraintsBuilder::addEntryConstraint(), otawa::Monitor::configure(), otawa::ImmutableRef< T, I >::exists(), and otawa::Manager::setVerbosity().

bool otawa::BasicBlock::isCall ( void  ) const
inline

Test if the basic block is ended by a call to a sub-program.

Returns
True if the basic block is call, false else.

References FLAG_Call, and flags.

Referenced by otawa::ContextTree::addBB().

bool otawa::BasicBlock::isConditional ( void  ) const
inline

Test if the BB is ended by a conditional branch.

Returns
True if the BB is ended by a conditional branch, false else.

References FLAG_Cond, and flags.

Referenced by otawa::ipet::BasicConstraintsBuilder::processBB().

bool otawa::BasicBlock::isReturn ( void  ) const
inline

Test if the basic block is ended by a sub-program return.

Returns
True if it is a sub-program return, false else.

References FLAG_Return, and flags.

Referenced by otawa::CFG::scan().

bool otawa::BasicBlock::isTargetUnknown ( void  ) const
inline

Test if the target of the branch instruction of this basic block is known or not.

Unknown branch target is usually to a non-constant branch address. Remark that sub-program return is not viewed as an unknown branch target.

Returns
True if the branch target is unknown, false else.

References FLAG_Unknown, and flags.

Referenced by otawa::CFGChecker::processBB().

bool otawa::BasicBlock::isVirtual ( void  ) const
inline
Inst * otawa::BasicBlock::lastInst ( void  ) const
int otawa::BasicBlock::number ( void  ) const
inline

Get the number hooked on this basic block, that is, value of ID_Index property.

Returns
Number of the basic block or -1 if there is no number hooked.

References otawa::INDEX.

Referenced by otawa::GraphBBTime< G >::analyzePathContext(), otawa::dfa::hai::UnrollingListener< P >::blockInterpreted(), otawa::dfa::hai::DefaultListener< P >::blockInterpreted(), otawa::dfa::hai::WideningListener< P >::blockInterpreted(), otawa::dfa::IterativeDFA< Problem, Set, Iter >::compute(), otawa::etime::EdgeTimeBuilder::contributeSplit(), otawa::Dominance::dominates(), otawa::CachePenalty::dump(), otawa::PSTBuilder::getVCFG(), otawa::cfgio::Output::id(), otawa::display::CFGAdapter::Vertex::index(), otawa::ForwardCFGAdapter::index(), otawa::BackwardCFGAdapter::index(), otawa::ai::CFGGraph::index(), otawa::ipet::VarAssignment::makeEdgeVar(), otawa::ipet::VarAssignment::makeNodeVar(), otawa::PostDominance::postDominates(), otawa::SESERegion::print(), print(), otawa::ipet::CachePenaltiesObjectFunctionBuilder::processBB(), otawa::ParamExeGraphBBTime::processBB(), otawa::ipet::BasicObjectFunctionBuilder::processBB(), otawa::cfgio::Output::processBB(), otawa::branch::CondNumber::processBB(), otawa::branch::OnlyConsBuilder::processBB(), otawa::BBRatioDisplayer::processBB(), otawa::LiExeGraphBBTime::processBB(), otawa::GraphBBTime< G >::processBB(), otawa::BBStatCollector::processCFG(), otawa::cat::CATConstraintBuilder::processLBlockSet(), otawa::ccg::ConstraintBuilder::processLBlockSet(), otawa::etime::EdgeTimeBuilder::processSequence(), otawa::StackAnalysis::processWorkSpace(), otawa::display::CFGAdapter::VertexMap< T >::put(), otawa::dfa::hai::HalfAbsInt< FixPoint >::tryAddToWorkList(), and otawa::dfa::XCFGVisitor< P >::XCFGVisitor().

void otawa::BasicBlock::print ( io::Output out) const

Print the reference for a basic block.

Parameters
outOutput stream.

References address(), isEntry(), isExit(), and number().

Referenced by otawa::operator<<().

void otawa::PropList::removeAllProp ( const AbstractIdentifier id)
inherited

Remove all the properties matching the given identifier.

Parameters
idIdentifier of properties to remove.

References otawa::Property::_next, and otawa::Property::next().

Referenced by otawa::LoopUnroller::unroll().

void otawa::BasicBlock::removeInEdge ( Edge edge)
inline

Remove an input edge from the basic block input list.

Parameters
edgeEdge to remove.

References ins.

Referenced by otawa::Edge::toCall(), and otawa::Edge::~Edge().

void otawa::BasicBlock::removeOutEdge ( Edge edge)
inline

Remove an output edge from the basic block output list.

Parameters
edgeEdge to remove.

References outs.

Referenced by otawa::Edge::~Edge().

void otawa::PropList::removeProp ( const AbstractIdentifier id)
inherited
void otawa::PropList::removeProp ( const AbstractIdentifier id)
inlineinherited
void otawa::BasicBlock::setNotTaken ( BasicBlock bb)
protected

Set the following basic block.

Parameters
bbNew following basic block.
Deprecated:
{Use Edge class instead.}

References Edge, and EDGE_NotTaken.

void otawa::PropList::setProp ( Property prop)
inherited

Set the property in the property list removing any double.

Parameters
propProperty to set.

References otawa::Property::_next, otawa::Property::id(), and otawa::Property::next().

void otawa::PropList::setProp ( const AbstractIdentifier id)
inlineinherited
void otawa::BasicBlock::setTaken ( BasicBlock bb)
protected

Set the target basic block of the branch last instruction.

Parameters
bbNew target basic block.
Deprecated:
{Use Edge class instead.}

References Edge, and EDGE_Taken.

Address otawa::BasicBlock::topAddress ( void  ) const
inline

Friends And Related Function Documentation

friend class CFG
friend
friend class CFGBuilder
friend
friend class CFGInfo
friend
friend class Edge
friend

Referenced by setNotTaken(), and setTaken().

friend class VirtualCFG
friend

Member Data Documentation

CFG* otawa::BasicBlock::_cfg
const PropList otawa::PropList::EMPTY
staticinherited

This is an empty proplist for convenience.

const unsigned long otawa::BasicBlock::FLAG_Call = 0x01
staticprotected
const unsigned long otawa::BasicBlock::FLAG_Cond = 0x40
staticprotected
const unsigned long otawa::BasicBlock::FLAG_Entry = 0x08
staticprotected

Referenced by isEnd(), and isEntry().

const unsigned long otawa::BasicBlock::FLAG_Exit = 0x10
staticprotected

Referenced by isEnd(), and isExit().

const unsigned long otawa::BasicBlock::FLAG_Return = 0x04
staticprotected
const unsigned long otawa::BasicBlock::FLAG_Unknown = 0x02
staticprotected
const unsigned long otawa::BasicBlock::FLAG_Virtual = 0x20
staticprotected
Identifier< BasicBlock * > otawa::BasicBlock::ID
static

Identifier of the basic block pseudo-instruction.

elm::genstruct::SLList<Edge *> otawa::BasicBlock::ins

Referenced by addInEdge(), and removeInEdge().

BasicBlock & otawa::BasicBlock::null_bb = null_bb_inst
staticprotected
elm::genstruct::SLList<Edge *> otawa::BasicBlock::outs

Referenced by addOutEdge(), and removeOutEdge().


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