24 std::size_t old_size = bv0.size();
25 std::size_t new_size = old_size * 2;
28 const bvt &bv0_extended = bv_utils.extension(bv0, new_size, rep);
29 const bvt &bv1_extended = bv_utils.extension(bv1, new_size, rep);
31 bvt result_extended = bv_utils.multiplier(bv0_extended, bv1_extended, rep);
32 bvt bv{result_extended.begin(), result_extended.begin() + old_size};
33 bvt bv_overflow{result_extended.begin() + old_size, result_extended.end()};
37 bv.push_back(prop.
lor(bv_overflow));
42 bv_overflow.push_back(bv.back());
47 bv.push_back(!prop.
lor(all_one, all_zero));
62 std::size_t old_size = bv0.size();
63 std::size_t new_size = old_size * 2;
65 bvt result_extended = bv_utils.shift(
66 bv_utils.extension(bv0, new_size, rep0),
69 bvt bv{result_extended.begin(), result_extended.begin() + old_size};
70 bvt bv_overflow{result_extended.begin() + old_size, result_extended.end()};
75 : bv_utils.sign_bit(bv1);
78 std::size_t cmp_width = std::max(bv1.size(),
address_bits(old_size) + 1);
80 bv_utils.extension(bv1, cmp_width, rep1),
82 bv_utils.build_constant(old_size, cmp_width),
88 bv.push_back(prop.
lor(bv_overflow));
93 bv_overflow.push_back(bv.back());
97 !prop.
lequal(bv_utils.sign_bit(bv0), bv_utils.sign_bit(bv));
103 bv.push_back(prop.
lor(sign_change, !prop.
lor(all_one, all_zero)));
109 prop.
land(!neg_shift, prop.
lselect(undef, prop.
lor(bv0), bv.back()));
120 ? std::optional<std::size_t>{bv0.size()}
129 const auto plus_overflow = expr_try_dynamic_cast<plus_overflow_exprt>(expr))
131 if(bv0.size() != bv1.size())
136 if(
const auto minus = expr_try_dynamic_cast<minus_overflow_exprt>(expr))
138 if(bv0.size() != bv1.size())
144 const auto mult_overflow = expr_try_dynamic_cast<mult_overflow_exprt>(expr))
154 mult_overflow->lhs().type() == mult_overflow->rhs().type(),
155 "operands of overflow_mult expression shall have same type");
162 const auto shl_overflow = expr_try_dynamic_cast<shl_overflow_exprt>(expr))
183 const auto unary_minus_overflow =
184 expr_try_dynamic_cast<unary_minus_overflow_exprt>(expr))
199 if(expr.
id() == ID_overflow_result_unary_minus)
207 else if(expr.
operands().size() != 2)
219 if(expr.
id() == ID_overflow_result_plus)
244 for(std::size_t i = 0; i < bv0.size(); i++)
253 else if(expr.
id() == ID_overflow_result_minus)
287 for(std::size_t i = 0; i < bv0.size(); i++)
290 bv.push_back(!carry);
298 else if(expr.
id() == ID_overflow_result_mult)
307 else if(expr.
id() == ID_overflow_result_shl)
API to expression classes for bitvectors.
bool can_cast_expr< mult_overflow_exprt >(const exprt &base)
Pre-defined bitvector types.
bool can_cast_type< signedbv_typet >(const typet &type)
Check whether a reference to a typet is a signedbv_typet.
bool can_cast_type< unsignedbv_typet >(const typet &type)
Check whether a reference to a typet is a unsignedbv_typet.
static bvt shl_overflow_result(propt &prop, const bvt &bv0, const bvt &bv1, bv_utilst::representationt rep0, bv_utilst::representationt rep1)
static bvt mult_overflow_result(propt &prop, const bvt &bv0, const bvt &bv1, bv_utilst::representationt rep)
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
virtual literalt convert_binary_overflow(const binary_overflow_exprt &expr)
virtual bvt convert_overflow_result(const overflow_result_exprt &expr)
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
virtual literalt convert_unary_overflow(const unary_overflow_exprt &expr)
virtual std::size_t boolbv_width(const typet &type) const
literalt is_int_min(const bvt &op)
static literalt sign_bit(const bvt &op)
bvt add(const bvt &op0, const bvt &op1)
literalt overflow_add(const bvt &op0, const bvt &op1, representationt rep)
literalt overflow_sub(const bvt &op0, const bvt &op1, representationt rep)
literalt overflow_negate(const bvt &op)
literalt full_adder(const literalt a, const literalt b, const literalt carry_in, literalt &carry_out)
bvt negate(const bvt &op)
typet & type()
Return the type of the expression.
const irep_idt & id() const
An expression returning both the result of the arithmetic operation under wrap-around semantics as we...
virtual literalt convert_rest(const exprt &expr)
virtual literalt land(literalt a, literalt b)=0
virtual literalt lselect(literalt a, literalt b, literalt c)=0
virtual literalt lxor(literalt a, literalt b)=0
virtual literalt lequal(literalt a, literalt b)=0
virtual literalt lor(literalt a, literalt b)=0
The type of an expression, extends irept.
A Boolean expression returning true, iff operation kind would result in an overflow when applied to t...
std::vector< literalt > bvt
literalt const_literal(bool value)
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...