Otawa  0.10
otawa::BBStatCollector Class Referenceabstract

This class alleviates the work of building a statistics collector. More...

#include <otawa/stats/BBStatCollector.h>

Inheritance diagram for otawa::BBStatCollector:
otawa::StatCollector

Public Member Functions

 BBStatCollector (WorkSpace *ws)
 Build the BB statistics collector. More...
 
virtual void collect (Collector &collector)
 Called to collect the statistics. More...
 
virtual cstring name (void) const =0
 Name of the statistics (for human user, in english). More...
 
virtual cstring unit (void) const =0
 Name of statistics unit (for human user, in english). More...
 
virtual bool isEnum (void) const =0
 Test if the statistics concerns enumerated value. More...
 
virtual const cstring valueName (int value)=0
 Get the name of an enumerated value (for human user, in english). More...
 
virtual int mergeContext (int v1, int v2)=0
 This function allows to merge statistics of a same block in different contexts. More...
 
virtual int mergeAgreg (int v1, int v2)=0
 This function allows to merge statistics when different blocks are aggregated. More...
 

Protected Member Functions

WorkSpacews (void) const
 
CFGcfg (void) const
 
virtual int total (void)
 Default implementation of a total as the sum of the total of each basic block (method total(BasicBlock *). More...
 
virtual void collect (Collector &collector, BasicBlock *bb)=0
 This method is called for each basic block in the current workspace (except for syntactic entry and exit blocks). More...
 
virtual int total (BasicBlock *bb)
 This method is automatically called on each basic block to compute the total() result as the sum of total of each basic block. More...
 

Private Member Functions

virtual void processCFG (Collector &collector, CFG *cfg)
 
void process (Collector &collector)
 Process basic block of the current CFG. More...
 

Private Attributes

WorkSpace_ws
 
CFG_cfg
 
int _total
 

Detailed Description

This class alleviates the work of building a statistics collector.

It ensures the traversal of all basic blocks and calls collect() to let the inheriting class do specific work for a basic block.

Constructor & Destructor Documentation

otawa::BBStatCollector::BBStatCollector ( WorkSpace ws)

Build the BB statistics collector.

Parameters
wsCurrent workspace.

Member Function Documentation

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

References _cfg.

Referenced by processCFG().

void otawa::BBStatCollector::collect ( Collector collector)
virtual

Called to collect the statistics.

Parameters
collectorCollector of statistics.

Implements otawa::StatCollector.

References _cfg, otawa::CFGCollection::count(), otawa::CFGCollection::get(), otawa::INVOLVED_CFGS, process(), and ws().

Referenced by processCFG().

void otawa::BBStatCollector::collect ( Collector collector,
BasicBlock bb 
)
protectedpure virtual

This method is called for each basic block in the current workspace (except for syntactic entry and exit blocks).

It must specialized by the inheriting class to provide specific work.

The methods ws(), cfg() and path() allows to get the current information about the processed blocks.

Parameters
collectorThe invoker collector to pass statistics information.
bbCurrent basic block.
bool otawa::StatCollector::isEnum ( void  ) const
pure virtualinherited

Test if the statistics concerns enumerated value.

If this method returns true, method valueName() can be called to collect names of enumerated values. The number of enumerated values is given by the total method.

Returns
True if the statistics are enumerated values.
int otawa::StatCollector::mergeAgreg ( int  v1,
int  v2 
)
pure virtualinherited

This function allows to merge statistics when different blocks are aggregated.

int otawa::StatCollector::mergeContext ( int  v1,
int  v2 
)
pure virtualinherited

This function allows to merge statistics of a same block in different contexts.

cstring otawa::StatCollector::name ( void  ) const
pure virtualinherited

Name of the statistics (for human user, in english).

void otawa::BBStatCollector::process ( Collector collector)
private

Process basic block of the current CFG.

Parameters
collectorCollector to use.

References _cfg, _ws, otawa::CFGCollection::count(), otawa::CFGCollection::get(), otawa::INVOLVED_CFGS, and processCFG().

Referenced by collect().

int otawa::BBStatCollector::total ( void  )
protectedvirtual

Default implementation of a total as the sum of the total of each basic block (method total(BasicBlock *).

It may be overriden if the default behavior does not match. As a default, entry and exit nodes are ignored.

Returns
Total of the statistics.

Implements otawa::StatCollector.

References _cfg, _total, _ws, otawa::cfgio::bb(), otawa::CFGCollection::count(), otawa::CFGCollection::get(), and otawa::INVOLVED_CFGS.

int otawa::BBStatCollector::total ( BasicBlock bb)
protectedvirtual

This method is automatically called on each basic block to compute the total() result as the sum of total of each basic block.

This methodmust be overriden to provide a customized behaviour. As a default, it returns 0.

Parameters
bbCurrent basic block.
Returns
Total of the basic block.
cstring otawa::StatCollector::unit ( void  ) const
pure virtualinherited

Name of statistics unit (for human user, in english).

const cstring otawa::StatCollector::valueName ( int  value)
pure virtualinherited

Get the name of an enumerated value (for human user, in english).

May only be called if isEnum() returns true.

Parameters
valueEnumerated value.
Returns
Name of the enumerated value.
WorkSpace* otawa::BBStatCollector::ws ( void  ) const
inlineprotected

References _ws.

Referenced by collect().

Member Data Documentation

CFG* otawa::BBStatCollector::_cfg
private

Referenced by cfg(), collect(), process(), processCFG(), and total().

int otawa::BBStatCollector::_total
private

Referenced by total().

WorkSpace* otawa::BBStatCollector::_ws
private

Referenced by process(), total(), and ws().


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