ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
z3_expr_adapter.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_TARGET_SMT_Z3_EXPR_ADAPTER_H__
5 #define ILANG_TARGET_SMT_Z3_EXPR_ADAPTER_H__
6 
7 #include <unordered_map>
8 
9 #include <z3++.h>
10 
11 #include <ilang/ila/ast_hub.h>
12 
14 namespace ilang {
15 
18 
21 public:
22  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
24  Z3ExprAdapter(z3::context& ctx);
27 
28  // ------------------------- METHODS -------------------------------------- //
30  z3::expr GetExpr(const ExprPtr& expr, const std::string& suffix = "");
31 
33  void operator()(const ExprPtr& expr);
34 
36  inline z3::context& context() const { return ctx_; }
37 
38  // ------------------------- SHIM INTERFACE ------------------------------- //
40  inline auto GetShimExpr(const ExprPtr& expr, const std::string& suffix) {
41  return GetExpr(expr, suffix);
42  }
44  inline auto GetShimFunc(const FuncPtr& func) {
45  return func->GetZ3FuncDecl(ctx_);
46  }
48  inline auto BoolAnd(const z3::expr& a, const z3::expr& b) { return a && b; }
50  inline auto Equal(const z3::expr& a, const z3::expr& b) { return a == b; }
51 
52 private:
54  typedef std::unordered_map<const ExprPtr, z3::expr, Z3AdapterHash> ExprMap;
55 
56  // ------------------------- MEMBERS -------------------------------------- //
58  z3::context& ctx_;
60  ExprMap expr_map_;
62  std::string suffix_ = "";
63 
64  // ------------------------- HELPERS -------------------------------------- //
66  void PopulateExprMap(const ExprPtr& expr);
67 
68 }; // class Z3ExprAdapter
69 
70 } // namespace ilang
71 
72 #endif // ILANG_TARGET_SMT_Z3_EXPR_ADAPTER_H__
auto Equal(const z3::expr &a, const z3::expr &b)
Unified SmtShim interface to EQUAL two z3::expr.
Definition: z3_expr_adapter.h:50
auto GetShimFunc(const FuncPtr &func)
Unified SmtShim interface to get z3::func_decl.
Definition: z3_expr_adapter.h:44
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
The function object for hashing Expr. The hash value is the id of the symbol, which is supposed to be...
Definition: expr.h:144
Z3ExprAdapter(z3::context &ctx)
Constructor.
ExprHash Z3AdapterHash
The function object for hashing Expr in generating z3 expression.
Definition: z3_expr_adapter.h:17
auto BoolAnd(const z3::expr &a, const z3::expr &b)
Unified SmtShim interface to AND two boolean z3::expr.
Definition: z3_expr_adapter.h:48
Func::FuncPtr FuncPtr
Pointer type for normal use of Func.
Definition: func.h:83
z3::expr GetExpr(const ExprPtr &expr, const std::string &suffix="")
Get the z3 expression of the AST node.
std::unordered_map< const ExprPtr, const ExprPtr, ExprHash > ExprMap
Type for mapping between Expr.
Definition: expr.h:151
void operator()(const ExprPtr &expr)
Function object for getting z3 expression.
z3::context & context() const
Return the underlying z3 context.
Definition: z3_expr_adapter.h:36
The class for generating z3 expression from an ILA.
Definition: z3_expr_adapter.h:20
auto GetShimExpr(const ExprPtr &expr, const std::string &suffix)
Unified SmtShim interface to get z3::expr.
Definition: z3_expr_adapter.h:40
~Z3ExprAdapter()
~Default destructor.