LCOV - code coverage report
Current view: top level - home/yyan7/compiler/rexompiler/src/midend/programTransformation/finiteDifferencing - patternRewrite.h (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 9 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #ifndef PATTERNREWRITE_H
       2             : #define PATTERNREWRITE_H
       3             : 
       4             : // #include "config.h"
       5             : 
       6             : //#include "rose.h"
       7             : #include <vector>
       8             : 
       9             : //! Definition of a rewrite rule on a given SgNode.  The rule modifies the node
      10             : //! and/or its children in-place, and then returns true for success or false for
      11             : //! failure.
      12           0 : class RewriteRule {
      13             :   public:
      14             :   virtual bool doRewrite(SgNode*& n) const = 0;
      15             : // Liao (2/7/2008): Added destructor to eliminate g++ compiler warning.
      16           0 :   virtual ~RewriteRule(){}
      17             : };
      18             : 
      19             : //! Combine several rules into one, doing the constituents in order
      20           0 : class RewriteRuleCombiner: public RewriteRule {
      21             :   std::vector<RewriteRule*> rules;
      22             : 
      23             :   public:
      24             :   std::vector<RewriteRule*>& getRules() {return rules;}
      25             :   const std::vector<RewriteRule*>& getRules() const {return rules;}
      26             : 
      27           0 :   void add(RewriteRule* r) {rules.push_back(r);}
      28             : 
      29             :   virtual bool doRewrite(SgNode*& n) const;
      30             : 
      31             : // DQ (12/16/2006): Added destructor to eliminate g++ compiler warning.
      32           0 :   virtual ~RewriteRuleCombiner() {}      
      33             : };
      34             : 
      35             : //! Rewrite a node and its children recursively using a rule.  Iterate until no
      36             : //! more changes can be made.
      37             : ROSE_DLL_API void rewrite(RewriteRule* rule, SgNode*& top);
      38             : 
      39             : //! Replace a child of a node.
      40             : void replaceChild(SgNode* parent, SgNode* from, SgNode* to);
      41             : 
      42             : typedef std::map<std::string, SgNode*> PatternVariables;
      43             : 
      44             : //! Abstract interface for a pattern which can match ASTs
      45           0 : class Pattern {
      46             :   public:
      47             :   virtual bool match(SgNode* top, PatternVariables& vars) const = 0;
      48             :   virtual SgNode* subst(PatternVariables& vars) const = 0;
      49             : // Liao (2/7/2008): Added destructor to eliminate g++ compiler warning.
      50             :   virtual ~Pattern(){}
      51             : };
      52             : 
      53             : //! A rule which changes one pattern of code to another
      54             : class PatternActionRule: public RewriteRule {
      55             :   Pattern* pattern;
      56             :   Pattern* action;
      57             : 
      58             :   public:
      59           0 :   PatternActionRule(Pattern* pattern, Pattern* action):
      60           0 :     pattern(pattern), action(action) {}
      61             : 
      62             :   virtual bool doRewrite(SgNode*& n) const;
      63             : // Liao (2/7/2008): Added destructor to eliminate g++ compiler warning.
      64           0 :   virtual ~PatternActionRule(){}
      65             : };
      66             : 
      67             : //! Create a PatternActionRule
      68             : PatternActionRule* patact(Pattern* pattern, Pattern* action);
      69             : 
      70             : //! Match an addition operation
      71             : Pattern* p_AddOp(Pattern* lhs, Pattern* rhs);
      72             : 
      73             : //! Match a multiplication operation
      74             : Pattern* p_MultiplyOp(Pattern* lhs, Pattern* rhs);
      75             : 
      76             : //! Match an add-assign operation
      77             : Pattern* p_PlusAssignOp(Pattern* lhs, Pattern* rhs);
      78             : 
      79             : //! Match a comma operation
      80             : Pattern* p_CommaOp(Pattern* lhs, Pattern* rhs);
      81             : 
      82             : //! Match anything into a variable
      83             : Pattern* p_var(std::string name);
      84             : 
      85             : //! Match any constant into a variable
      86             : Pattern* p_value(std::string name);
      87             : 
      88             : //! Match a particular integer
      89             : Pattern* p_int(int x);
      90             : 
      91             : //! Match anything
      92             : extern Pattern* p_wildcard;
      93             : 
      94             : //! A standard set of algebraic rules for simple optimizations
      95             : ROSE_DLL_API RewriteRule* getAlgebraicRules();
      96             : 
      97             : //! A standard set of algebraic and finite-differencing rules
      98             : RewriteRule* getFiniteDifferencingRules();
      99             : 
     100             : #endif // PATTERNREWRITE_H

Generated by: LCOV version 1.14