5 #ifndef ILANG_ILA_MNGR_U_UNROLLER_SMT_H__
6 #define ILANG_ILA_MNGR_U_UNROLLER_SMT_H__
25 : smt_gen_(smt_shim), unroller_suffix_(suffix) {}
37 step_pred_[k].insert(p);
51 return smt_gen_.GetShimExpr(expr, SuffixCurrent(k));
55 return smt_gen_.GetShimExpr(expr, SuffixNext(k));
59 return smt_gen_.GetShimFunc(func);
67 const std::string unroller_suffix_;
74 std::map<size_t, ExprSet> step_pred_;
78 inline std::string SuffixCurrent(
const size_t& t)
const {
79 return std::to_string(t) +
"_" + unroller_suffix_;
82 inline std::string SuffixNext(
const size_t& t)
const {
83 return std::to_string(t) +
"_" + unroller_suffix_ +
".nxt";
88 typedef decltype(smt_gen_.GetShimExpr(
nullptr,
"")) SmtExpr;
89 typedef decltype(smt_gen_.GetShimFunc(
nullptr)) SmtFunc;
90 typedef std::vector<ExprPtr> IlaExprVec;
91 typedef std::vector<SmtExpr> SmtExprVec;
110 SmtExpr
Unroll_(
const size_t& len,
const size_t& begin);
117 inline void InterpIlaExprAndAppend(
const IlaExprVec& ila_expr_src,
118 const std::string& suffix,
119 SmtExprVec& smt_expr_dst) {
120 for (
const auto& e : ila_expr_src) {
121 smt_expr_dst.push_back(smt_gen_.GetShimExpr(e, suffix));
125 inline void InterpIlaExprAndAppend(
const ExprSet& ila_expr_src,
126 const std::string& suffix,
127 SmtExprVec& smt_expr_dst) {
128 for (
const auto& e : ila_expr_src) {
129 smt_expr_dst.push_back(smt_gen_.GetShimExpr(e, suffix));
133 inline void ElementWiseEqualAndAppend(
const SmtExprVec& a,
135 SmtExprVec& smt_expr_dst) {
137 for (
size_t i = 0; i < a.size(); i++) {
138 smt_expr_dst.push_back(smt_gen_.Equal(a.at(i), b.at(i)));
142 inline SmtExpr ConjunctAll(
const SmtExprVec& vec)
const {
143 auto conjunct_holder = smt_gen_.GetShimExpr(asthub::BoolConst(
true));
144 for (
const auto& e : vec) {
145 conjunct_holder = smt_gen_.BoolAnd(conjunct_holder, e);
147 return conjunct_holder;
164 return this->
Unroll_(seq.size(), begin);
190 #endif // ILANG_ILA_MNGR_U_UNROLLER_SMT_H__
auto GetSmtCurrent(const ExprPtr &expr, const size_t &k) const
Return the SMT formula of expr at the beginning k-th step.
Definition: u_unroller_smt.h:50
#define ILA_ASSERT(b)
Assertion with message logged to FATAL (lvl 3). (Debug)
Definition: log.h:33
auto Unroll(const InstrVec &seq, const size_t &begin=0)
Unroll the sequence.
Definition: u_unroller_smt.h:162
void AssertInitial(const ExprPtr &p)
Add the predicate p to be asserted at the first step (initial condition).
Definition: u_unroller_smt.h:34
Base class for unrolling ILA execution in different settings.
Definition: u_unroller_smt.h:20
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
std::vector< InstrPtr > InstrVec
Type for storing a set of Instr.
Definition: instr.h:136
void AssertGlobal(const ExprPtr &p)
Add the predicate p to be asserted globally.
Definition: u_unroller_smt.h:32
SmtExpr Unroll_(const size_t &len, const size_t &begin)
Unroll the whole sequence.
void SetDecidingVars()
Setup the deciding variables.
virtual void MakeOneTransition(const size_t &idx)=0
void AssertStep(const ExprPtr &p, const int &k)
Add the predicate p to be asserted at the k-th step.
Definition: u_unroller_smt.h:36
IlaExprVec update_holder_
State update functions of the deciding variables.
Definition: u_unroller_smt.h:97
void ClearStepAssertion()
Clear all the step-specific assertions.
Definition: u_unroller_smt.h:44
PathUnroller(SmtShim< Generator > &smt_shim, const std::string &suffix="")
Constructor.
Definition: u_unroller_smt.h:157
std::unordered_set< ExprPtr, ExprHash > ExprSet
Type for storing a set of Expr.
Definition: expr.h:153
void ClearInitialAssertion()
Clear all the initial assertions.
Definition: u_unroller_smt.h:42
IlaExprVec assert_holder_
Non-execution semantics (state update) properties.
Definition: u_unroller_smt.h:99
Func::FuncPtr FuncPtr
Pointer type for normal use of Func.
Definition: func.h:83
IlaExprVec deciding_vars_
Variables on which the instruction sequence depends.
Definition: u_unroller_smt.h:95
auto UnrollWithStepsUnconnected(const InstrVec &seq, const size_t &begin)
Unroll the sequence without connecting the steps.
Definition: u_unroller_smt.h:168
SmtExpr UnrollWithStepsUnconnected_(const size_t &len, const size_t &begin)
Unroll the whole sequence without connecting the steps.
Application class for unrolling a sequence of instructions.
Definition: u_unroller_smt.h:153
void MakeOneTransition(const size_t &idx)
Make one transition and setup holders accordingly.
UnrollerSmt(SmtShim< Generator > &smt_shim, const std::string &suffix)
Constructor.
Definition: u_unroller_smt.h:24
auto GetSmtFuncDecl(const FuncPtr &func) const
Return the SMT function declaration of uninterpreted function func.
Definition: u_unroller_smt.h:58
A templated class for wrapping z3 and smt-switch to provide a unified interface for different applica...
Definition: smt_shim.h:15
void ClearGlobalAssertion()
Clear all the global assertions.
Definition: u_unroller_smt.h:40
auto GetSmtNext(const ExprPtr &expr, const size_t &k) const
Return the SMT formula of expr at the end of k-th step.
Definition: u_unroller_smt.h:54
virtual void SetDecidingVars()=0
Setup the deciding variabels.