OTAWA  2.0
Framework to perform machine analysis and compute WCET.
otawa::CFGProcessor Class Referenceabstract

#include <otawa/proc/CFGProcessor.h>

+ Inheritance diagram for otawa::CFGProcessor:

Public Member Functions

 CFGProcessor (AbstractRegistration &reg)
 Build a new CFG processor with the given registration information. More...
 
 CFGProcessor (cstring name, const Version &version, AbstractRegistration &reg)
 
 CFGProcessor (cstring name, elm::Version version)
 Build a new named processor. More...
 
 CFGProcessor (void)
 Build a new CFG processor. More...
 
- Public Member Functions inherited from otawa::Processor
virtual voidinterfaceFor (const AbstractFeature &feature)
 Get the interface corresponding to the given feature. More...
 
elm::String name (void) const
 
 Processor (AbstractRegistration &registration)
 For internal use only. More...
 
 Processor (const PropList &props)
 Build a new processor. More...
 
 Processor (elm::String name, elm::Version version, const PropList &props)
 Build a new processor with name and version. More...
 
 Processor (String name, Version version)
 Build a new processor with name and version. More...
 
 Processor (String name, Version version, AbstractRegistration &registration)
 For internal use only. More...
 
 Processor (void)
 Build a simple anonymous processor. More...
 
AbstractRegistrationregistration (void) const
 
elm::Version version (void) const
 
virtual ~Processor (void)
 
- Public Member Functions inherited from otawa::Monitor
void configure (const PropList &props, string name="")
 
bool isQuiet () const
 
bool isVerbose () const
 
bool logFor (log_level_t tested) const
 
log_level_t logLevel (void) const
 
 Monitor ()
 
 Monitor (Monitor &mon)
 Build a monitor by copy. More...
 
WorkSpaceworkspace (void)
 
 ~Monitor ()
 

Static Public Attributes

static p::declare reg
 
- Static Public Attributes inherited from otawa::Processor
static p::id< boolCOLLECT_STATS
 This property allows to activate collection of statistics for the work of the current processor. More...
 
static p::id< elm::io::OutStream * > & LOG = otawa::LOG
 This property identifier is used for setting the log stream used by the processor to write messages (information, warning, error). More...
 
static p::id< string > & LOG_FOR = otawa::LOG_FOR
 Logging message will only be displayed for the named processor. More...
 
static p::id< log_level_t > & LOG_LEVEL = otawa::LOG_LEVEL
 Property passed in the configuration property list of a processor to select the log level between LOG_PROC, LOG_CFG or LOG_BB. More...
 
static Processornull = _null
 Singleton representing a null processor. More...
 
static p::id< elm::io::OutStream * > & OUTPUT = otawa::OUTPUT
 This property identifier is used for setting the output stream used by the processor to write results. More...
 
static p::id< Progress * > PROGRESS
 Record a progress listener for the execution of the processors. More...
 
static p::id< boolRECURSIVE
 
static p::declare reg
 
static p::id< elm::sys::time_tRUNTIME
 This property identifier is used to store in the statistics of a processor the overall run time of the processor work. More...
 
static p::id< PropList * > STATS
 This property identifiers is used to pass a property list to the processor that will be used to store statistics about the performed work. More...
 
static p::id< boolTIMED
 If the value of the associated property is true (default to false), time statistics will also be collected with other processor statistics. More...
 
static p::id< bool > & VERBOSE = otawa::VERBOSE
 This property activates the verbose mode of the processor: information about the processor work will be displayed. More...
 
- Static Public Attributes inherited from otawa::Monitor
static Monitornull = __null_mon
 Monitor that output nothing. More...
 

Protected Member Functions

CFGcfg (void) const
 
const CFGCollectioncfgs (void) const
 
virtual void cleanupCFG (WorkSpace *ws, CFG *cfg)
 This function may be overridden by a subclass to provide custom cleanup for a CFG. More...
 
void configure (const PropList &props) override
 Configure the current processor. More...
 
void destroy (WorkSpace *ws) override
 This method is called when the properties produced by a processor are no more useful and can be release. More...
 
virtual void destroyCFG (WorkSpace *ws, CFG *cfg)
 Propagate the destroy phase to CFG resources. More...
 
void doCleanUp (void)
 Trigger associated with CFG. More...
 
void dump (WorkSpace *ws, Output &out) override
 Function called for debugging purpose when dump properties (otawa::DUMP, otawa::DUMP_FOR) are provided. More...
 
virtual void dumpCFG (CFG *cfg, Output &out)
 The default implementation of CFGProcessor dump calls this function for each CFG of the program. More...
 
Blockentry () const
 
Blockexit () const
 
virtual void processAll (WorkSpace *ws)
 This function is called once the CFG collection has been obtained. More...
 
virtual void processCFG (WorkSpace *ws, CFG *cfg)=0
 
void processWorkSpace (WorkSpace *ws) override
 Process the given framework. More...
 
string str (const Address &address)
 Transform an address to a smart string, that is, if a source line is available, transform it to "source_file:source_line", if the CFG has a label, it gives "label + 0xoffset", else return the address. More...
 
string str (const Address &base, const Address &address)
 Transform an address to a smart string, that is, if a source line is available, transform it to "source_file:source_line", if the CFG has a label, it gives "label + 0xoffset", else return the address. More...
 
CFGtaskCFG () const
 
BlocktaskEntry () const
 
- Protected Member Functions inherited from otawa::Processor
void addCleaner (const AbstractFeature &feature, Cleaner *cleaner)
 
template<class T >
void addDeletor (const AbstractFeature &feature, const Ref< T *, Identifier< T * > > &ref)
 
template<class T >
void addRemover (const AbstractFeature &feature, const Ref< T, Identifier< T > > &ref)
 
virtual void cleanup (WorkSpace *ws)
 This method is called after the end of the processor analysis to let it do some clean up. More...
 
virtual void collectStats (WorkSpace *ws)
 This method is invoked if the user has required to collect statistics about the processor. More...
 
virtual void commit (WorkSpace *ws)
 This processor is called as soon as all the required and invalidated features has been removed to let the processor install its own properties. More...
 
void invalidate (const AbstractFeature &feature)
 Usually called from a processor constructor, this method records a feature invalidated by the work of the current processor. More...
 
bool isAllocated (void) const
 
bool isCollectingStats (void) const
 
bool isDone () const
 
bool isDumping () const
 
bool isPrepared (void) const
 
bool isTimed (void) const
 
virtual void prepare (WorkSpace *ws)
 This method called to let the processor customize its requirements according to some generic feature. More...
 
Progressprogress (void)
 
void provide (const AbstractFeature &feature)
 Usually called from a processor constructor, this method records a feature provided by the work of the current processor. More...
 
void record (StatCollector *collector)
 Add a statistics collector to the current workspace collection. More...
 
bool recordsStats (void) const
 
void recordStat (const AbstractFeature &feature, StatCollector *collector)
 Add a statistics collector to the current workspace collection. More...
 
void require (const AbstractFeature &feature)
 Usually called from a processor constructor, this method records a required feature for the work of the current processor. More...
 
virtual void requireDyn (WorkSpace *ws, const PropList &props)
 Method called after registration requirements to support dynamic requirements. More...
 
virtual void setup (WorkSpace *ws)
 This method is called before an anlysis to let the processor do some initialization. More...
 
void track (Cleaner *cleaner)
 Track the given cleaner, that is, record the cleaner in the analysis and trigger when the analysis is deleted. More...
 
template<class T >
void track (const AbstractFeature &feature, const Ref< T *, const Identifier< T * > > &ref)
 
template<class T >
void track (const AbstractFeature &feature, const Ref< T *, Identifier< T * > > &ref)
 
template<class T >
void track (const AbstractFeature &feature, const Ref< T, const Identifier< T > > &ref)
 
template<class T >
void track (const AbstractFeature &feature, const Ref< T, Identifier< T > > &ref)
 
template<class T >
T * track (const AbstractFeature &feature, T *object)
 
template<class T >
void track (const Ref< T *, const Identifier< T * > > &ref)
 
template<class T >
void track (const Ref< T, const Identifier< T > > &ref)
 
template<class T >
T * track (T *object)
 
void use (const AbstractFeature &feature)
 Usually called from a processor constructor, this method records a feature as used by the work of the current processor. More...
 
void warn (const String &message)
 Display a warning. More...
 
WorkSpaceworkspace (void) const
 
- Protected Member Functions inherited from otawa::Monitor
void setWorkspace (WorkSpace *workspace)
 Update the workspace in the monitor. More...
 

Private Member Functions

void init (const PropList &props)
 Initialize the processor. More...
 

Private Attributes

CFG_cfg
 
const CFGCollection_coll
 

Additional Inherited Members

- Public Types inherited from otawa::Monitor
enum  log_level_t {
  LOG_NONE = 0, LOG_PROC = 1, LOG_FILE = 2, LOG_DEPS = LOG_FILE,
  LOG_FUN = 3, LOG_CFG = LOG_FUN, LOG_BLOCK = 4, LOG_BB = LOG_BLOCK,
  LOG_INST = 5
}
 
typedef enum otawa::Monitor::log_level_t log_level_t
 
- Public Attributes inherited from otawa::Monitor
elm::io::Output log
 
elm::io::Output out
 
- Protected Attributes inherited from otawa::Processor
PropListstats
 
- Protected Attributes inherited from otawa::Monitor
t::uint32 flags
 
- Static Protected Attributes inherited from otawa::Processor
static const t::uint32 CLOSE_DUMP = 0x100 << CUSTOM_SHIFT
 
static const t::uint32 IS_ALLOCATED = 0x004 << CUSTOM_SHIFT
 
static const t::uint32 IS_COLLECTING = 0x010 << CUSTOM_SHIFT
 
static const t::uint32 IS_DONE = 0x040 << CUSTOM_SHIFT
 
static const t::uint32 IS_DUMPING = 0x080 << CUSTOM_SHIFT
 
static const t::uint32 IS_PREPARED = 0x008 << CUSTOM_SHIFT
 
static const t::uint32 IS_TIED = 0x020 << CUSTOM_SHIFT
 
static const t::uint32 IS_TIMED = 0x001 << CUSTOM_SHIFT
 
- Static Protected Attributes inherited from otawa::Monitor
static const t::uint32 CUSTOM_SHIFT = 16
 
static const t::uint32 IS_QUIET = 0x02
 
static const t::uint32 IS_VERBOSE = 0x01
 

Detailed Description

This is a specialization of the processor class dedicated to CFG processing. The Processor::processFrameWork() method just take each CFG of the framework and apply the processor on.

It accepts in configuration the following properties:

  • ENTRY_CFG: the entry CFG of the task to work with,
  • RECURSIVE: to go down recursively in the task CFG.

If statistics are required, it provides:

  • PROCESSED_CFG: records the count of processed CFG.

Finally, it puts on the framework the following properties:

  • INVOLVED_CFGS: collection of CFG used by the current task.
Note
This processor automatically call CFGCollector.

Constructor & Destructor Documentation

◆ CFGProcessor() [1/4]

otawa::CFGProcessor::CFGProcessor ( AbstractRegistration reg)

Build a new CFG processor with the given registration information.

Parameters
regRegistration information.

◆ CFGProcessor() [2/4]

otawa::CFGProcessor::CFGProcessor ( void  )

Build a new CFG processor.

Deprecated:

◆ CFGProcessor() [3/4]

otawa::CFGProcessor::CFGProcessor ( cstring  name,
elm::Version  version 
)

Build a new named processor.

Parameters
nameProcessor name.
versionProcessor version.
Deprecated:

◆ CFGProcessor() [4/4]

otawa::CFGProcessor::CFGProcessor ( cstring  name,
const Version version,
AbstractRegistration reg 
)

Member Function Documentation

◆ cfg()

CFG * otawa::CFGProcessor::cfg ( void  ) const
inlineprotected

Get the current CFG.

Returns
Current CFG.
Warning
Can only be called from processCFG().

Get the current CFG.

Returns
Current CFG.

References _cfg.

Referenced by entry(), exit(), otawa::cfgio::Output::id(), otawa::ConcurrentCFGProcessor::nextCFG(), otawa::cfgio::Output::processBB(), and otawa::cfgio::Output::processCFG().

◆ cfgs()

const CFGCollection & otawa::CFGProcessor::cfgs ( void  ) const
inlineprotected

Get a range on the CFG of the current task.

Returns
Current CFGs range.
Warning
Can only be called from processAll() or processCFG().

References _coll.

Referenced by otawa::ai::BlockAnalysis< D, S >::processWorkSpace().

◆ cleanupCFG()

void otawa::CFGProcessor::cleanupCFG ( WorkSpace ws,
CFG cfg 
)
protectedvirtual

This function may be overridden by a subclass to provide custom cleanup for a CFG.

It is called for each CFG of the task when doCleanUp() is called. As a default, do nothing.

Parameters
wsCurrent workspace.
cfgCurrent CFG.

Reimplemented in otawa::BBProcessor, and otawa::EdgeProcessor.

Referenced by doCleanUp().

◆ configure()

◆ destroy()

void otawa::CFGProcessor::destroy ( WorkSpace ws)
overrideprotectedvirtual

This method is called when the properties produced by a processor are no more useful and can be release.

This happens (a) when the workspace is release or (b) the features provided by the processor are invalidated.

The processor has to retain the properties of the provided features until this function is called.

The default implementation activates the clean list.

Reimplemented from otawa::Processor.

References otawa::CFGCollection::count(), destroyCFG(), otawa::CFGCollection::get(), otawa::INVOLVED_CFGS, otawa::Processor::workspace(), and otawa::Processor::ws.

◆ destroyCFG()

void otawa::CFGProcessor::destroyCFG ( WorkSpace ws,
CFG cfg 
)
protectedvirtual

Propagate the destroy phase to CFG resources.

Default implementation does nothing.

Reimplemented in otawa::PostDominance, and otawa::BBProcessor.

Referenced by destroy().

◆ doCleanUp()

void otawa::CFGProcessor::doCleanUp ( void  )
protected

Trigger associated with CFG.

For each CFG, perform a call to cleanupCFG() that may be customized by a subclass.

References cleanupCFG(), otawa::CFGCollection::count(), otawa::CFGCollection::get(), otawa::INVOLVED_CFGS, and otawa::Processor::workspace().

◆ dump()

void otawa::CFGProcessor::dump ( WorkSpace ws,
Output out 
)
overrideprotectedvirtual

Function called for debugging purpose when dump properties (otawa::DUMP, otawa::DUMP_FOR) are provided.

The default implementation does nothing. The dumped data should be human readable.

Parameters
wsCurrent workspace.
outOutput to dump to.

Reimplemented from otawa::Processor.

References _coll, dumpCFG(), and endl.

◆ dumpCFG()

void otawa::CFGProcessor::dumpCFG ( CFG g,
Output out 
)
protectedvirtual

The default implementation of CFGProcessor dump calls this function for each CFG of the program.

So it can be redefined to provide a custom dump. The default implementation does nothing.

Parameters
gCFG to dump.
outStream to output to.

Reimplemented in otawa::Dominance, and otawa::BBProcessor.

Referenced by dump().

◆ entry()

Block * otawa::CFGProcessor::entry ( ) const
inlineprotected

Get the entry block of the current CFG.

Returns
Current CFG entry block.
Warning
Can only be called from processCFG().

References cfg(), and otawa::CFG::entry().

Referenced by otawa::cfgio::Output::processCFG().

◆ exit()

Block * otawa::CFGProcessor::exit ( ) const
inlineprotected

Get the exit block of the current CFG.

Returns
Current CFG exit block.
Warning
Can only be called from processCFG().

References cfg(), and otawa::CFG::exit().

Referenced by otawa::cfgio::Output::processCFG().

◆ init()

void otawa::CFGProcessor::init ( const PropList props)
private

Initialize the processor.

Parameters
propsConfiguration properties.

Referenced by configure().

◆ processAll()

void otawa::CFGProcessor::processAll ( WorkSpace ws)
protectedvirtual

This function is called once the CFG collection has been obtained.

It can be overriden to apply analysis on the whole task (collection of CFGs). As a default, it call processCFG() for each CFG of the collection.

In this function, the following functions are available:

Parameters
wsCurrent workspace.

References _cfg, _coll, endl, otawa::Monitor::log, otawa::Monitor::LOG_CFG, otawa::Monitor::logFor(), processCFG(), and otawa::Processor::ws.

Referenced by processWorkSpace().

◆ processCFG()

◆ processWorkSpace()

◆ str() [1/2]

string otawa::CFGProcessor::str ( const Address address)
protected

Transform an address to a smart string, that is, if a source line is available, transform it to "source_file:source_line", if the CFG has a label, it gives "label + 0xoffset", else return the address.

Parameters
addressAddress to display.
Returns
Address transformed in string.

◆ str() [2/2]

string otawa::CFGProcessor::str ( const Address base,
const Address address 
)
protected

Transform an address to a smart string, that is, if a source line is available, transform it to "source_file:source_line", if the CFG has a label, it gives "label + 0xoffset", else return the address.

Parameters
baseBase address of the function containing the give address.
addressAddress to display.
Returns
Address transformed in string.

◆ taskCFG()

CFG * otawa::CFGProcessor::taskCFG ( ) const
inlineprotected

Get the CFG entry point of the current task.

Returns
Current task entry point CFG.
Warning
Can only be called from processAll() or processCFG().

References _coll, and otawa::CFGCollection::entry().

Referenced by taskEntry().

◆ taskEntry()

Block * otawa::CFGProcessor::taskEntry ( ) const
inlineprotected

Get the entry block of the current task entry CFG.

Returns
Entry block of the current entry CFG.
Warning
Can only be called from processAll() or processCFG().

References otawa::CFG::entry(), and taskCFG().

Member Data Documentation

◆ _cfg

CFG* otawa::CFGProcessor::_cfg
private

Referenced by cfg(), and processAll().

◆ _coll

const CFGCollection* otawa::CFGProcessor::_coll
private

◆ reg

p::declare otawa::CFGProcessor::reg
static
Initial value:
= p::init("otawa::CFGProcessor", Version(2, 1, 0))
.require(LABEL_FEATURE)

The documentation for this class was generated from the following files:
otawa::LABEL_FEATURE
p::feature LABEL_FEATURE
This feature ensures that label or symbol information has been linked to the concerned instruction.
otawa::COLLECTED_CFG_FEATURE
p::interfaced_feature< const CFGCollection > COLLECTED_CFG_FEATURE
This feature asserts that all CFG involved in the current computation has been collected and accessib...