mirror of
https://github.com/Z3Prover/z3
synced 2025-09-05 01:27:41 +00:00
Merge branch 'master' into polysat
This commit is contained in:
commit
e5e79c1d4b
398 changed files with 24548 additions and 4983 deletions
|
@ -19,7 +19,7 @@ Notes:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include<climits>
|
||||
|
||||
class approx_nat {
|
||||
|
|
|
@ -17,7 +17,7 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#pragma once
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include "util/debug.h"
|
||||
|
||||
template<typename T> class approx_set_traits;
|
||||
|
|
|
@ -14,7 +14,6 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include "util/cmd_context_types.h"
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, cmd_arg_kind k) {
|
||||
|
|
|
@ -18,6 +18,7 @@ Notes:
|
|||
|
||||
#include "util/symbol.h"
|
||||
#include "util/z3_exception.h"
|
||||
#include <ostream>
|
||||
#include<sstream>
|
||||
class rational;
|
||||
class expr;
|
||||
|
|
|
@ -19,7 +19,7 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include "util/debug.h"
|
||||
|
||||
enum ext_numeral_kind { EN_MINUS_INFINITY, EN_NUMERAL, EN_PLUS_INFINITY };
|
||||
|
|
|
@ -534,6 +534,11 @@ public:
|
|||
d->display(out, 4, false);
|
||||
}
|
||||
|
||||
param_descrs const& get_global_param_descrs() {
|
||||
lock_guard lock(*gparams_mux);
|
||||
return get_param_descrs();
|
||||
}
|
||||
|
||||
void display_parameter(std::ostream & out, char const * name) {
|
||||
std::string m, p;
|
||||
normalize(name, m, p);
|
||||
|
@ -624,6 +629,10 @@ void gparams::display(std::ostream & out, unsigned indent, bool smt2_style, bool
|
|||
g_imp->display(out, indent, smt2_style, include_descr);
|
||||
}
|
||||
|
||||
param_descrs const& gparams::get_global_param_descrs() {
|
||||
return g_imp->get_global_param_descrs();
|
||||
}
|
||||
|
||||
void gparams::display_modules(std::ostream & out) {
|
||||
SASSERT(g_imp);
|
||||
g_imp->display_modules(out);
|
||||
|
|
|
@ -120,6 +120,7 @@ public:
|
|||
static void display_modules(std::ostream & out);
|
||||
static void display_module(std::ostream & out, char const * module_name);
|
||||
static void display_parameter(std::ostream & out, char const * name);
|
||||
static param_descrs const& get_global_param_descrs();
|
||||
|
||||
/**
|
||||
\brief Initialize the global parameter management module.
|
||||
|
|
|
@ -38,9 +38,8 @@ class max_cliques : public T {
|
|||
m_todo.push_back(p);
|
||||
for (unsigned i = 0; i < m_todo.size(); ++i) {
|
||||
p = m_todo[i];
|
||||
if (m_seen1.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
if (m_seen1.contains(p))
|
||||
continue;
|
||||
m_seen1.insert(p);
|
||||
if (m_seen2.contains(p)) {
|
||||
unsigned_vector const& tc = m_tc[p];
|
||||
|
@ -50,14 +49,12 @@ class max_cliques : public T {
|
|||
}
|
||||
else {
|
||||
unsigned np = negate(p);
|
||||
if (goal.contains(np)) {
|
||||
reachable.insert(np);
|
||||
}
|
||||
if (goal.contains(np))
|
||||
reachable.insert(np);
|
||||
m_todo.append(next(np));
|
||||
}
|
||||
}
|
||||
for (unsigned i = m_todo.size(); i > 0; ) {
|
||||
--i;
|
||||
for (unsigned i = m_todo.size(); i-- > 0; ) {
|
||||
p = m_todo[i];
|
||||
if (m_seen2.contains(p))
|
||||
continue;
|
||||
|
@ -181,7 +178,7 @@ public:
|
|||
next.push_back(n);
|
||||
std::sort(next.begin(), next.end(), [&](unsigned a, unsigned b) { return conns[a].num_elems() < conns[b].num_elems(); });
|
||||
for (unsigned x : next) {
|
||||
bool all = true;
|
||||
bool all = heap.contains(x);
|
||||
for (unsigned y : am1) {
|
||||
if (!conns[x].contains(y)) {
|
||||
all = false;
|
||||
|
@ -190,15 +187,18 @@ public:
|
|||
}
|
||||
if (all)
|
||||
am1.insert(x);
|
||||
}
|
||||
}
|
||||
am1.insert(v);
|
||||
|
||||
for (unsigned x : am1) {
|
||||
todo.remove(x);
|
||||
for (unsigned y : conns[x]) {
|
||||
conns[y].remove(x);
|
||||
heap.decreased(y);
|
||||
if (heap.contains(y))
|
||||
heap.decreased(y);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned x : am1)
|
||||
heap.erase(x);
|
||||
|
||||
|
@ -206,9 +206,8 @@ public:
|
|||
unsigned_vector mux;
|
||||
for (unsigned x : am1)
|
||||
mux.push_back(x);
|
||||
if (mux.size() == 2 && mux[0] == negate(mux[1])) {
|
||||
continue;
|
||||
}
|
||||
if (mux.size() == 2 && mux[0] == negate(mux[1]))
|
||||
continue;
|
||||
cliques.push_back(mux);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -904,8 +904,6 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
SASSERT(m_mpz_manager.lt(res.significand(), m_powers2(2 * x.sbits + 1 + 3)));
|
||||
if (m_mpz_manager.ge(res.significand(), m_powers2(2 * x.sbits + 3)))
|
||||
{
|
||||
SASSERT(exp(res) < mk_max_exp(x.ebits)); // NYI.
|
||||
|
||||
res.get().exponent++;
|
||||
renorm_sticky = !m_mpz_manager.is_even(res.significand());
|
||||
m_mpz_manager.machine_div2k(res.significand(), 1);
|
||||
|
@ -923,26 +921,32 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
|
||||
TRACE("mpf_dbg", tout << "R*= " << to_string_binary(res, 2, 0) << " (renormalized, delta=" << renorm_delta << ")" << std::endl;);
|
||||
|
||||
set(o, x.ebits, x.sbits, res.sign(), res.exponent(), mpz(0));
|
||||
if (exp(res) <= mk_max_exp(x.ebits))
|
||||
{
|
||||
set(o, x.ebits, x.sbits, res.sign(), res.exponent(), mpz(0));
|
||||
|
||||
if (x.sbits >= 4) {
|
||||
m_mpz_manager.machine_div_rem(res.significand(), m_powers2(x.sbits - 4 + 3), o.significand, sticky_rem);
|
||||
renorm_sticky |= !m_mpz_manager.is_zero(sticky_rem);
|
||||
if (x.sbits >= 4) {
|
||||
m_mpz_manager.machine_div_rem(res.significand(), m_powers2(x.sbits - 4 + 3), o.significand, sticky_rem);
|
||||
renorm_sticky |= !m_mpz_manager.is_zero(sticky_rem);
|
||||
}
|
||||
else {
|
||||
m_mpz_manager.mul2k(res.significand(), 4 - x.sbits + 3, o.significand);
|
||||
}
|
||||
|
||||
if (renorm_sticky && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "sum[-1:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;
|
||||
tout << "R = " << to_string_binary(o, 1, 3) << std::endl;);
|
||||
|
||||
if (m_mpz_manager.is_zero(o.significand))
|
||||
mk_zero(x.ebits, x.sbits, rm == MPF_ROUND_TOWARD_NEGATIVE, o);
|
||||
else
|
||||
round(rm, o);
|
||||
}
|
||||
else {
|
||||
m_mpz_manager.mul2k(res.significand(), 4 - x.sbits + 3, o.significand);
|
||||
mk_inf(x.ebits, x.sbits, res.sign(), o);
|
||||
}
|
||||
|
||||
if (renorm_sticky && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "sum[-1:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;
|
||||
tout << "R = " << to_string_binary(o, 1, 3) << std::endl;);
|
||||
|
||||
if (m_mpz_manager.is_zero(o.significand))
|
||||
mk_zero(x.ebits, x.sbits, rm == MPF_ROUND_TOWARD_NEGATIVE, o);
|
||||
else
|
||||
round(rm, o);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1849,7 +1849,7 @@ std::string mpz_manager<SYNCH>::to_string(mpz const & a) const {
|
|||
template<bool SYNCH>
|
||||
unsigned mpz_manager<SYNCH>::hash(mpz const & a) {
|
||||
if (is_small(a))
|
||||
return a.m_val;
|
||||
return ::abs(a.m_val);
|
||||
#ifndef _MP_GMP
|
||||
unsigned sz = size(a);
|
||||
if (sz == 1)
|
||||
|
@ -2255,6 +2255,9 @@ template<bool SYNCH>
|
|||
unsigned mpz_manager<SYNCH>::mlog2(mpz const & a) {
|
||||
if (is_nonneg(a))
|
||||
return 0;
|
||||
if (is_small(a) && a.m_val == INT_MIN)
|
||||
return ::log2((unsigned)a.m_val);
|
||||
|
||||
if (is_small(a))
|
||||
return ::log2((unsigned)-a.m_val);
|
||||
#ifndef _MP_GMP
|
||||
|
|
|
@ -1046,6 +1046,7 @@ void params::set_sym(char const * k, symbol const & v) {
|
|||
}
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
#include <iostream>
|
||||
void pp(params_ref const & p) {
|
||||
std::cout << p << std::endl;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include "util/vector.h"
|
||||
|
||||
class permutation {
|
||||
|
|
|
@ -238,11 +238,17 @@ public:
|
|||
rational::m().mod(r1.m_val, r2.m_val, r.m_val);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
friend inline void mod(rational const & r1, rational const & r2, rational & r) {
|
||||
rational::m().mod(r1.m_val, r2.m_val, r.m_val);
|
||||
}
|
||||
|
||||
friend inline rational mod2k(rational const & a, unsigned k) {
|
||||
if (a.is_nonneg() && a.is_int() && a.bitsize() <= k)
|
||||
return a;
|
||||
return mod(a, power_of_two(k));
|
||||
}
|
||||
|
||||
friend inline rational operator%(rational const & r1, rational const & r2) {
|
||||
rational r;
|
||||
rational::m().rem(r1.m_val, r2.m_val, r.m_val);
|
||||
|
|
|
@ -18,7 +18,7 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
#include<cstdlib>
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ namespace sat {
|
|||
inline bool operator!=(literal const & l1, literal const & l2) { return l1.m_val != l2.m_val; }
|
||||
|
||||
inline std::ostream & operator<<(std::ostream & out, sat::literal l) { if (l == sat::null_literal) out << "null"; else out << (l.sign() ? "-" : "") << l.var(); return out; }
|
||||
|
||||
|
||||
|
||||
typedef svector<literal> literal_vector;
|
||||
|
@ -192,3 +193,11 @@ namespace sat {
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
namespace std {
|
||||
|
||||
inline std::string to_string(sat::literal l) {
|
||||
if (l.sign()) return "-" + to_string(l.var());
|
||||
return to_string(l.var());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,6 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<signal.h>
|
||||
#include<iostream>
|
||||
#include "util/scoped_ctrl_c.h"
|
||||
|
||||
static scoped_ctrl_c * g_obj = nullptr;
|
||||
|
|
|
@ -51,10 +51,9 @@ static atomic<unsigned> num_workers(0);
|
|||
static void thread_func(scoped_timer_state *s) {
|
||||
workers.lock();
|
||||
while (true) {
|
||||
s->cv.wait(workers, [=]{ return s->work > IDLE; });
|
||||
s->cv.wait(workers, [=]{ return s->work != IDLE; });
|
||||
workers.unlock();
|
||||
|
||||
// exiting..
|
||||
if (s->work == EXITING)
|
||||
return;
|
||||
|
||||
|
@ -81,26 +80,20 @@ scoped_timer::scoped_timer(unsigned ms, event_handler * eh) {
|
|||
return;
|
||||
|
||||
workers.lock();
|
||||
bool new_worker = false;
|
||||
if (available_workers.empty()) {
|
||||
// start new thead
|
||||
workers.unlock();
|
||||
s = new scoped_timer_state;
|
||||
new_worker = true;
|
||||
++num_workers;
|
||||
}
|
||||
else {
|
||||
s = available_workers.back();
|
||||
available_workers.pop_back();
|
||||
workers.unlock();
|
||||
}
|
||||
s->ms = ms;
|
||||
s->eh = eh;
|
||||
s->m_mutex.lock();
|
||||
s->work = WORKING;
|
||||
if (new_worker) {
|
||||
init_state(ms, eh);
|
||||
s->m_thread = std::thread(thread_func, s);
|
||||
}
|
||||
else {
|
||||
// re-use existing thread
|
||||
s = available_workers.back();
|
||||
available_workers.pop_back();
|
||||
init_state(ms, eh);
|
||||
workers.unlock();
|
||||
s->cv.notify_one();
|
||||
}
|
||||
}
|
||||
|
@ -148,3 +141,10 @@ void scoped_timer::finalize() {
|
|||
num_workers = 0;
|
||||
available_workers.clear();
|
||||
}
|
||||
|
||||
void scoped_timer::init_state(unsigned ms, event_handler * eh) {
|
||||
s->ms = ms;
|
||||
s->eh = eh;
|
||||
s->m_mutex.lock();
|
||||
s->work = WORKING;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
~scoped_timer();
|
||||
static void initialize();
|
||||
static void finalize();
|
||||
private:
|
||||
void init_state(unsigned ms, event_handler * eh);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -24,6 +24,9 @@ Revision History:
|
|||
#include "util/util.h"
|
||||
#include "util/vector.h"
|
||||
#include<iomanip>
|
||||
#ifdef Z3DEBUG
|
||||
# include <iostream>
|
||||
#endif
|
||||
|
||||
small_object_allocator::small_object_allocator(char const * id) {
|
||||
for (unsigned i = 0; i < NUM_SLOTS; i++) {
|
||||
|
|
|
@ -20,23 +20,24 @@ Revision History:
|
|||
|
||||
#pragma once
|
||||
// add to value the stack semantics
|
||||
#include <stack>
|
||||
#include "util/vector.h"
|
||||
template <typename T> class stacked_value {
|
||||
T m_value;
|
||||
std::stack<T> m_stack;
|
||||
vector<T> m_stack;
|
||||
public:
|
||||
|
||||
|
||||
void push() {
|
||||
m_stack.push(m_value);
|
||||
m_stack.push_back(m_value);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
m_stack.clear();
|
||||
void clear(T const& m) {
|
||||
pop(m_stack.size());
|
||||
m_value = m;
|
||||
}
|
||||
|
||||
unsigned stack_size() const {
|
||||
return static_cast<unsigned>(m_stack.size());
|
||||
return m_stack.size();
|
||||
}
|
||||
|
||||
void pop() {
|
||||
|
@ -46,8 +47,8 @@ public:
|
|||
while (k-- > 0) {
|
||||
if (m_stack.empty())
|
||||
return;
|
||||
m_value = m_stack.top();
|
||||
m_stack.pop();
|
||||
m_value = m_stack.back();
|
||||
m_stack.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ Notes:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include "util/vector.h"
|
||||
#include "util/rlimit.h"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Revision History:
|
|||
|
||||
#include "util/debug.h"
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include<iomanip>
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<iostream>
|
||||
#include<istream>
|
||||
|
||||
class stream_buffer {
|
||||
std::istream & m_stream;
|
||||
|
@ -40,5 +40,3 @@ public:
|
|||
m_val = m_stream.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include "util/timeit.h"
|
||||
#include "util/memory_manager.h"
|
||||
#include "util/stopwatch.h"
|
||||
#include<iomanip>
|
||||
#include<iostream>
|
||||
|
||||
struct timeit::imp {
|
||||
stopwatch m_watch;
|
||||
|
@ -45,9 +45,9 @@ struct timeit::imp {
|
|||
}
|
||||
};
|
||||
|
||||
timeit::timeit(bool enable, char const * msg, std::ostream & out) {
|
||||
timeit::timeit(bool enable, char const * msg, std::ostream * out) {
|
||||
if (enable)
|
||||
m_imp = alloc(imp, msg, out);
|
||||
m_imp = alloc(imp, msg, out ? *out : std::cerr);
|
||||
else
|
||||
m_imp = nullptr;
|
||||
}
|
||||
|
|
|
@ -21,11 +21,14 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#include<ostream>
|
||||
|
||||
class timeit {
|
||||
struct imp;
|
||||
imp * m_imp;
|
||||
public:
|
||||
timeit(bool enable, char const * msg, std::ostream & out = std::cerr);
|
||||
timeit(bool enable, char const * msg, std::ostream * out = nullptr);
|
||||
timeit(bool enable, char const * msg, std::ostream & out) : timeit(enable, msg, &out) {}
|
||||
~timeit();
|
||||
};
|
||||
|
||||
|
|
|
@ -24,39 +24,50 @@ Revision History:
|
|||
#include "util/obj_hashtable.h"
|
||||
#include "util/vector.h"
|
||||
#include "util/memory_manager.h"
|
||||
#include "util/tptr.h"
|
||||
|
||||
|
||||
template<typename T>
|
||||
class top_sort {
|
||||
typedef obj_hashtable<T> T_set;
|
||||
obj_map<T, unsigned> m_partition_id;
|
||||
obj_map<T, unsigned> m_dfs_num;
|
||||
unsigned_vector m_partition_id;
|
||||
unsigned_vector m_dfs_num;
|
||||
ptr_vector<T> m_top_sorted;
|
||||
ptr_vector<T> m_stack_S;
|
||||
ptr_vector<T> m_stack_P;
|
||||
unsigned m_next_preorder;
|
||||
obj_map<T, T_set*> m_deps;
|
||||
ptr_vector<T_set> m_deps;
|
||||
ptr_vector<T> m_dep_keys;
|
||||
|
||||
static T_set* add_tag(T_set* t) { return TAG(T_set*, t, 1); }
|
||||
static T_set* del_tag(T_set* t) { return UNTAG(T_set*, t); }
|
||||
|
||||
|
||||
bool contains_partition(T* f) const {
|
||||
return m_partition_id.get(f->get_small_id(), UINT_MAX) != UINT_MAX;
|
||||
}
|
||||
|
||||
|
||||
void traverse(T* f) {
|
||||
unsigned p_id = 0;
|
||||
if (m_dfs_num.find(f, p_id)) {
|
||||
if (!m_partition_id.contains(f)) {
|
||||
while (!m_stack_P.empty() && m_partition_id.contains(m_stack_P.back()) && m_partition_id[m_stack_P.back()] > p_id) {
|
||||
unsigned p_id = m_dfs_num.get(f->get_small_id(), UINT_MAX);
|
||||
if (p_id != UINT_MAX) {
|
||||
if (!contains_partition(f)) {
|
||||
while (!m_stack_P.empty() && contains_partition(m_stack_P.back()) && partition_id(m_stack_P.back()) > p_id) {
|
||||
m_stack_P.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!m_deps.contains(f)) {
|
||||
else if (!contains_dep(f))
|
||||
return;
|
||||
}
|
||||
else {
|
||||
m_dfs_num.insert(f, m_next_preorder++);
|
||||
m_dfs_num.setx(f->get_small_id(), m_next_preorder, UINT_MAX);
|
||||
++m_next_preorder;
|
||||
m_stack_S.push_back(f);
|
||||
m_stack_P.push_back(f);
|
||||
if (m_deps[f]) {
|
||||
for (T* g : *m_deps[f]) {
|
||||
T_set* ts = get_dep(f);
|
||||
if (ts) {
|
||||
for (T* g : *ts)
|
||||
traverse(g);
|
||||
}
|
||||
}
|
||||
if (f == m_stack_P.back()) {
|
||||
p_id = m_top_sorted.size();
|
||||
|
@ -65,7 +76,7 @@ class top_sort {
|
|||
s_f = m_stack_S.back();
|
||||
m_stack_S.pop_back();
|
||||
m_top_sorted.push_back(s_f);
|
||||
m_partition_id.insert(s_f, p_id);
|
||||
m_partition_id.setx(s_f->get_small_id(), p_id, UINT_MAX);
|
||||
}
|
||||
while (s_f != f);
|
||||
m_stack_P.pop_back();
|
||||
|
@ -76,28 +87,36 @@ class top_sort {
|
|||
public:
|
||||
|
||||
virtual ~top_sort() {
|
||||
for (auto & kv : m_deps) dealloc(kv.m_value);
|
||||
for (auto * t : m_dep_keys) {
|
||||
dealloc(get_dep(t));
|
||||
m_deps[t->get_small_id()] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void topological_sort() {
|
||||
m_next_preorder = 0;
|
||||
m_partition_id.reset();
|
||||
m_top_sorted.reset();
|
||||
for (auto & kv : m_deps) {
|
||||
traverse(kv.m_key);
|
||||
}
|
||||
for (auto * t : m_dep_keys)
|
||||
traverse(t);
|
||||
SASSERT(m_stack_S.empty());
|
||||
SASSERT(m_stack_P.empty());
|
||||
m_dfs_num.reset();
|
||||
}
|
||||
|
||||
void insert(T* t, T_set* s) {
|
||||
m_deps.insert(t, s);
|
||||
void insert(T* t, T_set* s) {
|
||||
if (contains_dep(t))
|
||||
dealloc(get_dep(t));
|
||||
else
|
||||
m_dep_keys.push_back(t);
|
||||
m_deps.setx(t->get_small_id(), add_tag(s), nullptr);
|
||||
}
|
||||
|
||||
ptr_vector<T> const& deps() { return m_dep_keys; }
|
||||
|
||||
void add(T* t, T* s) {
|
||||
T_set* tb = nullptr;
|
||||
if (!m_deps.find(t, tb) || !tb) {
|
||||
T_set* tb = get_dep(t);
|
||||
if (!tb) {
|
||||
tb = alloc(T_set);
|
||||
insert(t, tb);
|
||||
}
|
||||
|
@ -106,18 +125,21 @@ public:
|
|||
|
||||
ptr_vector<T> const& top_sorted() const { return m_top_sorted; }
|
||||
|
||||
obj_map<T, unsigned> const& partition_ids() const { return m_partition_id; }
|
||||
unsigned partition_id(T* t) const { return m_partition_id[t->get_small_id()]; }
|
||||
|
||||
bool find(T* t, unsigned& p) const { p = m_partition_id.get(t->get_small_id(), UINT_MAX); return p != UINT_MAX; }
|
||||
|
||||
bool contains_dep(T* t) const { return m_deps.get(t->get_small_id(), nullptr) != nullptr; }
|
||||
|
||||
T_set* get_dep(T* t) const { return del_tag(m_deps.get(t->get_small_id(), nullptr)); }
|
||||
|
||||
unsigned partition_id(T* t) const { return m_partition_id[t]; }
|
||||
|
||||
bool is_singleton_partition(T* f) const {
|
||||
unsigned pid = m_partition_id[f];
|
||||
unsigned pid = m_partition_id(f);
|
||||
return f == m_top_sorted[pid] &&
|
||||
(pid == 0 || m_partition_id[m_top_sorted[pid-1]] != pid) &&
|
||||
(pid + 1 == m_top_sorted.size() || m_partition_id[m_top_sorted[pid+1]] != pid);
|
||||
(pid == 0 || partition_id(m_top_sorted[pid-1]) != pid) &&
|
||||
(pid + 1 == m_top_sorted.size() || partition_id(m_top_sorted[pid+1]) != pid);
|
||||
}
|
||||
|
||||
obj_map<T, T_set*> const& deps() const { return m_deps; }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ Revision History:
|
|||
--*/
|
||||
|
||||
#include "util/util.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
static unsigned g_verbosity_level = 0;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Revision History:
|
|||
|
||||
#include "util/debug.h"
|
||||
#include "util/memory_manager.h"
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include<climits>
|
||||
#include<limits>
|
||||
#include<stdint.h>
|
||||
|
|
|
@ -17,7 +17,7 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#pragma once
|
||||
#include<iostream>
|
||||
#include<ostream>
|
||||
#include<stdarg.h>
|
||||
|
||||
void send_warnings_to_stdout(bool flag);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue