Otawa  0.10
otawa::VirtualCFG Class Reference

A virtual CFG is a CFG not-mapped to real code, that is, it may contains virtual nodes for inlining functions calls or for separating nodes according some context information. More...

#include <otawa/cfg/VirtualCFG.h>

Inheritance diagram for otawa::VirtualCFG:
otawa::CFG otawa::PropList

Public Member Functions

 VirtualCFG (CFG *cfg, bool inlined=true)
 Build a new virtual CFG from the given CFG. More...
 
 VirtualCFG (bool addEntryExit=true)
 Build a new empty VirtualCFG. More...
 
CFGcfg (void) const
 Get the base CFG of the current virtual CFG. More...
 
void addBB (BasicBlock *bb)
 Adds a basic block. More...
 
void removeBB (BasicBlock *bb)
 Remove a basic block. More...
 
void numberBBs (void)
 Give a number to each basic block of the virtual CFG. More...
 
Segmentsegment (void) const
 
string label (void)
 Get some label to identify the CFG. More...
 
string name (void)
 Build a name that identifies this CFG and is valid C name. More...
 
string format (const Address &addr)
 Format the display of the given address relativelt to the given CFG. More...
 
int number (void)
 
address_t address (void)
 Get the address of the first instruction of the CFG. More...
 
BasicBlockentry (void)
 Get the entry basic block of the CFG. More...
 
BasicBlockexit (void)
 Get the exit basic block of the CFG. More...
 
int countBB (void)
 
bool isVirtual (void) const
 
bool isInlined (void) const
 
void numberBB (void)
 Number the basic block of the CFG, that is, hook a property with ID_Index identifier and the integer value of the number to each basic block. More...
 
BasicBlockfirstBB (void)
 Get the first basic block of the CFG. More...
 
InstfirstInst (void)
 Get the first instruction of the CFG. More...
 
void print (io::Output &out)
 Print a reference for the CFG. More...
 
void print (elm::io::Output &out) const
 Display the current property list. More...
 
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...
 

Static Public Attributes

static const PropList EMPTY
 This is an empty proplist for convenience. More...
 

Protected Member Functions

virtual void scan (void)
 Scan the CFG for finding exit and builds virtual edges with entry and exit. More...
 

Protected Attributes

unsigned long flags
 
EndBasicBlock _entry
 
EndBasicBlock _exit
 
bbs_t _bbs
 

Static Protected Attributes

static const unsigned long FLAG_Scanned = 0x01
 
static const unsigned long FLAG_Virtual = 0x02
 
static const unsigned long FLAG_Inlined = 0x04
 

Private Member Functions

void virtualize (struct call_t *stack, CFG *cfg, BasicBlock *entry, BasicBlock *exit)
 Build the virtual CFG. More...
 

Private Attributes

CFG_cfg
 

Detailed Description

A virtual CFG is a CFG not-mapped to real code, that is, it may contains virtual nodes for inlining functions calls or for separating nodes according some context information.

Constructor & Destructor Documentation

otawa::VirtualCFG::VirtualCFG ( CFG cfg,
bool  inlined = true 
)

Build a new virtual CFG from the given CFG.

Parameters
cfgCFG to buid from.
inlinedIf true, performs inlining.

References otawa::PropList::addProps(), otawa::CFG::FLAG_Inlined, otawa::CFG::FLAG_Virtual, and otawa::CFG::flags.

Member Function Documentation

Address otawa::CFG::address ( void  )
inherited

Get the address of the first instruction of the CFG.

Returns
Return address of the first instruction.

References otawa::BasicBlock::address(), otawa::cfgio::edge(), otawa::CFG::ent, otawa::CFG::entry(), and otawa::Address::null.

Referenced by otawa::PCGBlock::getAddress(), makeAddress(), and nameOf().

CFG * otawa::VirtualCFG::cfg ( void  ) const
inline

Get the base CFG of the current virtual CFG.

Returns
Base CFG.

References _cfg.

Referenced by virtualize().

void otawa::PropList::clearProps ( void  )
inherited
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().

BasicBlock * otawa::CFG::firstBB ( void  )
inherited
Inst * otawa::CFG::firstInst ( void  )
inherited
string otawa::CFG::format ( const Address addr)
inherited

Format the display of the given address relativelt to the given CFG.

Parameters
addrAddress to format.
Returns
Formatted address.

References elm::_, otawa::ot::address(), elm::io::hex(), and otawa::display::LABEL.

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::CFG::isInlined ( void  ) const
inlineinherited

References otawa::CFG::FLAG_Inlined, and otawa::CFG::flags.

Referenced by virtualize().

bool otawa::CFG::isVirtual ( void  ) const
inlineinherited
string otawa::CFG::name ( void  )
inherited

Build a name that identifies this CFG and is valid C name.

Returns
Name of the CFG.

References _, otawa::BasicBlock::address(), otawa::CFG::ent, and otawa::CFG::label().

void otawa::CFG::numberBB ( void  )
inherited

Number the basic block of the CFG, that is, hook a property with ID_Index identifier and the integer value of the number to each basic block.

The entry get the number 0 et the exit the last number.

References otawa::CFG::_bbs, otawa::INDEX, and elm::genstruct::FragTable< T >::length().

Referenced by otawa::PSTBuilder::getVCFG(), and otawa::Virtualizer::virtualizeCFG().

void otawa::VirtualCFG::numberBBs ( void  )
void otawa::CFG::print ( io::Output out)
inherited

Print a reference for the CFG.

Parameters
outOutput stream.

References otawa::CFG::label().

Referenced by otawa::operator<<().

void otawa::PropList::print ( elm::io::Output out) const
inherited

Display the current property list.

Parameters
outOutput to use.

Referenced by otawa::operator<<(), and otawa::ContextualProperty::print().

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::VirtualCFG::removeBB ( BasicBlock bb)

Remove a basic block.

Parameters
bbRemoved basic block.
Note
This operation may be faster if BB are numbered.

References otawa::CFG::_bbs, elm::genstruct::FragTable< T >::count(), otawa::INDEX, and elm::genstruct::FragTable< T >::shrink().

void otawa::PropList::removeProp ( const AbstractIdentifier id)
inherited
void otawa::PropList::removeProp ( const AbstractIdentifier id)
inlineinherited
void otawa::VirtualCFG::scan ( void  )
protectedvirtual

Scan the CFG for finding exit and builds virtual edges with entry and exit.

For memory-place and time purposes, this method is only called when the CFG is used (call to an accessors method).

Reimplemented from otawa::CFG.

References otawa::CFG::_bbs, _cfg, otawa::CFG::_entry, otawa::CFG::_exit, elm::genstruct::FragTable< T >::add(), otawa::CFG::FLAG_Scanned, otawa::CFG::flags, otawa::INDEX, elm::genstruct::FragTable< T >::length(), and virtualize().

Segment * otawa::CFG::segment ( void  ) const
inlineinherited

References otawa::CFG::_seg.

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::VirtualCFG::virtualize ( struct call_t stack,
CFG cfg,
BasicBlock entry,
BasicBlock exit 
)
private

Member Data Documentation

CFG* otawa::VirtualCFG::_cfg
private

Referenced by cfg(), and scan().

EndBasicBlock otawa::CFG::_entry
protectedinherited
EndBasicBlock otawa::CFG::_exit
protectedinherited
const PropList otawa::PropList::EMPTY
staticinherited

This is an empty proplist for convenience.

const unsigned long otawa::CFG::FLAG_Inlined = 0x04
staticprotectedinherited
const unsigned long otawa::CFG::FLAG_Scanned = 0x01
staticprotectedinherited
const unsigned long otawa::CFG::FLAG_Virtual = 0x02
staticprotectedinherited

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