ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
hash_ast.h
Go to the documentation of this file.
1 
5 #ifndef ILANG_ILA_HASH_AST_H__
6 #define ILANG_ILA_HASH_AST_H__
7 
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11 
12 #include <ilang/ila/ast_hub.h>
13 
15 namespace ilang {
16 
18 class ExprMngr {
19 public:
21  typedef std::shared_ptr<ExprMngr> ExprMngrPtr;
22 
23  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
25  ExprMngr();
27  ~ExprMngr();
28 
29  // ------------------------- HELPERS -------------------------------------- //
32  static ExprMngrPtr New();
33 
34  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
36  void clear();
37 
38  // ------------------------- METHODS -------------------------------------- //
40  ExprPtr GetRep(const ExprPtr& node);
42  void operator()(const ExprPtr& node);
43 
44 private:
45  // ------------------------- MEMBERS -------------------------------------- //
47  std::unordered_map<std::string, ExprPtr> map_;
48 
49  // ------------------------- HELPER FUNCTIONS ----------------------------- //
51  static std::string Hash(const ExprPtr& node);
52 
53 }; // class ExprMngr
54 
57 
58 } // namespace ilang
59 
60 #endif // ILANG_ILA_HASH_AST_H__
ExprMngr()
Default constructor.
ExprPtr GetRep(const ExprPtr &node)
Return the AST node representative.
ExprMngr::ExprMngrPtr ExprMngrPtr
Pointer type for passing shared ast simplifier.
Definition: hash_ast.h:56
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
~ExprMngr()
Default destructor.
void operator()(const ExprPtr &node)
Function object for sharing ast nodes.
static ExprMngrPtr New()
Create an object and return the pointer. Used for hiding implementation specific types.
void clear()
Reset the hash table.
Simplifier for AST trees by sharing nodes based on the hash value.
Definition: hash_ast.h:18
std::shared_ptr< ExprMngr > ExprMngrPtr
Pointer type for passing shared ast simplifier.
Definition: hash_ast.h:21