ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
u_rewriter.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_ILA_MNGR_U_REWRITER_H__
5 #define ILANG_ILA_MNGR_U_REWRITER_H__
6 
8 
9 namespace ilang {
10 
13 public:
15  FuncObjRewrExpr(const ExprMap& rule) : rule_(rule) {}
16 
18  ExprPtr get(const ExprPtr& e) const;
19 
21  bool pre(const ExprPtr& e) const;
23  void post(const ExprPtr& e);
24 
25 protected:
28 
30  virtual ExprPtr Rewrite(const ExprPtr& e) const;
32  virtual ExprPtr RewriteOp(const ExprPtr& e) const;
33 
34 }; // class FuncObjRewrExpr
35 
38 private:
40  typedef CnstIlaMap IlaMap;
41 
42 public:
44  FuncObjRewrIla(const IlaMap& ila_map, const ExprMap& expr_map)
45  : ila_map_(ila_map), expr_map_(expr_map) {}
46 
48  InstrLvlAbsPtr get(const InstrLvlAbsCnstPtr& m) const;
49 
51  bool pre(const InstrLvlAbsCnstPtr& src);
53  void post(const InstrLvlAbsCnstPtr& src) const;
54 
55 private:
57  IlaMap ila_map_;
59  ExprMap expr_map_;
60 
61 }; // FuncObjRewrIla
62 
65 
66  /* There is currently a problem:
67  This func obj calls duplInst which in turn uses rewriteExpr and rewriteExpr
68  does not change the host of of state variables, so the flatten expression
69  still has the host pointed to their original ILA. This is fine for Verilog
70  Gen, which only depends on variable names to generate variables but may not be
71  good enough for other purpose.
72  - Hongce
73  */
74 
75 private:
77  typedef CnstIlaMap IlaMap;
78 
79 public:
81  FuncObjFlatIla(const InstrLvlAbsCnstPtr& top_, const IlaMap& ila_map,
82  const ExprMap& expr_map);
83 
85  bool pre(const InstrLvlAbsCnstPtr& src);
87  void post(const InstrLvlAbsCnstPtr& src);
88 
89 private:
91  typedef std::stack<ExprPtr> ValidCondStack;
92 
94  IlaMap ila_map_;
96  ExprMap expr_map_;
98  ValidCondStack valid_cond_stack_;
100  InstrLvlAbsCnstPtr top_ila_;
101 }; // FuncObjRewrIla
102 
103 } // namespace ilang
104 
105 #endif // ILANG_ILA_MNGR_U_REWRITER_H__
Function object for rewriting ILA tree.
Definition: u_rewriter.h:37
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
InstrLvlAbs::InstrLvlAbsCnstPtr InstrLvlAbsCnstPtr
Pointer type for read-only usage of InstrLvlAbs.
Definition: instr_lvl_abs.h:328
FuncObjFlatIla(const InstrLvlAbsCnstPtr &top_, const IlaMap &ila_map, const ExprMap &expr_map)
Constructor.
FuncObjRewrExpr(const ExprMap &rule)
Constructor, initialize rewriting rule.
Definition: u_rewriter.h:15
bool pre(const InstrLvlAbsCnstPtr &src)
Pre-processing: create new ILA based on the given source.
bool pre(const ExprPtr &e) const
Pre-process: return true (break) if the node has been visited.
Function object for rewriting Expr.
Definition: u_rewriter.h:12
Function object for flatten ILA tree.
Definition: u_rewriter.h:64
virtual ExprPtr RewriteOp(const ExprPtr &e) const
Rewrite Operation sorted Expr.
std::map< InstrLvlAbsCnstPtr, InstrLvlAbsPtr > CnstIlaMap
Type for storing a mapping from constant ILA ptr to ILA ptr.
Definition: instr_lvl_abs.h:330
ExprMap rule_
Internal rewriting table.
Definition: u_rewriter.h:27
bool pre(const InstrLvlAbsCnstPtr &src)
Pre-processing: create new ILA based on the given source.
void post(const InstrLvlAbsCnstPtr &src) const
Nothing.
std::unordered_map< const ExprPtr, const ExprPtr, ExprHash > ExprMap
Type for mapping between Expr.
Definition: expr.h:151
InstrLvlAbs::InstrLvlAbsPtr InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:326
virtual ExprPtr Rewrite(const ExprPtr &e) const
Rewrite all sorts of Expr.
void post(const ExprPtr &e)
Post-process: update the rewriting rule map.
FuncObjRewrIla(const IlaMap &ila_map, const ExprMap &expr_map)
Constructor.
Definition: u_rewriter.h:44
void post(const InstrLvlAbsCnstPtr &src)
Nothing.