Program Listing for File AnalysisInterface.h

Program Listing for File AnalysisInterface.h#

Return to documentation for file (src/midend/astUtil/astSupport/AnalysisInterface.h)

#ifndef ANALYSIS_INTERFACE_H
#define ANALYSIS_INTERFACE_H

#include "FunctionObject.h"
#include "SymbolicVal.h"

class FunctionSideEffectInterface
{
 public:
  // returns false if unknown function encountered
  virtual bool get_modify(AstInterface& fa, const AstNodePtr& fc,
                               CollectObject<AstNodePtr>* collect = 0) = 0 ;

  virtual bool get_read(AstInterface& fa, const AstNodePtr& fc,
                               CollectObject<AstNodePtr>* collect = 0) = 0;
  virtual ~FunctionSideEffectInterface() {}
};

class NoFunctionSideEffectAnalysis : public FunctionSideEffectInterface
{
 public:
  virtual bool get_modify(AstInterface& fa, const AstNodePtr& fc,
                               CollectObject<AstNodePtr>* collect = 0)
   { return false; }
  virtual bool get_read(AstInterface& fa, const AstNodePtr& fc,
                               CollectObject<AstNodePtr>* collect = 0)
   { return false; }
  virtual ~NoFunctionSideEffectAnalysis() {}
};

class SideEffectAnalysisInterface
{
 public:
  // returns false if stmts may ---modify-- unknown (non-collected) locations
  virtual bool
   get_side_effect( AstInterface& fa, const AstNodePtr& stmts,
                    CollectObject< std::pair<AstNodePtr, AstNodePtr> >* mod,
                    CollectObject< std::pair<AstNodePtr, AstNodePtr> >* read= 0,
                    CollectObject< std::pair<AstNodePtr, AstNodePtr> >* kill = 0) = 0;
  virtual ~SideEffectAnalysisInterface() {}
};

class FunctionAliasInterface
{
 public:
  // returns false if unknown function encountered
  virtual bool
     may_alias(AstInterface& fa, const AstNodePtr& fc, const AstNodePtr& result,
               CollectObject< std::pair<AstNodePtr, int> >& collectalias) = 0;
  virtual bool
     allow_alias(AstInterface& fa, const AstNodePtr& fc,
               CollectObject< std::pair<AstNodePtr, int> >& collectalias) = 0;
  virtual ~FunctionAliasInterface() {}
};

class NoFunctionAliasAnalysis : public FunctionAliasInterface
{
 public:
  virtual bool
    may_alias(AstInterface& fa, const AstNodePtr& fc, const AstNodePtr& result,
              CollectObject< std::pair<AstNodePtr, int> >& collectalias)
   { return false; }
  virtual ~NoFunctionAliasAnalysis() {}
};

class AliasAnalysisInterface
{
 public:
  virtual void analyze(AstInterface& fa, const AstNodePtr& f) {}
  virtual bool
     may_alias(AstInterface& fa, const AstNodePtr& r1, const AstNodePtr& r2) = 0;
  virtual ~AliasAnalysisInterface() {}
};

class AssumeNoAlias : public AliasAnalysisInterface
{
 public:
  virtual bool may_alias(AstInterface& fa, const AstNodePtr& r1, const AstNodePtr& r2)
   { return false; }
};

// This is the interface to access loop structure stored in AST.
class LoopInterface
{
public:
  virtual ~LoopInterface() {}

  virtual bool
  IsLoop(AstInterface& __fa, const AstNodePtr& __fc,
         AstNodePtr* __init = 0, AstNodePtr* __cond = 0, AstNodePtr* __incr = 0,
         //SymbolicVal* __init = 0, SymbolicVal* __cond = 0, SymbolicVal* __incr = 0,
         AstNodePtr* __body = 0) const = 0;

  virtual bool
  IsFortranLoop(AstInterface& __fa, const AstNodePtr& __fc,
        AstNodePtr* __ivar = 0, AstNodePtr* __start = 0, AstNodePtr* __stop = 0, AstNodePtr* __step = 0,
        AstNodePtr* __body = 0) const = 0;
};

// interface FunctionInterface
#endif