40 std::vector<mp_integer> bytes;
43 for(std::size_t bit = 0; bit < width; bit += bits_per_byte)
44 bytes.push_back((value >> bit)%
power(2, bits_per_byte));
48 for(std::size_t bit = 0; bit < width; bit += bits_per_byte)
52 "bytes is not empty because we just pushed just as many elements on "
53 "top of it as we are popping now");
54 new_value+=bytes.back()<<bit;
76 type_id == ID_integer || type_id == ID_natural ||
77 type_id == ID_unsignedbv || type_id == ID_signedbv)
86 else if(type_id==ID_rational)
95 else if(type_id==ID_fixedbv)
102 else if(type_id==ID_floatbv)
125 type_id == ID_integer || type_id == ID_natural ||
126 type_id == ID_unsignedbv || type_id == ID_signedbv)
135 else if(type_id==ID_rational)
144 else if(type_id==ID_fixedbv)
151 else if(type_id==ID_floatbv)
172 bool no_change =
true;
175 exprt::operandst::iterator constant;
178 bool constant_found =
false;
180 std::optional<typet> c_sizeof_type;
183 for(exprt::operandst::iterator it = new_operands.begin();
184 it != new_operands.end();)
193 it->type().id()!=ID_floatbv)
199 bool do_erase =
false;
202 if(it->is_constant() && it->type()==expr.
type())
205 if(!c_sizeof_type.has_value())
207 const typet &sizeof_type =
208 static_cast<const typet &
>(it->find(ID_C_c_sizeof_type));
210 c_sizeof_type = sizeof_type;
223 constant_found =
true;
230 it = new_operands.erase(it);
237 if(c_sizeof_type.has_value())
241 "c_sizeof_type is only set to a non-nil value "
242 "if a constant has been found");
243 constant->set(ID_C_c_sizeof_type, *c_sizeof_type);
246 if(new_operands.size() == 1)
248 return new_operands.front();
253 if(constant_found && constant->is_one())
256 new_operands.erase(constant);
259 if(new_operands.size() == 1)
260 return new_operands.front();
269 tmp.
operands() = std::move(new_operands);
270 return std::move(tmp);
281 if(expr_type!=expr.
op0().
type() ||
287 if(expr_type.
id()==ID_signedbv ||
288 expr_type.
id()==ID_unsignedbv ||
289 expr_type.
id()==ID_natural ||
290 expr_type.
id()==ID_integer)
292 const auto int_value0 = numeric_cast<mp_integer>(expr.
op0());
293 const auto int_value1 = numeric_cast<mp_integer>(expr.
op1());
296 if(int_value1.has_value() && *int_value1 == 0)
300 if(int_value1.has_value() && *int_value1 == 1)
306 if(int_value0.has_value() && *int_value0 == 0)
311 if(int_value0.has_value() && int_value1.has_value())
313 mp_integer result = *int_value0 / *int_value1;
317 else if(expr_type.
id()==ID_rational)
325 if(ok1 && rat_value1.
is_zero())
328 if((ok1 && rat_value1.
is_one()) ||
340 return std::move(tmp);
343 else if(expr_type.
id()==ID_fixedbv)
373 if(expr.
type().
id()==ID_signedbv ||
374 expr.
type().
id()==ID_unsignedbv ||
375 expr.
type().
id()==ID_natural ||
376 expr.
type().
id()==ID_integer)
381 const auto int_value0 = numeric_cast<mp_integer>(expr.
op0());
382 const auto int_value1 = numeric_cast<mp_integer>(expr.
op1());
384 if(int_value1.has_value() && *int_value1 == 0)
388 (int_value1.has_value() && *int_value1 == 1) ||
389 (int_value0.has_value() && *int_value0 == 0))
394 if(int_value0.has_value() && int_value1.has_value())
396 mp_integer result = *int_value0 % *int_value1;
410 bool no_change =
true;
417 if(expr.
type().
id() == ID_floatbv)
422 const exprt::operandst::iterator next = std::next(it);
424 if(next != new_operands.end())
426 if(it->type()==next->type() &&
431 new_operands.erase(next);
442 expr.
op0().
id() == ID_plus && expr.
op0().
type().
id() == ID_pointer &&
446 if(
as_const(result).op0().type().
id() != ID_pointer)
450 if(op1.
id() == ID_plus)
469 for(
const auto &op : expr.
operands())
471 if(
is_number(op.type()) && op.is_constant())
478 exprt::operandst::iterator const_sum;
479 bool const_sum_set=
false;
481 for(
auto it = new_operands.begin(); it != new_operands.end(); it++)
483 if(
is_number(it->type()) && it->is_constant())
505 typedef std::unordered_map<exprt, exprt::operandst::iterator, irep_hash>
509 for(
auto it = new_operands.begin(); it != new_operands.end(); it++)
510 if(it->id() == ID_unary_minus)
516 for(
auto it = new_operands.begin(); it != new_operands.end(); it++)
520 else if(it->id()==ID_unary_minus)
523 expr_mapt::iterator itm=expr_map.find(*it);
525 if(itm!=expr_map.end())
537 for(exprt::operandst::iterator it = new_operands.begin();
538 it != new_operands.end();
541 if(
is_number(it->type()) && it->is_zero())
543 it = new_operands.erase(it);
551 if(new_operands.empty())
555 else if(new_operands.size() == 1)
557 return new_operands.front();
565 tmp.
operands() = std::move(new_operands);
566 return std::move(tmp);
574 if(!
is_number(minus_expr.type()) && minus_expr.type().id() != ID_pointer)
589 minus_expr.type().id() == ID_pointer &&
590 operands[0].type().id() == ID_pointer &&
is_number(operands[1].type()))
600 is_number(minus_expr.type()) && operands[0].type().id() == ID_pointer &&
601 operands[1].type().id() == ID_pointer)
606 auto address_of = expr_try_dynamic_cast<address_of_exprt>(ptr_op0);
607 if(ptr_op0 == ptr_op1 && address_of)
620 offset_op0.
is_constant() && offset_op1.is_constant() &&
621 object_size.has_value() && element_size.has_value() &&
622 element_size->
is_constant() && !element_size->is_zero() &&
649 element_size.has_value() && element_size->is_constant() &&
650 !element_size->is_zero())
673 for(
const auto &op : expr.
operands())
678 else if(op.is_zero() || op.is_one())
690 if(expr.
id()==ID_bitand)
692 else if(expr.
id()==ID_bitor)
694 else if(expr.
id()==ID_bitxor)
701 if(it->id()==ID_typecast)
703 else if(it->is_zero())
705 else if(it->is_one())
716 bool no_change =
true;
717 auto new_expr = expr;
723 while(new_expr.operands().size() >= 2)
725 if(!new_expr.op0().is_constant())
728 if(!new_expr.op1().is_constant())
731 if(new_expr.op0().type() != new_expr.type())
734 if(new_expr.op1().type() != new_expr.type())
740 std::function<bool(
bool,
bool)> f;
742 if(new_expr.id() == ID_bitand)
743 f = [](
bool a,
bool b) {
return a && b; };
744 else if(new_expr.id() == ID_bitor)
745 f = [](
bool a,
bool b) {
return a || b; };
746 else if(new_expr.id() == ID_bitxor)
747 f = [](
bool a,
bool b) {
return a != b; };
752 make_bvrep(width, [&a_val, &b_val, &width, &f](std::size_t i) {
760 new_expr.operands().erase(new_expr.operands().begin());
761 new_expr.op0().swap(new_op);
768 if(new_expr.id() == ID_bitor || new_expr.id() == ID_bitxor)
770 for(exprt::operandst::iterator it = new_expr.operands().begin();
771 it != new_expr.operands().end();)
773 if(it->is_zero() && new_expr.operands().size() > 1)
775 it = new_expr.operands().erase(it);
779 it->is_constant() && it->type().id() == ID_bv &&
781 new_expr.operands().size() > 1)
783 it = new_expr.operands().erase(it);
793 if(new_expr.id() == ID_bitand)
795 const auto all_ones =
power(2, width) - 1;
796 for(exprt::operandst::iterator it = new_expr.operands().begin();
797 it != new_expr.operands().end();)
803 new_expr.operands().size() > 1)
805 it = new_expr.operands().erase(it);
815 if(new_expr.operands().size() == 2 && new_expr.op0() == new_expr.op1())
817 if(new_expr.id() == ID_bitand || new_expr.id() == ID_bitor)
819 return new_expr.op0();
821 else if(new_expr.id() == ID_bitxor)
827 if(new_expr.operands().size() == 1)
828 return new_expr.op0();
833 return std::move(new_expr);
846 const auto index_converted_to_int = numeric_cast<mp_integer>(expr.
index());
848 !index_converted_to_int.has_value() || *index_converted_to_int < 0 ||
849 *index_converted_to_int >= src_bit_width)
860 numeric_cast_v<std::size_t>(*index_converted_to_int));
868 bool no_change =
true;
880 const bool value = op.
is_true();
889 while(i < new_expr.
operands().size() - 1)
904 const auto new_width = width_i + width_n;
907 new_width, [&value_i, &value_n, width_i, width_n](std::size_t x) {
957 else if(new_expr.
type().
id() == ID_verilog_unsignedbv)
962 while(i < new_expr.
operands().size() - 1)
973 const std::string new_value=
975 opi.
set(ID_value, new_value);
977 opi.
type().
id(ID_verilog_unsignedbv);
991 return new_expr.
op0();
997 return std::move(new_expr);
1018 const auto distance = numeric_cast<mp_integer>(expr.
distance());
1020 if(!distance.has_value())
1026 auto value = numeric_cast<mp_integer>(expr.
op());
1029 !value.has_value() && expr.
op().
type().
id() == ID_bv &&
1037 if(!value.has_value())
1041 expr.
op().
type().
id() == ID_unsignedbv ||
1046 if(expr.
id()==ID_lshr)
1049 if(*distance >= width)
1053 else if(*distance >= 0)
1056 *value +=
power(2, width);
1057 *value /=
power(2, *distance);
1061 else if(expr.
id()==ID_ashr)
1070 else if(expr.
id()==ID_shl)
1073 if(*distance >= width)
1077 else if(*distance >= 0)
1079 *value *=
power(2, *distance);
1085 expr.
op().
type().
id() == ID_integer || expr.
op().
type().
id() == ID_natural)
1087 if(expr.
id()==ID_lshr)
1091 *value /=
power(2, *distance);
1095 else if(expr.
id()==ID_ashr)
1101 if(*value < 0 && new_value == 0)
1107 else if(expr.
id()==ID_shl)
1111 *value *=
power(2, *distance);
1126 const auto base = numeric_cast<mp_integer>(expr.
op0());
1127 const auto exponent = numeric_cast<mp_integer>(expr.
op1());
1129 if(!base.has_value())
1132 if(!exponent.has_value())
1153 const auto end = numeric_cast<mp_integer>(expr.
index());
1155 if(!end.has_value())
1160 if(!width.has_value())
1165 if(!result_width.has_value())
1168 const auto start = std::optional(*end + *result_width - 1);
1170 if(*start < 0 || *start >= (*width) || *end < 0 || *end >= (*width))
1173 DATA_INVARIANT(*start >= *end,
"extractbits must have start >= end");
1179 if(!svalue.has_value() || svalue->size() != *width)
1182 std::string extracted_value = svalue->substr(
1183 numeric_cast_v<std::size_t>(*end),
1184 numeric_cast_v<std::size_t>(*start - *end + 1));
1187 if(!result.has_value())
1190 return std::move(*result);
1192 else if(expr.
src().
id() == ID_concatenation)
1202 if(!op_width.has_value() || *op_width <= 0)
1205 if(*start < offset && offset <= *end + *op_width)
1214 offset -= *op_width;
1217 else if(
auto eb_src = expr_try_dynamic_cast<extractbits_exprt>(expr.
src()))
1219 if(eb_src->index().is_constant())
1229 else if(*end == 0 && *start + 1 == *width)
1251 const exprt &operand = expr.
op();
1256 if(operand.
id()==ID_unary_minus)
1269 if(type_id==ID_integer ||
1270 type_id==ID_signedbv ||
1271 type_id==ID_unsignedbv)
1273 const auto int_value = numeric_cast<mp_integer>(constant_expr);
1275 if(!int_value.has_value())
1280 else if(type_id==ID_rational)
1288 else if(type_id==ID_fixedbv)
1294 else if(type_id==ID_floatbv)
1310 const auto &type = expr.
type();
1313 type.id() == ID_bv || type.id() == ID_unsignedbv ||
1314 type.id() == ID_signedbv)
1318 if(op.
type() == type)
1323 const auto new_value =
1324 make_bvrep(width, [&value, &width](std::size_t i) {
1350 if((expr.
id()==ID_equal || expr.
id()==ID_notequal) &&
1354 auto new_expr = expr;
1355 new_expr.
op0().
swap(new_expr.op1());
1359 if(tmp0.
id()==ID_if && tmp0.
operands().size()==3)
1373 (expr.
id() == ID_equal || expr.
id() == ID_notequal))
1378 if(tmp0.
id()==ID_pointer_object &&
1379 tmp1.
id()==ID_pointer_object &&
1380 (expr.
id()==ID_equal || expr.
id()==ID_notequal))
1385 if(tmp0.
type().
id()==ID_c_enum_tag)
1388 if(tmp1.
type().
id()==ID_c_enum_tag)
1395 if(tmp0_const && tmp1_const)
1405 if(expr.
id()==ID_ge)
1407 else if(expr.
id()==ID_le)
1409 else if(expr.
id()==ID_gt)
1411 else if(expr.
id()==ID_lt)
1439 if(tmp0.
type().
id() == ID_c_enum_tag)
1442 if(tmp1.
type().
id() == ID_c_enum_tag)
1448 if(expr.
id() == ID_equal || expr.
id() == ID_notequal)
1452 bool equal = (tmp0_const.get_value() == tmp1_const.get_value());
1454 !equal && tmp0_const.type().id() == ID_pointer &&
1455 tmp1_const.type().id() == ID_pointer)
1459 tmp1_const.get_value() == ID_NULL))
1465 equal = tmp0_const.is_zero() && tmp1_const.is_zero();
1470 if(tmp0.
type().
id() == ID_fixedbv)
1475 if(expr.
id() == ID_ge)
1477 else if(expr.
id() == ID_le)
1479 else if(expr.
id() == ID_gt)
1481 else if(expr.
id() == ID_lt)
1486 else if(tmp0.
type().
id() == ID_floatbv)
1491 if(expr.
id() == ID_ge)
1493 else if(expr.
id() == ID_le)
1495 else if(expr.
id() == ID_gt)
1497 else if(expr.
id() == ID_lt)
1502 else if(tmp0.
type().
id() == ID_rational)
1512 if(expr.
id() == ID_ge)
1514 else if(expr.
id() == ID_le)
1516 else if(expr.
id() == ID_gt)
1518 else if(expr.
id() == ID_lt)
1525 const auto v0 = numeric_cast<mp_integer>(tmp0_const);
1530 const auto v1 = numeric_cast<mp_integer>(tmp1_const);
1535 if(expr.
id() == ID_ge)
1537 else if(expr.
id() == ID_le)
1539 else if(expr.
id() == ID_gt)
1541 else if(expr.
id() == ID_lt)
1559 if(op0.
id()==ID_plus)
1561 bool no_change =
true;
1569 else if(op1.
id()==ID_plus)
1571 bool no_change =
true;
1582 op0.
type().
id()!=ID_complex)
1600 if(expr.
op0().
type().
id() == ID_floatbv)
1603 if(expr.
op0().
type().
id() == ID_pointer)
1608 if(ptr_op0 == ptr_op1)
1614 std::move(offset_op0), expr.
id(), std::move(offset_op1)}));
1617 else if(expr.
id() != ID_equal && expr.
id() != ID_notequal)
1622 expr.
id() == ID_equal && ptr_op0.
id() == ID_address_of &&
1623 ptr_op1.
id() == ID_address_of)
1628 auto in_bounds = [
this](
const exprt &object_ptr,
const exprt &expr_op) {
1635 exprt in_object_bounds =
1637 std::move(offset), ID_lt, std::move(*
object_size)})
1647 in_bounds(ptr_op0, expr.
op0()).is_true() &&
1648 in_bounds(ptr_op1, expr.
op1()).is_true())
1656 if(expr.
id()==ID_notequal)
1658 auto new_rel_expr = expr;
1659 new_rel_expr.
id(ID_equal);
1663 else if(expr.
id()==ID_gt)
1665 auto new_rel_expr = expr;
1666 new_rel_expr.
id(ID_ge);
1668 new_rel_expr.lhs().
swap(new_rel_expr.rhs());
1672 else if(expr.
id()==ID_lt)
1674 auto new_rel_expr = expr;
1675 new_rel_expr.
id(ID_ge);
1679 else if(expr.
id()==ID_le)
1681 auto new_rel_expr = expr;
1682 new_rel_expr.
id(ID_ge);
1684 new_rel_expr.lhs().
swap(new_rel_expr.rhs());
1691 expr.
id() == ID_ge || expr.
id() == ID_equal,
1692 "we previously converted all other cases to >= or ==");
1696 if(expr.
op0() == expr.
op1())
1701 if(expr.
id()==ID_equal)
1737 if(expr.
id()==ID_notequal)
1739 auto new_rel_expr = expr;
1740 new_rel_expr.
id(ID_equal);
1746 if(expr.
id() != ID_equal)
1755 if(expr.
op0().
id() == ID_address_of)
1760 object.
id() == ID_symbol ||
object.
id() == ID_dynamic_object ||
1761 object.
id() == ID_member ||
object.
id() == ID_index ||
1762 object.
id() == ID_string_constant)
1768 expr.
op0().
id() == ID_typecast &&
1772 const auto &
object =
1776 object.
id() == ID_symbol ||
object.
id() == ID_dynamic_object ||
1777 object.
id() == ID_member ||
object.
id() == ID_index ||
1778 object.
id() == ID_string_constant)
1784 expr.
op0().
id() == ID_typecast && expr.
op0().
type().
id() == ID_pointer)
1788 op.
type().
id() != ID_pointer &&
1790 op.
type().
id() == ID_complex))
1797 auto new_expr = expr;
1799 if(new_expr.op0().type().id() != ID_pointer)
1800 new_expr.op1() =
from_integer(0, new_expr.op0().type());
1802 new_expr.op1().type() = new_expr.op0().type();
1805 else if(expr.
op0().
id() == ID_plus)
1817 else if(
auto address_of = expr_try_dynamic_cast<address_of_exprt>(ptr))
1837 if(expr.
op0().
id()==ID_plus)
1841 if(expr.
id()==ID_equal || expr.
id()==ID_notequal)
1844 bool op_changed =
false;
1845 auto new_expr = expr;
1849 if(it->is_constant())
1867 new_expr.op1() =
from_integer(i, new_expr.op1().type());
1880 expr.
op0().
id() == ID_typecast && expr.
op0().
type().
id() == ID_floatbv &&
1887 ieee_floatt const_val_converted_back=const_val_converted;
1890 if(const_val_converted_back==const_val)
1895 return std::move(result);
1904 if(expr.
id()==ID_ge &&
1911 auto new_expr = expr;
1914 if(expr.
id()==ID_equal)
1917 if(operand.
id()==ID_unary_minus)
1920 return std::move(new_expr);
1922 else if(operand.
id()==ID_plus)
1927 if(operand_plus_expr.operands().size() == 2)
1930 if(operand_plus_expr.op0().id() == ID_unary_minus)
1931 operand_plus_expr.op0().swap(operand_plus_expr.op1());
1933 if(operand_plus_expr.op1().id() == ID_unary_minus)
1936 operand_plus_expr.op0(),
1948 if(maybe_tc_op.
type().
id() == ID_pointer)
1952 bool bitwidth_unchanged =
true;
1954 while(bitwidth_unchanged && ep->
id() == ID_typecast)
1956 if(
auto t = type_try_dynamic_cast<bitvector_typet>(ep->
type()))
1958 bitwidth_unchanged = t->get_width() == p_type.
get_width();
1961 bitwidth_unchanged =
false;
1966 if(bitwidth_unchanged)
1968 if(expr.
id() == ID_equal || expr.
id() == ID_ge || expr.
id() == ID_le)
1985 expr.
op0().
id() == ID_typecast &&
1999 return lhs_typecast_op;
2003 #define NORMALISE_CONSTANT_TESTS
2004 #ifdef NORMALISE_CONSTANT_TESTS
2006 if(expr.
op0().
type().
id()==ID_unsignedbv ||
2011 if(expr.
id()==ID_notequal)
2013 auto new_rel_expr = expr;
2014 new_rel_expr.
id(ID_equal);
2018 else if(expr.
id()==ID_gt)
2027 auto new_expr = expr;
2030 new_expr.op1() =
from_integer(i, new_expr.op1().type());
2033 else if(expr.
id()==ID_lt)
2035 auto new_rel_expr = expr;
2036 new_rel_expr.
id(ID_ge);
2040 else if(expr.
id()==ID_le)
2049 auto new_rel_expr = expr;
2050 new_rel_expr.
id(ID_ge);
2052 new_rel_expr.op1() =
from_integer(i, new_rel_expr.op1().type());
2069 if(!const_bits_opt.has_value())
2072 std::reverse(const_bits_opt->begin(), const_bits_opt->end());
2079 if(!result.has_value())
2082 return std::move(*result);
std::unordered_map< exprt, exprt, irep_hash > expr_mapt
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
API to expression classes for bitvectors.
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
const integer_bitvector_typet & to_integer_bitvector_type(const typet &type)
Cast a typet to an integer_bitvector_typet.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
A base class for binary expressions.
A base class for relations, i.e., binary predicates whose two operands have the same type.
Bit-wise negation of bit-vectors.
Reverse the order of bits in a bit-vector.
Base class of fixed-width bit-vector types.
void set_width(std::size_t width)
std::size_t get_width() const
The byte swap expression.
std::size_t get_bits_per_byte() const
Concatenation of bit-vector operands.
struct configt::ansi_ct ansi_c
A constant literal expression.
const irep_idt & get_value() const
bool value_is_zero_string() const
void set_value(const irep_idt &value)
bool is_null_pointer() const
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
bool is_one() const
Return whether the expression is a constant representing 1.
bool is_true() const
Return whether the expression is a constant representing true.
bool is_boolean() const
Return whether the expression represents a Boolean.
bool is_false() const
Return whether the expression is a constant representing false.
bool is_zero() const
Return whether the expression is a constant representing 0.
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
The Boolean constant false.
constant_exprt to_expr() const
constant_exprt to_expr() const
void change_spec(const ieee_float_spect &dest_spec)
The trinary if-then-else operator.
mp_integer largest() const
Return the largest value that can be represented using this type.
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
const std::string & get_string(const irep_idt &name) const
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
Binary multiplication Associativity is not specified.
A base class for multi-ary expressions Associativity is not specified.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
The null pointer constant.
The plus expression Associativity is not specified.
The offset (in bytes) of a pointer relative to the object.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
A base class for shift and rotate operators.
resultt simplify_bitwise(const multi_ary_exprt &)
resultt simplify_power(const binary_exprt &)
resultt simplify_inequality_address_of(const binary_relation_exprt &)
resultt simplify_div(const div_exprt &)
resultt simplify_bitreverse(const bitreverse_exprt &)
Try to simplify bit-reversing to a constant expression.
resultt simplify_bitnot(const bitnot_exprt &)
resultt simplify_zero_extend(const zero_extend_exprt &)
static resultt changed(resultt<> result)
resultt simplify_if(const if_exprt &)
resultt simplify_node(const exprt &)
resultt simplify_minus(const minus_exprt &)
resultt simplify_extractbit(const extractbit_exprt &)
resultt simplify_rec(const exprt &)
resultt simplify_shifts(const shift_exprt &)
resultt simplify_typecast(const typecast_exprt &)
resultt simplify_boolean(const exprt &)
resultt simplify_object(const exprt &)
resultt simplify_mult(const mult_exprt &)
resultt simplify_inequality_rhs_is_constant(const binary_relation_exprt &)
resultt simplify_inequality(const binary_relation_exprt &)
simplifies inequalities !=, <=, <, >=, >, and also ==
resultt simplify_not(const not_exprt &)
resultt simplify_bswap(const bswap_exprt &)
resultt simplify_inequality_pointer_object(const binary_relation_exprt &)
static resultt unchanged(exprt expr)
resultt simplify_extractbits(const extractbits_exprt &)
Simplifies extracting of bits from a constant.
resultt simplify_mod(const mod_exprt &)
resultt simplify_pointer_offset(const pointer_offset_exprt &)
resultt simplify_plus(const plus_exprt &)
resultt simplify_inequality_no_constant(const binary_relation_exprt &)
resultt simplify_unary_plus(const unary_plus_exprt &)
resultt simplify_concatenation(const concatenation_exprt &)
resultt simplify_inequality_both_constant(const binary_relation_exprt &)
simplifies inequalities for the case in which both sides of the inequality are constants
resultt simplify_unary_minus(const unary_minus_exprt &)
The Boolean constant true.
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
The unary minus expression.
The unary plus expression.
Fixed-width bit-vector with unsigned binary interpretation.
zero extension The operand is converted to the given type by either a) truncating if the new type is ...
#define Forall_operands(it, expr)
#define Forall_expr(it, expr)
constant_exprt make_boolean_expr(bool value)
returns true_exprt if given true and false_exprt otherwise
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
if_exprt lift_if(const exprt &src, std::size_t operand_number)
lift up an if_exprt one level
bool is_null_pointer(const constant_exprt &expr)
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
Deprecated expression utility functions.
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
API to expression classes for Pointers.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
std::optional< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
std::optional< exprt > size_of_expr(const typet &type, const namespacet &ns)
std::optional< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
exprt object_size(const exprt &pointer)
static bool mul_expr(constant_exprt &dest, const constant_exprt &expr)
produce a product of two expressions of the same type
static bool sum_expr(constant_exprt &dest, const constant_exprt &expr)
produce a sum of two constant expressions of the same type
static bool eliminate_common_addends(exprt &op0, exprt &op1)
std::optional< std::string > expr2bits(const exprt &expr, bool little_endian, const namespacet &ns)
std::optional< exprt > bits2expr(const std::string &bits, const typet &type, bool little_endian, const namespacet &ns)
#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,...
#define PRECONDITION(CONDITION)
API to expression classes.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.