Otawa
0.10
|
Control Flow Graph representation. More...
#include <otawa/cfg/CFG.h>
Classes | |
class | BBIterator |
Public Member Functions | |
CFG (Segment *seg, BasicBlock *entry) | |
Constructor. More... | |
virtual | ~CFG (void) |
Segment * | segment (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... | |
BasicBlock * | entry (void) |
Get the entry basic block of the CFG. More... | |
BasicBlock * | exit (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... | |
BasicBlock * | firstBB (void) |
Get the first basic block of the CFG. More... | |
Inst * | firstInst (void) |
Get the first instruction of the CFG. More... | |
void | print (io::Output &out) |
Print a reference for the CFG. More... | |
Property * | getProp (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) |
Property * | extractProp (const AbstractIdentifier *id) |
Remove a property matching the given identifier and return it. More... | |
Property * | extractProp (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... | |
void | print (elm::io::Output &out) const |
Display the current property list. More... | |
Static Public Attributes | |
static const PropList | EMPTY |
This is an empty proplist for convenience. More... | |
Protected Member Functions | |
CFG (void) | |
Build an empty CFG. More... | |
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 Types | |
typedef genstruct::FragTable < BasicBlock * > | bbs_t |
Private Member Functions | |
const bbs_t & | getBBS (void) |
Private Attributes | |
Segment * | _seg |
BasicBlock * | ent |
Friends | |
class | CFGInfo |
Control Flow Graph representation.
Its entry basic block is given and the graph is built using following taken and not-taken properties of the block.
|
private |
otawa::CFG::CFG | ( | Segment * | seg, |
BasicBlock * | entry | ||
) |
Constructor.
Add a property to the basic block for quick retrieval of the matching CFG.
References otawa::FUNCTION_LABEL, label(), and otawa::LABEL.
|
virtual |
References _bbs, otawa::cfgio::bb(), otawa::cfgio::edge(), and elm::genstruct::FragTable< T >::length().
|
protected |
Build an empty CFG.
|
inherited |
Add property to the list without checking of duplication.
prop | Property to add. |
References otawa::Property::_next.
Referenced by otawa::Identifier< T >::add(), otawa::ast::ASTInfo::ASTInfo(), otawa::Identifier< otawa::arm::Info * >::copy(), otawa::AbstractIdentifier::initProps(), otawa::ContextualProperty::make(), otawa::script::Script::makeConfig(), otawa::ccg::Builder::processLBlockSet(), otawa::ipet::ILPSystemGetter::processWorkSpace(), otawa::Identifier< T >::ref(), otawa::ContextualProperty::ref(), and otawa::ContextualProperty::refProps().
|
inherited |
Add all properties from the given property list, in a reverse order.
props | Property list to clone. |
References copy(), otawa::PropList::head, and otawa::Property::next().
Referenced by otawa::display::CFGDrawer::CFGDrawer(), otawa::display::GraphVizGraph::GraphVizGraph(), otawa::ParamFeature::instantiate(), otawa::Manager::loadXML(), otawa::display::GraphVizGraph::newEdge(), otawa::display::GraphVizGraph::newNode(), otawa::PropList::operator=(), otawa::Process::Process(), otawa::PropList::PropList(), otawa::display::GraphVizItem::setProps(), otawa::VirtualBasicBlock::VirtualBasicBlock(), and otawa::VirtualCFG::VirtualCFG().
Address otawa::CFG::address | ( | void | ) |
Get the address of the first instruction of the CFG.
References otawa::BasicBlock::address(), otawa::cfgio::edge(), ent, entry(), and otawa::Address::null.
Referenced by otawa::PCGBlock::getAddress(), makeAddress(), and nameOf().
|
inherited |
Remove all properties from the list.
References otawa::Property::next().
Referenced by otawa::PSTBuilder::getVCFG(), otawa::PropList::operator=(), otawa::display::GraphVizItem::setProps(), otawa::PropList::~PropList(), and otawa::WorkSpace::~WorkSpace().
|
inline |
References _bbs, FLAG_Scanned, flags, elm::genstruct::FragTable< T >::length(), and scan().
Referenced by otawa::PSTBuilder::assignClasses(), otawa::ForwardCFGAdapter::count(), otawa::BackwardCFGAdapter::count(), otawa::display::CFGAdapter::count(), otawa::dfa::hai::DefaultListener< P >::DefaultListener(), otawa::PSTBuilder::getVCFG(), otawa::BBStatCollector::processCFG(), otawa::PSTBuilder::processCFG(), otawa::Virtualizer::processWorkSpace(), otawa::LoopReductor::reduce(), otawa::dfa::hai::UnrollingListener< P >::UnrollingListener(), otawa::dfa::hai::WideningListener< P >::WideningListener(), otawa::dfa::hai::DefaultListener< P >::~DefaultListener(), otawa::dfa::hai::UnrollingListener< P >::~UnrollingListener(), and otawa::dfa::hai::WideningListener< P >::~WideningListener().
|
inline |
Get the entry basic block of the CFG.
References _entry, FLAG_Scanned, flags, and scan().
Referenced by otawa::ipet::BasicConstraintsBuilder::addEntryConstraint(), address(), otawa::DelayedBuilder::buildBB(), otawa::Dominance::ensure(), otawa::PostDominance::ensure(), otawa::ForwardCFGAdapter::entry(), otawa::dfa::Predecessor::entry(), otawa::PSTBuilder::getVCFG(), label(), otawa::cfgio::Output::processCFG(), otawa::BBStatCollector::processCFG(), otawa::CFGSaver::processCFG(), otawa::BBRatioDisplayer::processCFG(), otawa::ContextualProcessor::processCFG(), otawa::PSTBuilder::processCFG(), otawa::LoopReductor::processWorkSpace(), otawa::LoopUnroller::processWorkSpace(), otawa::SubCFGBuilder::processWorkSpace(), otawa::DelayedBuilder::processWorkSpace(), otawa::ipet::BasicConstraintsBuilder::processWorkSpace(), otawa::LoopReductor::reduce(), otawa::SESERegion::SESERegion(), otawa::dfa::hai::HalfAbsInt< FixPoint >::solve(), otawa::LoopUnroller::unroll(), otawa::VirtualCFG::virtualize(), otawa::Virtualizer::virtualize(), and otawa::Virtualizer::virtualizeCFG().
|
inline |
Get the exit basic block of the CFG.
References _exit, FLAG_Scanned, flags, and scan().
Referenced by otawa::DelayedBuilder::buildBB(), otawa::dfa::Successor::entry(), otawa::BackwardCFGAdapter::entry(), otawa::PSTBuilder::getVCFG(), otawa::cfgio::Output::processCFG(), otawa::CFGChecker::processCFG(), otawa::BBStatCollector::processCFG(), otawa::CFGSaver::processCFG(), otawa::DelayedBuilder::processCFG(), otawa::ContextualProcessor::processCFG(), otawa::PSTBuilder::processCFG(), otawa::LoopReductor::processWorkSpace(), otawa::SubCFGBuilder::processWorkSpace(), otawa::LoopReductor::reduce(), otawa::SESERegion::SESERegion(), otawa::LoopUnroller::unroll(), otawa::VirtualCFG::virtualize(), and otawa::Virtualizer::virtualizeCFG().
|
inherited |
Remove a property matching the given identifier and return it.
Caller is responsible of the management of the obtained property.
id | Identifier of the property to extract. |
References otawa::Property::_next, and otawa::Property::next().
Referenced by otawa::script::Script::makeConfig().
|
inlineinherited |
Remove a property matching the given identifier and return it.
Caller is responsible of the management of the obtained property.
id | Identifier of the property to extract. |
References otawa::PropList::extractProp().
Referenced by otawa::PropList::extractProp().
BasicBlock * otawa::CFG::firstBB | ( | void | ) |
Get the first basic block of the CFG.
References _bbs, FLAG_Scanned, flags, and scan().
Referenced by otawa::DelayedBuilder::buildEdges(), firstInst(), and otawa::etime::EdgeTimeBuilder::processEdge().
Inst * otawa::CFG::firstInst | ( | void | ) |
Get the first instruction of the CFG.
References otawa::cfgio::bb(), firstBB(), FLAG_Scanned, flags, and scan().
Referenced by otawa::Virtualizer::isInlined(), otawa::CFGProcessor::str(), otawa::VirtualCFG::virtualize(), and otawa::Virtualizer::virtualize().
Format the display of the given address relativelt to the given CFG.
addr | Address to format. |
References elm::_, otawa::ot::address(), elm::io::hex(), and otawa::display::LABEL.
|
inlineprivate |
References _bbs, FLAG_Scanned, flags, and scan().
|
inherited |
Find a property by its identifier.
id | Identifier of the property to find. |
References otawa::Property::_next, and otawa::Property::next().
Referenced by otawa::Identifier< otawa::arm::Info * >::exists(), otawa::ContextualProperty::exists(), otawa::ContextualProperty::find(), otawa::Identifier< T >::get(), otawa::PropList::hasProp(), otawa::ContextualProperty::make(), otawa::ParamFeature::matches(), otawa::ImmutableRef< T, I >::print(), otawa::ContextualProperty::print(), otawa::Identifier< T >::ref(), otawa::ContextualProperty::ref(), otawa::ContextualProperty::refProps(), otawa::Identifier< T >::set(), otawa::Identifier< T >::use(), and otawa::Identifier< T >::value().
|
inlineinherited |
Test if the property list contains a property matching the given identifier.
id | Property identifier to look for. |
References otawa::PropList::getProp().
Referenced by otawa::ipet::BasicConstraintsBuilder::addEntryConstraint(), otawa::Monitor::configure(), otawa::ImmutableRef< T, I >::exists(), and otawa::Manager::setVerbosity().
|
inline |
References FLAG_Inlined, and flags.
Referenced by otawa::VirtualCFG::virtualize().
|
inline |
References FLAG_Virtual, and flags.
Referenced by otawa::SubCFGBuilder::processWorkSpace().
String otawa::CFG::label | ( | void | ) |
Get some label to identify the CFG.
References ent, entry(), otawa::BasicBlock::firstInst(), otawa::FUNCTION_LABEL, otawa::LABEL, and out.
Referenced by otawa::CFGBuilder::addCFG(), otawa::ContextTree::addChild(), otawa::PCGBuilder::addPCGBlock(), otawa::dfa::hai::UnrollingListener< P >::blockInterpreted(), CFG(), otawa::ContextTree::ContextTree(), otawa::etime::EdgeTimeBuilder::contributeSplit(), otawa::display::CFGOutput::genGraphLabel(), otawa::PCGBlock::getName(), makeAddress(), otawa::ipet::VarAssignment::makeEdgeVar(), otawa::ipet::VarAssignment::makeNodeVar(), name(), nameOf(), otawa::display::CFGDrawer::onCall(), print(), otawa::ipet::BasicObjectFunctionBuilder::processBB(), otawa::ipet::FlowFactConstraintBuilder::processBB(), otawa::BBRatioDisplayer::processBB(), otawa::cfgio::Output::processCFG(), otawa::CFGChecker::processCFG(), otawa::BBRatioDisplayer::processCFG(), otawa::display::CFGOutput::processCFG(), otawa::ContextualProcessor::processCFG(), otawa::ccg::ConstraintBuilder::processLBlockSet(), otawa::dcache::CatConstraintBuilder::processWorkSpace(), otawa::StackAnalysis::processWorkSpace(), otawa::CFGCollector::processWorkSpace(), otawa::CFGProcessor::processWorkSpace(), otawa::clp::Analysis::processWorkSpace(), and otawa::Virtualizer::virtualize().
string otawa::CFG::name | ( | void | ) |
|
inline |
void otawa::CFG::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.
The entry get the number 0 et the exit the last number.
References _bbs, otawa::INDEX, and elm::genstruct::FragTable< T >::length().
Referenced by otawa::PSTBuilder::getVCFG(), and otawa::Virtualizer::virtualizeCFG().
void otawa::CFG::print | ( | io::Output & | out | ) |
Print a reference for the CFG.
out | Output stream. |
References label().
Referenced by otawa::operator<<().
|
inherited |
Display the current property list.
out | Output to use. |
Referenced by otawa::operator<<(), and otawa::ContextualProperty::print().
|
inherited |
Remove all the properties matching the given identifier.
id | Identifier of properties to remove. |
References otawa::Property::_next, and otawa::Property::next().
Referenced by otawa::LoopUnroller::unroll().
|
inherited |
Remove a property matching the given identifier.
id | Identifier of the property to remove. |
References otawa::Property::_next, and otawa::Property::next().
Referenced by otawa::PSTBuilder::buildTree(), otawa::BBRemover< T >::clean(), otawa::display::CFGOutput::processCFG(), otawa::SubCFGBuilder::processWorkSpace(), otawa::Ref< T, I >::remove(), and otawa::ContextualPath::Ref< T >::remove().
|
inlineinherited |
References otawa::PropList::removeProp().
Referenced by otawa::PropList::removeProp().
|
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 in otawa::VirtualCFG.
References _bbs, _entry, _exit, elm::genstruct::FragTable< T >::add(), otawa::BasicBlock::address(), otawa::cfgio::bb(), otawa::Edge::CALL, otawa::cfgio::edge(), ent, otawa::ENTRY, otawa::BasicBlock::FLAG_Call, FLAG_Scanned, flags, elm::genstruct::VectorQueue< T, class >::get(), otawa::INDEX, otawa::BasicBlock::isReturn(), elm::genstruct::FragTable< T >::length(), elm::genstruct::VectorQueue< T, class >::put(), otawa::Edge::toCall(), and otawa::Edge::VIRTUAL.
Referenced by countBB(), entry(), exit(), firstBB(), firstInst(), and getBBS().
|
inherited |
Set the property in the property list removing any double.
prop | Property to set. |
References otawa::Property::_next, otawa::Property::id(), and otawa::Property::next().
|
inlineinherited |
References otawa::PropList::setProp().
Referenced by otawa::PropList::setProp().
|
friend |
|
protected |
|
protected |
Referenced by entry(), otawa::VirtualCFG::scan(), scan(), and otawa::VirtualCFG::VirtualCFG().
|
protected |
Referenced by exit(), otawa::VirtualCFG::scan(), scan(), and otawa::VirtualCFG::VirtualCFG().
|
staticinherited |
This is an empty proplist for convenience.
|
mutableprivate |
|
staticprotected |
Referenced by isInlined(), and otawa::VirtualCFG::VirtualCFG().
|
staticprotected |
Referenced by countBB(), entry(), exit(), firstBB(), firstInst(), getBBS(), otawa::VirtualCFG::scan(), scan(), and otawa::VirtualCFG::VirtualCFG().
|
staticprotected |
Referenced by isVirtual(), and otawa::VirtualCFG::VirtualCFG().
|
protected |
Referenced by countBB(), entry(), exit(), firstBB(), firstInst(), getBBS(), isInlined(), isVirtual(), otawa::VirtualCFG::scan(), scan(), and otawa::VirtualCFG::VirtualCFG().