Otawa  0.10
otawa::dfa::hai::HalfAbsInt< FixPoint > Class Template Reference

Implements abstract interpretation. More...

#include <otawa/dfa/hai/HalfAbsInt.h>

Public Member Functions

FixPoint::FixPointState * getFixPointState (BasicBlock *bb)
 Get the FixPointState of a loop. More...
 
int solve (otawa::CFG *main_cfg=0, typename FixPoint::Domain *entdom=0, BasicBlock *start_bb=0)
 Do the abstract interpretation of the CFG. More...
 
 HalfAbsInt (FixPoint &_fp, WorkSpace &_fw)
 
 ~HalfAbsInt (void)
 
FixPoint::Domain backEdgeUnion (BasicBlock *bb)
 Given a loop header, returns the union of the value of its back edges. More...
 
FixPoint::Domain entryEdgeUnion (BasicBlock *bb)
 Given a loop header, returns the union of the value of is entry edges (the entry edges are the in-edges that are not back-edges.) More...
 

Private Member Functions

bool isEdgeDone (Edge *edge)
 Tests if an edge verify the conditions needed to add its target BasicBlock. More...
 
bool tryAddToWorkList (BasicBlock *bb)
 Try to add the BasicBlock to the worklist. More...
 
EdgedetectCalls (bool &enter_call, elm::genstruct::Vector< Edge * > &call_edges, BasicBlock *bb)
 
void inputProcessing (typename FixPoint::Domain &entdom)
 
void outputProcessing ()
 
void addSuccessors ()
 

Private Attributes

FixPoint & fp
 
WorkSpacefw
 
CFGentry_cfg
 
CFGcur_cfg
 
elm::genstruct::Vector
< BasicBlock * > * 
workList
 
elm::genstruct::Vector< Edge * > * callStack
 
elm::genstruct::Vector< CFG * > * cfgStack
 
BasicBlockcurrent
 
FixPoint::Domain in
 
FixPoint::Domain out
 
elm::genstruct::Vector< Edge * > call_edges
 
Edgenext_edge
 
bool enter_call
 
bool fixpoint
 
bool mainEntry
 

Static Private Attributes

static Identifier< typename
FixPoint::FixPointState * > 
FIXPOINT_STATE
 

Detailed Description

template<class FixPoint>
class otawa::dfa::hai::HalfAbsInt< FixPoint >

Implements abstract interpretation.

Parameters
FixPointClass used to manage loops.
FixPoint

This parameter must match the following signature:

class FixPoint {
                typedef ... Domain;
                class FixPointState {
                        ...
                };

                void init(CFG*, HalfAbsInt<FixPoint>*);
                FixPointState *newState(void);
                void fixPoint(BasicBlock*, bool&, Domain&, bool) const;
                void markEdge(Edge*, Domain&);
                void unmarkEdge(Edge*);
                Domain* getMark(Edge*);

                const Domain& bottom(void);
        void lub(Domain &, const Domain &) const;
        void assign(Domain &, const Domain &) const;
        bool equals(const Domain &, const Domain &) const;
        void update(Domain &, const Domain &, BasicBlock*) const;
        void blockInterpreted(BasicBlock*, const Domain&, const Domain&) const ;
        void fixPointReached(BasicBlock*) const;
                const Domain& entry(void);
}

Signature explanation
  • Domain – this type is the Domain of the abstract values used in the abstract interpretation.
  • FixPointState – this class can holds, for each loop, status informations needed by FixPoint. This status information can be accessed and modified by calling the halfAbsInt::getFixPointState() method.
  • void init(CFG*, HalfAbsInt<FixPoint>*) – Method called at HalfAbsInt initialization. Gives FixPoint the chance to perform initialization tasks that were impossible to do in FixPoint's constructor because HalfAbsInt was not instantiated yet.
  • FixPointState *newState(void) – Create a new (empty) FixPointState.
  • markEdge(Edge*, Domain&) – Mark the edge with the value.
  • unmarkEdge(Edge*) – Delete the mark from the edge.
  • Domain* getMark(Edge*) – Retrieve the value from the marked edge.
  • Domain& bottom(void) – Returns the least abstract value (BOTTOM)
  • The lub, assign, equals methods are easy to understand.
  • void update(Domain& out, const Domain& in, BasicBlock*) const – Compute the OUT value, from the IN value and the BasicBlock.
  • void blockInterpreted(BasicBlock*, const Domain& in, const Domain& out) const – Is called when a BasicBlock is interpreted by HalfAbsInt. Informations provided: The BasicBlock, and its IN & OUT values
  • void FixPointReached(BasicBlock*) const – Called by HalfAbsInt when the fixpoint is reached on a particular loop. The loop header is passed in the parameter.
  • const Domain& bottom(void) – returns the least element of the domain.
  • const Domain& entry(void) – returns the domain value at the entry of CFG.

An important precondition on the implementation of the fixpoint is that the Domain MUST support a complete partial order, we use "<=" to denote this order. The following applies on the different functions handling the domain:

  • bottom() must returns the least element of the domain, that is, whatever d in Domain, bottom() <= d.
  • update() must be monotonic, that is, if d1 <= d2, update(d'1, BB, d1) and update(d'2, BB, d2), d'1 <= d'2.
  • lub() must gives a greater element, that is, if d = d1 and join(d, d2) then d1 <= d and d2 <= d.

If these constraints are not ensured, the termination of the analysis performed by HalfAbsInst can not be asserted.

Inside a code processor

To be used inside an OTAWA code processor, the following features must be available (passed in the requirement list of the code processor):

Debugging the analysis
Causes of a failed abstract interpretation performed by HalfAbsInt may be hard to understand. To get details on what does the analyzer for debugging purpose, you may define the constant HAI_DEBUG before including the HalfAbsInt header file. When the analysis will be launched, the processing performed on basic block will be outputted with the values of the domain. To have a readable display of the domain, you have also to provide an overload of "<<" operator to perform the display:
#define HAI_DEBUG
// definition of domain, fixpoint, etc
// display the domain to output
}

Constructor & Destructor Documentation

Member Function Documentation

template<class FixPoint >
void otawa::dfa::hai::HalfAbsInt< FixPoint >::addSuccessors ( )
private
template<class FixPoint >
typename FixPoint::Domain otawa::dfa::hai::HalfAbsInt< FixPoint >::backEdgeUnion ( BasicBlock bb)
inline

Given a loop header, returns the union of the value of its back edges.

Parameters
bbThe loop header.
Returns
The unionized value.

References otawa::Edge::CALL, otawa::Dominance::dominates(), otawa::dfa::hai::FIRST_ITER, and HAI_TRACE.

template<class FixPoint >
Edge * otawa::dfa::hai::HalfAbsInt< FixPoint >::detectCalls ( bool &  enter_call,
elm::genstruct::Vector< Edge * > &  call_edges,
BasicBlock bb 
)
private
template<class FixPoint >
typename FixPoint::Domain otawa::dfa::hai::HalfAbsInt< FixPoint >::entryEdgeUnion ( BasicBlock bb)
inline

Given a loop header, returns the union of the value of is entry edges (the entry edges are the in-edges that are not back-edges.)

Parameters
bbThe loop header
Returns
The unionized value.

References otawa::Edge::CALL, otawa::dfa::hai::CTX_LOOP, otawa::Dominance::dominates(), otawa::dfa::hai::HAI_BYPASS_TARGET, HAI_TRACE, and otawa::Edge::VIRTUAL_RETURN.

template<class FixPoint >
typename FixPoint::FixPointState * otawa::dfa::hai::HalfAbsInt< FixPoint >::getFixPointState ( BasicBlock bb)
inline

Get the FixPointState of a loop.

Parameters
bbThe header of the loop which we want to get the state.
Returns
The requested FixPointState info.
template<class FixPoint>
void otawa::dfa::hai::HalfAbsInt< FixPoint >::inputProcessing ( typename FixPoint::Domain &  entdom)
private
template<class FixPoint >
bool otawa::dfa::hai::HalfAbsInt< FixPoint >::isEdgeDone ( Edge edge)
inlineprivate

Tests if an edge verify the conditions needed to add its target BasicBlock.

Parameters
edgeThe edge to test
Returns
Returns false if the edge's target cannot be added to the worklist. True otherwise.

References otawa::Dominance::dominates(), otawa::dfa::hai::FIRST_ITER, otawa::dfa::hai::FIXED, otawa::LOOP_EXIT_EDGE, otawa::Edge::source(), and otawa::Edge::target().

template<class FixPoint>
int otawa::dfa::hai::HalfAbsInt< FixPoint >::solve ( otawa::CFG main_cfg = 0,
typename FixPoint::Domain *  entdom = 0,
BasicBlock start_bb = 0 
)
template<class FixPoint >
void otawa::dfa::hai::HalfAbsInt< FixPoint >::tryAddToWorkList ( BasicBlock bb)
inlineprivate

Try to add the BasicBlock to the worklist.

In order to be added, the BasicBlock's in-edges must verify some conditions. These conditions are verified by isEdgeDone()

Parameters
bbThe BasicBlock to try to add.

References otawa::sem::add(), otawa::Edge::CALL, cerr, otawa::dfa::hai::FIRST_ITER, otawa::dfa::hai::HAI_BYPASS_TARGET, HAI_TRACE, otawa::LOOP_HEADER, otawa::BasicBlock::number(), and otawa::Edge::VIRTUAL_RETURN.

Member Data Documentation

template<class FixPoint>
elm::genstruct::Vector<Edge*> otawa::dfa::hai::HalfAbsInt< FixPoint >::call_edges
private
template<class FixPoint>
elm::genstruct::Vector<Edge*>* otawa::dfa::hai::HalfAbsInt< FixPoint >::callStack
private
template<class FixPoint>
elm::genstruct::Vector<CFG*>* otawa::dfa::hai::HalfAbsInt< FixPoint >::cfgStack
private
template<class FixPoint>
CFG* otawa::dfa::hai::HalfAbsInt< FixPoint >::cur_cfg
private
template<class FixPoint>
BasicBlock* otawa::dfa::hai::HalfAbsInt< FixPoint >::current
private
template<class FixPoint>
bool otawa::dfa::hai::HalfAbsInt< FixPoint >::enter_call
private
template<class FixPoint>
CFG& otawa::dfa::hai::HalfAbsInt< FixPoint >::entry_cfg
private
template<class FixPoint>
bool otawa::dfa::hai::HalfAbsInt< FixPoint >::fixpoint
private
template<class FixPoint>
Identifier< typename FixPoint::FixPointState * > otawa::dfa::hai::HalfAbsInt< FixPoint >::FIXPOINT_STATE
staticprivate
template<class FixPoint>
FixPoint& otawa::dfa::hai::HalfAbsInt< FixPoint >::fp
private
template<class FixPoint>
WorkSpace& otawa::dfa::hai::HalfAbsInt< FixPoint >::fw
private
template<class FixPoint>
FixPoint::Domain otawa::dfa::hai::HalfAbsInt< FixPoint >::in
private
template<class FixPoint>
bool otawa::dfa::hai::HalfAbsInt< FixPoint >::mainEntry
private
template<class FixPoint>
Edge* otawa::dfa::hai::HalfAbsInt< FixPoint >::next_edge
private
template<class FixPoint>
FixPoint::Domain otawa::dfa::hai::HalfAbsInt< FixPoint >::out
private
template<class FixPoint>
elm::genstruct::Vector<BasicBlock*>* otawa::dfa::hai::HalfAbsInt< FixPoint >::workList
private

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