41 std::vector<mp_integer> bytes;
44 for(std::size_t bit = 0; bit < width; bit += bits_per_byte)
45 bytes.push_back((value >> bit)%
power(2, bits_per_byte));
49 for(std::size_t bit = 0; bit < width; bit += bits_per_byte)
53 "bytes is not empty because we just pushed just as many elements on "
54 "top of it as we are popping now");
55 new_value+=bytes.back()<<bit;
77 type_id == ID_integer || type_id == ID_natural ||
78 type_id == ID_unsignedbv || type_id == ID_signedbv)
87 else if(type_id==ID_rational)
96 else if(type_id==ID_fixedbv)
103 else if(type_id==ID_floatbv)
127 type_id == ID_integer || type_id == ID_natural ||
128 type_id == ID_unsignedbv || type_id == ID_signedbv)
137 else if(type_id==ID_rational)
146 else if(type_id==ID_fixedbv)
153 else if(type_id==ID_floatbv)
175 bool no_change =
true;
178 exprt::operandst::iterator constant;
181 bool constant_found =
false;
183 std::optional<typet> c_sizeof_type;
186 for(exprt::operandst::iterator it = new_operands.begin();
187 it != new_operands.end();)
195 if(*it == 0 && it->type().id() != ID_floatbv)
201 bool do_erase =
false;
204 if(it->is_constant() && it->type()==expr.
type())
207 if(!c_sizeof_type.has_value())
209 const typet &sizeof_type =
210 static_cast<const typet &
>(it->find(ID_C_c_sizeof_type));
212 c_sizeof_type = sizeof_type;
225 constant_found =
true;
232 it = new_operands.erase(it);
239 if(c_sizeof_type.has_value())
243 "c_sizeof_type is only set to a non-nil value "
244 "if a constant has been found");
245 constant->set(ID_C_c_sizeof_type, *c_sizeof_type);
248 if(new_operands.size() == 1)
250 return new_operands.front();
255 if(constant_found && *constant == 1)
258 new_operands.erase(constant);
261 if(new_operands.size() == 1)
262 return new_operands.front();
271 tmp.
operands() = std::move(new_operands);
272 return std::move(tmp);
283 if(expr_type!=expr.
op0().
type() ||
289 if(expr_type.
id()==ID_signedbv ||
290 expr_type.
id()==ID_unsignedbv ||
291 expr_type.
id()==ID_natural ||
292 expr_type.
id()==ID_integer)
298 if(int_value1.has_value() && *int_value1 == 0)
302 if(int_value1.has_value() && *int_value1 == 1)
308 if(int_value0.has_value() && *int_value0 == 0)
313 if(int_value0.has_value() && int_value1.has_value())
315 mp_integer result = *int_value0 / *int_value1;
319 else if(expr_type.
id()==ID_rational)
327 if(ok1 && rat_value1.
is_zero())
330 if((ok1 && rat_value1.
is_one()) ||
342 return std::move(tmp);
345 else if(expr_type.
id()==ID_fixedbv)
374 if(expr.
type().
id()==ID_signedbv ||
375 expr.
type().
id()==ID_unsignedbv ||
376 expr.
type().
id()==ID_natural ||
377 expr.
type().
id()==ID_integer)
385 if(int_value1.has_value() && *int_value1 == 0)
389 (int_value1.has_value() && *int_value1 == 1) ||
390 (int_value0.has_value() && *int_value0 == 0))
395 if(int_value0.has_value() && int_value1.has_value())
397 mp_integer result = *int_value0 % *int_value1;
411 bool no_change =
true;
418 if(expr.
type().
id() == ID_floatbv)
423 const exprt::operandst::iterator next = std::next(it);
425 if(next != new_operands.end())
427 if(it->type()==next->type() &&
432 new_operands.erase(next);
443 expr.
op0().
id() == ID_plus && expr.
op0().
type().
id() == ID_pointer &&
447 if(
as_const(result).op0().type().
id() != ID_pointer)
451 if(op1.
id() == ID_plus)
470 for(
const auto &op : expr.
operands())
472 if(
is_number(op.type()) && op.is_constant())
479 exprt::operandst::iterator const_sum;
480 bool const_sum_set=
false;
482 for(
auto it = new_operands.begin(); it != new_operands.end(); it++)
484 if(
is_number(it->type()) && it->is_constant())
506 typedef std::unordered_map<exprt, exprt::operandst::iterator, irep_hash>
510 for(
auto it = new_operands.begin(); it != new_operands.end(); it++)
511 if(it->id() == ID_unary_minus)
517 for(
auto it = new_operands.begin(); it != new_operands.end(); it++)
521 else if(it->id()==ID_unary_minus)
524 expr_mapt::iterator itm=expr_map.find(*it);
526 if(itm!=expr_map.end())
538 for(exprt::operandst::iterator it = new_operands.begin();
539 it != new_operands.end();
544 it = new_operands.erase(it);
552 if(new_operands.empty())
556 else if(new_operands.size() == 1)
558 return new_operands.front();
566 tmp.
operands() = std::move(new_operands);
567 return std::move(tmp);
575 if(!
is_number(minus_expr.type()) && minus_expr.type().id() != ID_pointer)
590 minus_expr.type().id() == ID_pointer &&
591 operands[0].type().id() == ID_pointer &&
is_number(operands[1].type()))
601 is_number(minus_expr.type()) && operands[0].type().id() == ID_pointer &&
602 operands[1].type().id() == ID_pointer)
608 if(ptr_op0 == ptr_op1 && address_of)
621 offset_op0.
is_constant() && offset_op1.is_constant() &&
622 object_size.has_value() && element_size.has_value() &&
623 element_size->is_constant() && *element_size != 0 &&
650 element_size.has_value() && element_size->is_constant() &&
674 for(
const auto &op : expr.
operands())
679 else if(op == 0 || op == 1)
691 if(expr.
id()==ID_bitand)
693 else if(expr.
id()==ID_bitor)
695 else if(expr.
id()==ID_bitxor)
697 else if(expr.
id() == ID_bitxnor)
698 new_expr.
id(ID_equal);
704 if(it->id()==ID_typecast)
719 bool no_change =
true;
720 auto new_expr = expr;
726 while(new_expr.operands().size() >= 2)
728 if(!new_expr.op0().is_constant())
731 if(!new_expr.op1().is_constant())
734 if(new_expr.op0().type() != new_expr.type())
737 if(new_expr.op1().type() != new_expr.type())
743 std::function<bool(
bool,
bool)> f;
745 if(new_expr.id() == ID_bitand)
746 f = [](
bool a,
bool b) {
return a && b; };
747 else if(new_expr.id() == ID_bitor)
748 f = [](
bool a,
bool b) {
return a || b; };
749 else if(new_expr.id() == ID_bitxor)
750 f = [](
bool a,
bool b) {
return a != b; };
751 else if(new_expr.id() == ID_bitxnor)
752 f = [](
bool a,
bool b) {
return a == b; };
757 make_bvrep(width, [&a_val, &b_val, &width, &f](std::size_t i) {
765 new_expr.operands().erase(new_expr.operands().begin());
766 new_expr.op0().swap(new_op);
772 if(new_expr.id() == ID_bitand)
776 for(
const auto &op : new_expr.operands())
784 if(new_expr.id() == ID_bitor)
787 new_expr.
type().
id() == ID_bv
790 for(
const auto &op : new_expr.operands())
799 if(new_expr.id() == ID_bitor || new_expr.id() == ID_bitxor)
801 for(exprt::operandst::iterator it = new_expr.operands().begin();
802 it != new_expr.operands().end();)
804 if(*it == 0 && new_expr.operands().size() > 1)
806 it = new_expr.operands().erase(it);
810 it->is_constant() && it->type().id() == ID_bv &&
811 *it ==
to_bv_type(it->type()).all_zeros_expr() &&
812 new_expr.operands().size() > 1)
814 it = new_expr.operands().erase(it);
824 if(new_expr.id() == ID_bitand)
826 const auto all_ones =
power(2, width) - 1;
827 for(exprt::operandst::iterator it = new_expr.operands().begin();
828 it != new_expr.operands().end();)
834 new_expr.operands().size() > 1)
836 it = new_expr.operands().erase(it);
846 if(new_expr.operands().size() == 2 && new_expr.op0() == new_expr.op1())
848 if(new_expr.id() == ID_bitand || new_expr.id() == ID_bitor)
850 return new_expr.op0();
852 else if(new_expr.id() == ID_bitxor)
858 if(new_expr.operands().size() == 1)
859 return new_expr.op0();
864 return std::move(new_expr);
879 !index_converted_to_int.has_value() || *index_converted_to_int < 0 ||
880 *index_converted_to_int >= src_bit_width)
899 bool no_change =
true;
909 if(op ==
true || op ==
false)
911 const bool value = op ==
true;
920 while(i < new_expr.
operands().size() - 1)
935 const auto new_width = width_i + width_n;
938 new_width, [&value_i, &value_n, width_i, width_n](std::size_t x) {
988 else if(new_expr.
type().
id() == ID_verilog_unsignedbv)
993 while(i < new_expr.
operands().size() - 1)
1004 const std::string new_value=
1006 opi.
set(ID_value, new_value);
1008 opi.
type().
id(ID_verilog_unsignedbv);
1019 if(new_expr.
operands().size() == 1)
1022 return new_expr.
op0();
1033 return std::move(new_expr);
1056 if(!distance.has_value())
1065 !value.has_value() && expr.
op().
type().
id() == ID_bv &&
1073 if(!value.has_value())
1077 expr.
op().
type().
id() == ID_unsignedbv ||
1082 if(expr.
id()==ID_lshr)
1085 if(*distance >= width)
1089 else if(*distance >= 0)
1092 *value +=
power(2, width);
1093 *value /=
power(2, *distance);
1097 else if(expr.
id()==ID_ashr)
1106 else if(expr.
id()==ID_shl)
1109 if(*distance >= width)
1113 else if(*distance >= 0)
1115 *value *=
power(2, *distance);
1121 expr.
op().
type().
id() == ID_integer || expr.
op().
type().
id() == ID_natural)
1123 if(expr.
id()==ID_lshr)
1127 *value /=
power(2, *distance);
1131 else if(expr.
id()==ID_ashr)
1137 if(*value < 0 && new_value == 0)
1143 else if(expr.
id()==ID_shl)
1147 *value *=
power(2, *distance);
1165 if(!exponent.has_value())
1168 if(exponent.value() == 0)
1171 if(exponent.value() == 1)
1174 if(!base.has_value())
1197 if(!end.has_value())
1202 if(!width.has_value())
1207 if(!result_width.has_value())
1210 const auto start = std::optional(*end + *result_width - 1);
1212 if(*start < 0 || *start >= (*width) || *end < 0 || *end >= (*width))
1215 DATA_INVARIANT(*start >= *end,
"extractbits must have start >= end");
1221 if(!svalue.has_value() || svalue->size() != *width)
1224 std::string extracted_value = svalue->substr(
1229 if(!result.has_value())
1232 return std::move(*result);
1234 else if(expr.
src().
id() == ID_concatenation)
1244 if(!op_width.has_value() || *op_width <= 0)
1247 if(*start < offset && offset <= *end + *op_width)
1256 offset -= *op_width;
1261 if(eb_src->index().is_constant())
1271 else if(*end == 0 && *start + 1 == *width)
1293 const exprt &operand = expr.
op();
1298 if(operand.
id()==ID_unary_minus)
1311 if(type_id==ID_integer ||
1312 type_id==ID_signedbv ||
1313 type_id==ID_unsignedbv)
1317 if(!int_value.has_value())
1322 else if(type_id==ID_rational)
1330 else if(type_id==ID_fixedbv)
1336 else if(type_id==ID_floatbv)
1352 const auto &type = expr.
type();
1355 type.id() == ID_bv || type.id() == ID_unsignedbv ||
1356 type.id() == ID_signedbv)
1360 if(op.
type() == type)
1365 const auto new_value =
1366 make_bvrep(width, [&value, &width](std::size_t i) {
1392 if((expr.
id()==ID_equal || expr.
id()==ID_notequal) &&
1396 auto new_expr = expr;
1397 new_expr.
op0().
swap(new_expr.op1());
1401 if(tmp0.
id()==ID_if && tmp0.
operands().size()==3)
1415 (expr.
id() == ID_equal || expr.
id() == ID_notequal))
1420 if(tmp0.
id()==ID_pointer_object &&
1421 tmp1.
id()==ID_pointer_object &&
1422 (expr.
id()==ID_equal || expr.
id()==ID_notequal))
1427 if(tmp0.
type().
id()==ID_c_enum_tag)
1430 if(tmp1.
type().
id()==ID_c_enum_tag)
1437 if(tmp0_const && tmp1_const)
1447 if(expr.
id()==ID_ge)
1449 else if(expr.
id()==ID_le)
1451 else if(expr.
id()==ID_gt)
1453 else if(expr.
id()==ID_lt)
1481 if(tmp0.
type().
id() == ID_c_enum_tag)
1484 if(tmp1.
type().
id() == ID_c_enum_tag)
1490 if(expr.
id() == ID_equal || expr.
id() == ID_notequal)
1494 bool equal = (tmp0_const.get_value() == tmp1_const.get_value());
1496 !equal && tmp0_const.type().id() == ID_pointer &&
1497 tmp1_const.type().id() == ID_pointer)
1500 !
config.ansi_c.NULL_is_zero && (tmp0_const.get_value() == ID_NULL ||
1501 tmp1_const.get_value() == ID_NULL))
1507 equal = tmp0_const == 0 && tmp1_const == 0;
1512 if(tmp0.
type().
id() == ID_fixedbv)
1517 if(expr.
id() == ID_ge)
1519 else if(expr.
id() == ID_le)
1521 else if(expr.
id() == ID_gt)
1523 else if(expr.
id() == ID_lt)
1528 else if(tmp0.
type().
id() == ID_floatbv)
1533 if(expr.
id() == ID_ge)
1535 else if(expr.
id() == ID_le)
1537 else if(expr.
id() == ID_gt)
1539 else if(expr.
id() == ID_lt)
1544 else if(tmp0.
type().
id() == ID_rational)
1554 if(expr.
id() == ID_ge)
1556 else if(expr.
id() == ID_le)
1558 else if(expr.
id() == ID_gt)
1560 else if(expr.
id() == ID_lt)
1577 if(expr.
id() == ID_ge)
1579 else if(expr.
id() == ID_le)
1581 else if(expr.
id() == ID_gt)
1583 else if(expr.
id() == ID_lt)
1594 op0 == 0 || op1 == 0 ||
1601 if(op0.
id()==ID_plus)
1603 bool no_change =
true;
1611 else if(op1.
id()==ID_plus)
1613 bool no_change =
true;
1623 if(op0 != 0 && op0.
type().
id() != ID_complex)
1641 if(expr.
op0().
type().
id() == ID_floatbv)
1644 if(expr.
op0().
type().
id() == ID_pointer)
1649 if(ptr_op0 == ptr_op1)
1655 std::move(offset_op0), expr.
id(), std::move(offset_op1)}));
1658 else if(expr.
id() != ID_equal && expr.
id() != ID_notequal)
1663 expr.
id() == ID_equal && ptr_op0.
id() == ID_address_of &&
1664 ptr_op1.
id() == ID_address_of)
1669 auto in_bounds = [
this](
const exprt &object_ptr,
const exprt &expr_op) {
1676 exprt in_object_bounds =
1678 std::move(offset), ID_lt, std::move(*
object_size)})
1681 return tvt{in_object_bounds ==
true};
1688 in_bounds(ptr_op0, expr.
op0()).is_true() &&
1689 in_bounds(ptr_op1, expr.
op1()).is_true())
1697 if(expr.
id()==ID_notequal)
1699 auto new_rel_expr = expr;
1700 new_rel_expr.
id(ID_equal);
1704 else if(expr.
id()==ID_gt)
1706 auto new_rel_expr = expr;
1707 new_rel_expr.
id(ID_ge);
1709 new_rel_expr.lhs().
swap(new_rel_expr.rhs());
1713 else if(expr.
id()==ID_lt)
1715 auto new_rel_expr = expr;
1716 new_rel_expr.
id(ID_ge);
1720 else if(expr.
id()==ID_le)
1722 auto new_rel_expr = expr;
1723 new_rel_expr.
id(ID_ge);
1725 new_rel_expr.lhs().
swap(new_rel_expr.rhs());
1732 expr.
id() == ID_ge || expr.
id() == ID_equal,
1733 "we previously converted all other cases to >= or ==");
1737 if(expr.
op0() == expr.
op1())
1742 if(expr.
id()==ID_equal)
1778 if(expr.
id()==ID_notequal)
1780 auto new_rel_expr = expr;
1781 new_rel_expr.
id(ID_equal);
1787 if(expr.
id() != ID_equal)
1796 if(expr.
op0().
id() == ID_address_of)
1801 object.
id() == ID_symbol ||
object.
id() == ID_dynamic_object ||
1802 object.
id() == ID_member ||
object.
id() == ID_index ||
1803 object.
id() == ID_string_constant)
1809 expr.
op0().
id() == ID_typecast &&
1813 const auto &
object =
1817 object.
id() == ID_symbol ||
object.
id() == ID_dynamic_object ||
1818 object.
id() == ID_member ||
object.
id() == ID_index ||
1819 object.
id() == ID_string_constant)
1825 expr.
op0().
id() == ID_typecast && expr.
op0().
type().
id() == ID_pointer)
1829 op.
type().
id() != ID_pointer &&
1831 op.
type().
id() == ID_complex))
1838 auto new_expr = expr;
1840 if(new_expr.op0().type().id() != ID_pointer)
1841 new_expr.op1() =
from_integer(0, new_expr.op0().type());
1843 new_expr.op1().type() = new_expr.op0().type();
1846 else if(expr.
op0().
id() == ID_plus)
1878 if(expr.
op0().
id()==ID_plus)
1882 if(expr.
id()==ID_equal || expr.
id()==ID_notequal)
1885 bool op_changed =
false;
1886 auto new_expr = expr;
1890 if(it->is_constant())
1908 new_expr.op1() =
from_integer(i, new_expr.op1().type());
1921 expr.
op0().
id() == ID_typecast && expr.
op0().
type().
id() == ID_floatbv &&
1929 ieee_floatt const_val_converted_back=const_val_converted;
1932 if(const_val_converted_back==const_val)
1937 return std::move(result);
1946 if(expr.
id()==ID_ge &&
1953 auto new_expr = expr;
1956 if(expr.
id()==ID_equal)
1959 if(operand.
id()==ID_unary_minus)
1962 return std::move(new_expr);
1964 else if(operand.
id()==ID_plus)
1969 if(operand_plus_expr.operands().size() == 2)
1972 if(operand_plus_expr.op0().id() == ID_unary_minus)
1973 operand_plus_expr.op0().swap(operand_plus_expr.op1());
1975 if(operand_plus_expr.op1().id() == ID_unary_minus)
1978 operand_plus_expr.op0(),
1987 if(
config.ansi_c.NULL_is_zero)
1990 if(maybe_tc_op.
type().
id() == ID_pointer)
1994 bool bitwidth_unchanged =
true;
1996 while(bitwidth_unchanged && ep->
id() == ID_typecast)
2000 bitwidth_unchanged = t->get_width() == p_type.
get_width();
2003 bitwidth_unchanged =
false;
2008 if(bitwidth_unchanged)
2010 if(expr.
id() == ID_equal || expr.
id() == ID_ge || expr.
id() == ID_le)
2027 expr.
op0().
id() == ID_typecast &&
2033 if(expr.
op1() == 0 && expr.
id() == ID_equal)
2039 if(expr.
op1() == 0 && expr.
id() == ID_notequal)
2041 return lhs_typecast_op;
2045 #define NORMALISE_CONSTANT_TESTS
2046 #ifdef NORMALISE_CONSTANT_TESTS
2048 if(expr.
op0().
type().
id()==ID_unsignedbv ||
2053 if(expr.
id()==ID_notequal)
2055 auto new_rel_expr = expr;
2056 new_rel_expr.
id(ID_equal);
2060 else if(expr.
id()==ID_gt)
2069 auto new_expr = expr;
2072 new_expr.op1() =
from_integer(i, new_expr.op1().type());
2075 else if(expr.
id()==ID_lt)
2077 auto new_rel_expr = expr;
2078 new_rel_expr.
id(ID_ge);
2082 else if(expr.
id()==ID_le)
2091 auto new_rel_expr = expr;
2092 new_rel_expr.
id(ID_ge);
2094 new_rel_expr.op1() =
from_integer(i, new_rel_expr.op1().type());
2111 if(!const_bits_opt.has_value())
2114 std::reverse(const_bits_opt->begin(), const_bits_opt->end());
2121 if(!result.has_value())
2124 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 bv_typet & to_bv_type(const typet &type)
Cast a typet to a bv_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 floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
unsignedbv_typet size_type()
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.
constant_exprt all_zeros_expr() const
constant_exprt all_ones_expr() const
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.
A constant literal expression.
const irep_idt & get_value() 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...
Base class for all expressions.
std::vector< exprt > operandst
bool is_boolean() const
Return whether the expression represents a Boolean.
bool is_constant() const
Return whether the expression is a constant.
typet & type()
Return the type of the expression.
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
An IEEE 754 floating-point value, including specificiation.
constant_exprt to_expr() const
An IEEE 754 value plus a rounding mode, enabling operations with rounding on values.
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.
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 ...
const exprt & base() const
const exprt & exponent() const
A base class for shift and rotate operators.
resultt simplify_bitwise(const multi_ary_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_object(const exprt &)
resultt simplify_mult(const mult_exprt &)
resultt simplify_inequality_rhs_is_constant(const binary_relation_exprt &)
virtual resultt simplify_inequality(const binary_relation_exprt &)
simplifies inequalities !=, <=, <, >=, >, and also ==
resultt simplify_not(const not_exprt &)
resultt simplify_bswap(const bswap_exprt &)
virtual 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 &)
virtual 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_power(const power_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)
auto type_try_dynamic_cast(TType &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TType >::type
Try to cast a reference to a generic typet to a specific derived class.
bool can_cast_type(const typet &base)
Check whether a reference to a generic typet is of a specific derived class.
auto expr_try_dynamic_cast(TExpr &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TExpr >::type
Try to cast a reference to a generic exprt to a specific derived class.
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
Deprecated expression utility functions.
API to expression classes for 'mathematical' expressions.
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 address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
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.
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)
exprt object_size(const exprt &pointer)
static bool mul_expr(constant_exprt &dest, const constant_exprt &expr)
static bool sum_expr(constant_exprt &dest, const constant_exprt &expr)
static bool eliminate_common_addends(exprt &op0, exprt &op1)
std::optional< exprt > bits2expr(const std::string &bits, const typet &type, bool little_endian, const namespacet &ns)
std::optional< std::string > expr2bits(const exprt &expr, 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)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
API to expression classes.
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.