3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

update topological sort to use arrays instead of hash tables, expose Context over Z3Object for programmability

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2022-06-08 06:28:24 -07:00
parent 0e6c64510a
commit 51ed13f96a
17 changed files with 103 additions and 96 deletions

View file

@ -78,7 +78,7 @@ namespace {
public:
unsigned char operator()(func_decl * lbl) {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
if (lbl_id >= m_lbl2hash.size())
m_lbl2hash.resize(lbl_id + 1, -1);
if (m_lbl2hash[lbl_id] == -1) {
@ -2906,7 +2906,7 @@ namespace {
SASSERT(first_idx < mp->get_num_args());
app * p = to_app(mp->get_arg(first_idx));
func_decl * lbl = p->get_decl();
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
m_trees.reserve(lbl_id+1, nullptr);
if (m_trees[lbl_id] == nullptr) {
m_trees[lbl_id] = m_compiler.mk_tree(qa, mp, first_idx, false);
@ -2935,7 +2935,7 @@ namespace {
}
code_tree * get_code_tree_for(func_decl * lbl) const {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
if (lbl_id < m_trees.size())
return m_trees[lbl_id];
else
@ -3165,11 +3165,11 @@ namespace {
}
bool is_plbl(func_decl * lbl) const {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
return lbl_id < m_is_plbl.size() && m_is_plbl[lbl_id];
}
bool is_clbl(func_decl * lbl) const {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
return lbl_id < m_is_clbl.size() && m_is_clbl[lbl_id];
}
@ -3182,7 +3182,7 @@ namespace {
}
void update_clbls(func_decl * lbl) {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
m_is_clbl.reserve(lbl_id+1, false);
TRACE("trigger_bug", tout << "update_clbls: " << lbl->get_name() << " is already clbl: " << m_is_clbl[lbl_id] << "\n";);
TRACE("mam_bug", tout << "update_clbls: " << lbl->get_name() << " is already clbl: " << m_is_clbl[lbl_id] << "\n";);
@ -3222,7 +3222,7 @@ namespace {
}
void update_plbls(func_decl * lbl) {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
m_is_plbl.reserve(lbl_id+1, false);
TRACE("trigger_bug", tout << "update_plbls: " << lbl->get_name() << " is already plbl: " << m_is_plbl[lbl_id] << ", lbl_id: " << lbl_id << "\n";
tout << "mam: " << this << "\n";);
@ -3744,7 +3744,7 @@ namespace {
app * p = to_app(mp->get_arg(0));
func_decl * lbl = p->get_decl();
if (m_context.get_num_enodes_of(lbl) > 0) {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
m_tmp_trees.reserve(lbl_id+1, 0);
if (m_tmp_trees[lbl_id] == 0) {
m_tmp_trees[lbl_id] = m_compiler.mk_tree(qa, mp, 0, false);
@ -3757,7 +3757,7 @@ namespace {
}
for (func_decl * lbl : m_tmp_trees_to_delete) {
unsigned lbl_id = lbl->get_decl_id();
unsigned lbl_id = lbl->get_small_id();
code_tree * tmp_tree = m_tmp_trees[lbl_id];
SASSERT(tmp_tree != 0);
SASSERT(m_context.get_num_enodes_of(lbl) > 0);
@ -3963,7 +3963,7 @@ namespace {
unsigned h = m_lbl_hasher(lbl);
TRACE("trigger_bug", tout << "lbl: " << lbl->get_name() << " is_clbl(lbl): " << is_clbl(lbl)
<< ", is_plbl(lbl): " << is_plbl(lbl) << ", h: " << h << "\n";
tout << "lbl_id: " << lbl->get_decl_id() << "\n";);
tout << "lbl_id: " << lbl->get_small_id() << "\n";);
if (is_clbl(lbl))
update_lbls(n, h);
if (is_plbl(lbl))

View file

@ -531,22 +531,22 @@ namespace smt {
}
unsigned get_num_enodes_of(func_decl const * decl) const {
unsigned id = decl->get_decl_id();
unsigned id = decl->get_small_id();
return id < m_decl2enodes.size() ? m_decl2enodes[id].size() : 0;
}
enode_vector const& enodes_of(func_decl const * d) const {
unsigned id = d->get_decl_id();
unsigned id = d->get_small_id();
return id < m_decl2enodes.size() ? m_decl2enodes[id] : m_empty_vector;
}
enode_vector::const_iterator begin_enodes_of(func_decl const * decl) const {
unsigned id = decl->get_decl_id();
unsigned id = decl->get_small_id();
return id < m_decl2enodes.size() ? m_decl2enodes[id].begin() : nullptr;
}
enode_vector::const_iterator end_enodes_of(func_decl const * decl) const {
unsigned id = decl->get_decl_id();
unsigned id = decl->get_small_id();
return id < m_decl2enodes.size() ? m_decl2enodes[id].end() : nullptr;
}

View file

@ -171,7 +171,7 @@ namespace smt {
unsigned get_expr_id() const { return m_owner->get_id(); }
func_decl * get_decl() const { return m_owner->get_decl(); }
unsigned get_decl_id() const { return m_owner->get_decl()->get_decl_id(); }
unsigned get_decl_id() const { return m_owner->get_decl()->get_small_id(); }
sort* get_sort() const { return m_owner->get_sort(); }

View file

@ -1010,7 +1010,7 @@ namespace smt {
}
}
if (!e->is_eq()) {
unsigned decl_id = n->get_decl()->get_decl_id();
unsigned decl_id = n->get_decl()->get_small_id();
if (decl_id >= m_decl2enodes.size())
m_decl2enodes.resize(decl_id+1);
m_decl2enodes[decl_id].push_back(e);
@ -1054,7 +1054,7 @@ namespace smt {
m_cg_table.erase(e);
}
if (e->get_num_args() > 0 && !e->is_eq()) {
unsigned decl_id = to_app(n)->get_decl()->get_decl_id();
unsigned decl_id = to_app(n)->get_decl()->get_small_id();
SASSERT(decl_id < m_decl2enodes.size());
SASSERT(m_decl2enodes[decl_id].back() == e);
m_decl2enodes[decl_id].pop_back();