3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

merge with unstable

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2014-10-05 10:37:55 -07:00
commit c706e91019
18 changed files with 49 additions and 38 deletions

View file

@ -138,9 +138,8 @@ bool bit_vector::operator==(bit_vector const & source) const {
bit_vector & bit_vector::operator|=(bit_vector const & source) {
if (size() < source.size())
resize(source.size(), false);
unsigned n1 = num_words();
unsigned n2 = source.num_words();
SASSERT(n2 <= n1);
SASSERT(n2 <= num_words());
unsigned bit_rest = source.m_num_bits % 32;
if (bit_rest == 0) {
unsigned i = 0;

View file

@ -55,12 +55,12 @@ class cmd_exception : public default_exception {
}
public:
cmd_exception(char const * msg):default_exception(msg), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg):default_exception(msg.c_str()), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg, int line, int pos):default_exception(msg.c_str()), m_line(line), m_pos(pos) {}
cmd_exception(std::string const & msg):default_exception(msg), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg, int line, int pos):default_exception(msg), m_line(line), m_pos(pos) {}
cmd_exception(char const * msg, symbol const & s):
default_exception(compose(msg,s).c_str()),m_line(-1),m_pos(-1) {}
default_exception(compose(msg,s)),m_line(-1),m_pos(-1) {}
cmd_exception(char const * msg, symbol const & s, int line, int pos):
default_exception(compose(msg,s).c_str()),m_line(line),m_pos(pos) {}
default_exception(compose(msg,s)),m_line(line),m_pos(pos) {}
bool has_pos() const { return m_line >= 0; }
int line() const { SASSERT(has_pos()); return m_line; }

View file

@ -120,7 +120,8 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
// double === mpf(11, 53)
COMPILE_TIME_ASSERT(sizeof(double) == 8);
uint64 raw = *reinterpret_cast<uint64*>(&value);
uint64 raw;
memcpy(&raw, &value, sizeof(double));
bool sign = (raw >> 63) != 0;
int64 e = ((raw & 0x7FF0000000000000ull) >> 52) - 1023;
uint64 s = raw & 0x000FFFFFFFFFFFFFull;
@ -155,7 +156,8 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, float value) {
// single === mpf(8, 24)
COMPILE_TIME_ASSERT(sizeof(float) == 4);
unsigned int raw = *reinterpret_cast<unsigned int*>(&value);
unsigned int raw;
memcpy(&raw, &value, sizeof(float));
bool sign = (raw >> 31) != 0;
signed int e = ((raw & 0x7F800000) >> 23) - 127;
unsigned int s = raw & 0x007FFFFF;
@ -1288,7 +1290,9 @@ double mpf_manager::to_double(mpf const & x) {
if (x.sign)
raw = raw | 0x8000000000000000ull;
return *reinterpret_cast<double*>(&raw);
double ret;
memcpy(&ret, &raw, sizeof(double));
return ret;
}
float mpf_manager::to_float(mpf const & x) {
@ -1318,7 +1322,9 @@ float mpf_manager::to_float(mpf const & x) {
if (x.sign)
raw = raw | 0x80000000;
return *reinterpret_cast<float*>(&raw);
float ret;
memcpy(&ret, &raw, sizeof(float));
return ret;
}
bool mpf_manager::is_nan(mpf const & x) {
@ -1679,7 +1685,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
TRACE("mpf_dbg", tout << "OVF2 = " << OVF2 << std::endl;);
TRACE("mpf_dbg", tout << "o_has_max_exp = " << o_has_max_exp << std::endl;);
if (!OVFen && SIGovf && o_has_max_exp)
if (!OVFen && OVF2)
mk_round_inf(rm, o);
else {
const mpz & p = m_powers2(o.sbits-1);

View file

@ -43,8 +43,7 @@ mpff_manager::mpff_manager(unsigned prec, unsigned initial_capacity) {
for (unsigned i = 0; i < MPFF_NUM_BUFFERS; i++)
m_buffers[i].resize(2 * prec, 0);
// Reserve space for zero
unsigned zero_sig_idx = m_id_gen.mk();
SASSERT(zero_sig_idx == 0);
VERIFY(m_id_gen.mk() == 0);
set(m_one, 1);
}

View file

@ -38,8 +38,7 @@ mpfx_manager::mpfx_manager(unsigned int_sz, unsigned frac_sz, unsigned initial_c
m_buffer0.resize(2*m_total_sz, 0);
m_buffer1.resize(2*m_total_sz, 0);
m_buffer2.resize(2*m_total_sz, 0);
unsigned zero_sig_idx = m_id_gen.mk();
SASSERT(zero_sig_idx == 0);
VERIFY(m_id_gen.mk() == 0);
set(m_one, 1);
}

View file

@ -235,6 +235,9 @@ void mpq_manager<SYNCH>::set(mpq & a, char const * val) {
SASSERT(str[0] - '0' <= 9);
exp = (10*exp) + (str[0] - '0');
}
else if ('/' == str[0]) {
throw default_exception("mixing rational/scientific notation");
}
TRACE("mpq_set", tout << "[exp]: " << exp << ", str[0]: " << (str[0] - '0') << std::endl;);
++str;
}

View file

@ -24,9 +24,6 @@ Revision History:
#include<iostream>
#include<climits>
#include<limits>
#ifdef _MSC_VER
#include<intrin.h>
#endif
#ifndef SIZE_MAX
#define SIZE_MAX std::numeric_limits<std::size_t>::max()
@ -99,9 +96,7 @@ COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
// Return the number of 1 bits in v.
static inline unsigned get_num_1bits(unsigned v) {
#ifdef _MSC_VER
return __popcnt(v);
#elif defined(__GNUC__)
#ifdef __GNUC__
return __builtin_popcount(v);
#else
#ifdef Z3DEBUG