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)
126 type_id == ID_integer || type_id == ID_natural ||
127 type_id == ID_unsignedbv || type_id == ID_signedbv)
136 else if(type_id==ID_rational)
145 else if(type_id==ID_fixedbv)
152 else if(type_id==ID_floatbv)
173 bool no_change =
true;
176 exprt::operandst::iterator constant;
179 bool constant_found =
false;
181 std::optional<typet> c_sizeof_type;
184 for(exprt::operandst::iterator it = new_operands.begin();
185 it != new_operands.end();)
194 it->type().id()!=ID_floatbv)
200 bool do_erase =
false;
203 if(it->is_constant() && it->type()==expr.
type())
206 if(!c_sizeof_type.has_value())
208 const typet &sizeof_type =
209 static_cast<const typet &
>(it->find(ID_C_c_sizeof_type));
211 c_sizeof_type = sizeof_type;
224 constant_found =
true;
231 it = new_operands.erase(it);
238 if(c_sizeof_type.has_value())
242 "c_sizeof_type is only set to a non-nil value "
243 "if a constant has been found");
244 constant->set(ID_C_c_sizeof_type, *c_sizeof_type);
247 if(new_operands.size() == 1)
249 return new_operands.front();
254 if(constant_found && constant->is_one())
257 new_operands.erase(constant);
260 if(new_operands.size() == 1)
261 return new_operands.front();
270 tmp.
operands() = std::move(new_operands);
271 return std::move(tmp);
282 if(expr_type!=expr.
op0().
type() ||
288 if(expr_type.
id()==ID_signedbv ||
289 expr_type.
id()==ID_unsignedbv ||
290 expr_type.
id()==ID_natural ||
291 expr_type.
id()==ID_integer)
293 const auto int_value0 = numeric_cast<mp_integer>(expr.
op0());
294 const auto int_value1 = numeric_cast<mp_integer>(expr.
op1());
297 if(int_value1.has_value() && *int_value1 == 0)
301 if(int_value1.has_value() && *int_value1 == 1)
307 if(int_value0.has_value() && *int_value0 == 0)
312 if(int_value0.has_value() && int_value1.has_value())
314 mp_integer result = *int_value0 / *int_value1;
318 else if(expr_type.
id()==ID_rational)
326 if(ok1 && rat_value1.
is_zero())
329 if((ok1 && rat_value1.
is_one()) ||
341 return std::move(tmp);
344 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)
382 const auto int_value0 = numeric_cast<mp_integer>(expr.
op0());
383 const auto int_value1 = numeric_cast<mp_integer>(expr.
op1());
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();
542 if(
is_number(it->type()) && it->is_zero())
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)
607 auto address_of = expr_try_dynamic_cast<address_of_exprt>(ptr_op0);
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->is_zero() &&
650 element_size.has_value() && element_size->is_constant() &&
651 !element_size->is_zero())
674 for(
const auto &op : expr.
operands())
679 else if(op.is_zero() || op.is_one())
691 if(expr.
id()==ID_bitand)
693 else if(expr.
id()==ID_bitor)
695 else if(expr.
id()==ID_bitxor)
702 if(it->id()==ID_typecast)
704 else if(it->is_zero())
706 else if(it->is_one())
717 bool no_change =
true;
718 auto new_expr = expr;
724 while(new_expr.operands().size() >= 2)
726 if(!new_expr.op0().is_constant())
729 if(!new_expr.op1().is_constant())
732 if(new_expr.op0().type() != new_expr.type())
735 if(new_expr.op1().type() != new_expr.type())
741 std::function<bool(
bool,
bool)> f;
743 if(new_expr.id() == ID_bitand)
744 f = [](
bool a,
bool b) {
return a && b; };
745 else if(new_expr.id() == ID_bitor)
746 f = [](
bool a,
bool b) {
return a || b; };
747 else if(new_expr.id() == ID_bitxor)
748 f = [](
bool a,
bool b) {
return a != b; };
749 else if(new_expr.id() == ID_bitxnor)
750 f = [](
bool a,
bool b) {
return a == b; };
755 make_bvrep(width, [&a_val, &b_val, &width, &f](std::size_t i) {
763 new_expr.operands().erase(new_expr.operands().begin());
764 new_expr.op0().swap(new_op);
771 if(new_expr.id() == ID_bitor || new_expr.id() == ID_bitxor)
773 for(exprt::operandst::iterator it = new_expr.operands().begin();
774 it != new_expr.operands().end();)
776 if(it->is_zero() && new_expr.operands().size() > 1)
778 it = new_expr.operands().erase(it);
782 it->is_constant() && it->type().id() == ID_bv &&
784 new_expr.operands().size() > 1)
786 it = new_expr.operands().erase(it);
796 if(new_expr.id() == ID_bitand)
798 const auto all_ones =
power(2, width) - 1;
799 for(exprt::operandst::iterator it = new_expr.operands().begin();
800 it != new_expr.operands().end();)
806 new_expr.operands().size() > 1)
808 it = new_expr.operands().erase(it);
818 if(new_expr.operands().size() == 2 && new_expr.op0() == new_expr.op1())
820 if(new_expr.id() == ID_bitand || new_expr.id() == ID_bitor)
822 return new_expr.op0();
824 else if(new_expr.id() == ID_bitxor)
830 if(new_expr.operands().size() == 1)
831 return new_expr.op0();
836 return std::move(new_expr);
849 const auto index_converted_to_int = numeric_cast<mp_integer>(expr.
index());
851 !index_converted_to_int.has_value() || *index_converted_to_int < 0 ||
852 *index_converted_to_int >= src_bit_width)
863 numeric_cast_v<std::size_t>(*index_converted_to_int));
871 bool no_change =
true;
883 const bool value = op.
is_true();
892 while(i < new_expr.
operands().size() - 1)
907 const auto new_width = width_i + width_n;
910 new_width, [&value_i, &value_n, width_i, width_n](std::size_t x) {
960 else if(new_expr.
type().
id() == ID_verilog_unsignedbv)
965 while(i < new_expr.
operands().size() - 1)
976 const std::string new_value=
978 opi.
set(ID_value, new_value);
980 opi.
type().
id(ID_verilog_unsignedbv);
994 return new_expr.
op0();
1000 return std::move(new_expr);
1021 const auto distance = numeric_cast<mp_integer>(expr.
distance());
1023 if(!distance.has_value())
1029 auto value = numeric_cast<mp_integer>(expr.
op());
1032 !value.has_value() && expr.
op().
type().
id() == ID_bv &&
1040 if(!value.has_value())
1044 expr.
op().
type().
id() == ID_unsignedbv ||
1049 if(expr.
id()==ID_lshr)
1052 if(*distance >= width)
1056 else if(*distance >= 0)
1059 *value +=
power(2, width);
1060 *value /=
power(2, *distance);
1064 else if(expr.
id()==ID_ashr)
1073 else if(expr.
id()==ID_shl)
1076 if(*distance >= width)
1080 else if(*distance >= 0)
1082 *value *=
power(2, *distance);
1088 expr.
op().
type().
id() == ID_integer || expr.
op().
type().
id() == ID_natural)
1090 if(expr.
id()==ID_lshr)
1094 *value /=
power(2, *distance);
1098 else if(expr.
id()==ID_ashr)
1104 if(*value < 0 && new_value == 0)
1110 else if(expr.
id()==ID_shl)
1114 *value *=
power(2, *distance);
1129 const auto base = numeric_cast<mp_integer>(expr.
base());
1130 const auto exponent = numeric_cast<mp_integer>(expr.
exponent());
1132 if(!exponent.has_value())
1135 if(exponent.value() == 0)
1138 if(exponent.value() == 1)
1141 if(!base.has_value())
1162 const auto end = numeric_cast<mp_integer>(expr.
index());
1164 if(!end.has_value())
1169 if(!width.has_value())
1174 if(!result_width.has_value())
1177 const auto start = std::optional(*end + *result_width - 1);
1179 if(*start < 0 || *start >= (*width) || *end < 0 || *end >= (*width))
1182 DATA_INVARIANT(*start >= *end,
"extractbits must have start >= end");
1188 if(!svalue.has_value() || svalue->size() != *width)
1191 std::string extracted_value = svalue->substr(
1192 numeric_cast_v<std::size_t>(*end),
1193 numeric_cast_v<std::size_t>(*start - *end + 1));
1196 if(!result.has_value())
1199 return std::move(*result);
1201 else if(expr.
src().
id() == ID_concatenation)
1211 if(!op_width.has_value() || *op_width <= 0)
1214 if(*start < offset && offset <= *end + *op_width)
1223 offset -= *op_width;
1226 else if(
auto eb_src = expr_try_dynamic_cast<extractbits_exprt>(expr.
src()))
1228 if(eb_src->index().is_constant())
1238 else if(*end == 0 && *start + 1 == *width)
1260 const exprt &operand = expr.
op();
1265 if(operand.
id()==ID_unary_minus)
1278 if(type_id==ID_integer ||
1279 type_id==ID_signedbv ||
1280 type_id==ID_unsignedbv)
1282 const auto int_value = numeric_cast<mp_integer>(constant_expr);
1284 if(!int_value.has_value())
1289 else if(type_id==ID_rational)
1297 else if(type_id==ID_fixedbv)
1303 else if(type_id==ID_floatbv)
1319 const auto &type = expr.
type();
1322 type.id() == ID_bv || type.id() == ID_unsignedbv ||
1323 type.id() == ID_signedbv)
1327 if(op.
type() == type)
1332 const auto new_value =
1333 make_bvrep(width, [&value, &width](std::size_t i) {
1359 if((expr.
id()==ID_equal || expr.
id()==ID_notequal) &&
1363 auto new_expr = expr;
1364 new_expr.
op0().
swap(new_expr.op1());
1368 if(tmp0.
id()==ID_if && tmp0.
operands().size()==3)
1382 (expr.
id() == ID_equal || expr.
id() == ID_notequal))
1387 if(tmp0.
id()==ID_pointer_object &&
1388 tmp1.
id()==ID_pointer_object &&
1389 (expr.
id()==ID_equal || expr.
id()==ID_notequal))
1394 if(tmp0.
type().
id()==ID_c_enum_tag)
1397 if(tmp1.
type().
id()==ID_c_enum_tag)
1404 if(tmp0_const && tmp1_const)
1414 if(expr.
id()==ID_ge)
1416 else if(expr.
id()==ID_le)
1418 else if(expr.
id()==ID_gt)
1420 else if(expr.
id()==ID_lt)
1448 if(tmp0.
type().
id() == ID_c_enum_tag)
1451 if(tmp1.
type().
id() == ID_c_enum_tag)
1457 if(expr.
id() == ID_equal || expr.
id() == ID_notequal)
1461 bool equal = (tmp0_const.get_value() == tmp1_const.get_value());
1463 !equal && tmp0_const.type().id() == ID_pointer &&
1464 tmp1_const.type().id() == ID_pointer)
1468 tmp1_const.get_value() == ID_NULL))
1474 equal = tmp0_const.is_zero() && tmp1_const.is_zero();
1479 if(tmp0.
type().
id() == ID_fixedbv)
1484 if(expr.
id() == ID_ge)
1486 else if(expr.
id() == ID_le)
1488 else if(expr.
id() == ID_gt)
1490 else if(expr.
id() == ID_lt)
1495 else if(tmp0.
type().
id() == ID_floatbv)
1500 if(expr.
id() == ID_ge)
1502 else if(expr.
id() == ID_le)
1504 else if(expr.
id() == ID_gt)
1506 else if(expr.
id() == ID_lt)
1511 else if(tmp0.
type().
id() == ID_rational)
1521 if(expr.
id() == ID_ge)
1523 else if(expr.
id() == ID_le)
1525 else if(expr.
id() == ID_gt)
1527 else if(expr.
id() == ID_lt)
1534 const auto v0 = numeric_cast<mp_integer>(tmp0_const);
1539 const auto v1 = numeric_cast<mp_integer>(tmp1_const);
1544 if(expr.
id() == ID_ge)
1546 else if(expr.
id() == ID_le)
1548 else if(expr.
id() == ID_gt)
1550 else if(expr.
id() == ID_lt)
1568 if(op0.
id()==ID_plus)
1570 bool no_change =
true;
1578 else if(op1.
id()==ID_plus)
1580 bool no_change =
true;
1591 op0.
type().
id()!=ID_complex)
1609 if(expr.
op0().
type().
id() == ID_floatbv)
1612 if(expr.
op0().
type().
id() == ID_pointer)
1617 if(ptr_op0 == ptr_op1)
1623 std::move(offset_op0), expr.
id(), std::move(offset_op1)}));
1626 else if(expr.
id() != ID_equal && expr.
id() != ID_notequal)
1631 expr.
id() == ID_equal && ptr_op0.
id() == ID_address_of &&
1632 ptr_op1.
id() == ID_address_of)
1637 auto in_bounds = [
this](
const exprt &object_ptr,
const exprt &expr_op) {
1644 exprt in_object_bounds =
1646 std::move(offset), ID_lt, std::move(*
object_size)})
1656 in_bounds(ptr_op0, expr.
op0()).is_true() &&
1657 in_bounds(ptr_op1, expr.
op1()).is_true())
1665 if(expr.
id()==ID_notequal)
1667 auto new_rel_expr = expr;
1668 new_rel_expr.
id(ID_equal);
1672 else if(expr.
id()==ID_gt)
1674 auto new_rel_expr = expr;
1675 new_rel_expr.
id(ID_ge);
1677 new_rel_expr.lhs().
swap(new_rel_expr.rhs());
1681 else if(expr.
id()==ID_lt)
1683 auto new_rel_expr = expr;
1684 new_rel_expr.
id(ID_ge);
1688 else if(expr.
id()==ID_le)
1690 auto new_rel_expr = expr;
1691 new_rel_expr.
id(ID_ge);
1693 new_rel_expr.lhs().
swap(new_rel_expr.rhs());
1700 expr.
id() == ID_ge || expr.
id() == ID_equal,
1701 "we previously converted all other cases to >= or ==");
1705 if(expr.
op0() == expr.
op1())
1710 if(expr.
id()==ID_equal)
1746 if(expr.
id()==ID_notequal)
1748 auto new_rel_expr = expr;
1749 new_rel_expr.
id(ID_equal);
1755 if(expr.
id() != ID_equal)
1764 if(expr.
op0().
id() == ID_address_of)
1769 object.
id() == ID_symbol ||
object.
id() == ID_dynamic_object ||
1770 object.
id() == ID_member ||
object.
id() == ID_index ||
1771 object.
id() == ID_string_constant)
1777 expr.
op0().
id() == ID_typecast &&
1781 const auto &
object =
1785 object.
id() == ID_symbol ||
object.
id() == ID_dynamic_object ||
1786 object.
id() == ID_member ||
object.
id() == ID_index ||
1787 object.
id() == ID_string_constant)
1793 expr.
op0().
id() == ID_typecast && expr.
op0().
type().
id() == ID_pointer)
1797 op.
type().
id() != ID_pointer &&
1799 op.
type().
id() == ID_complex))
1806 auto new_expr = expr;
1808 if(new_expr.op0().type().id() != ID_pointer)
1809 new_expr.op1() =
from_integer(0, new_expr.op0().type());
1811 new_expr.op1().type() = new_expr.op0().type();
1814 else if(expr.
op0().
id() == ID_plus)
1826 else if(
auto address_of = expr_try_dynamic_cast<address_of_exprt>(ptr))
1846 if(expr.
op0().
id()==ID_plus)
1850 if(expr.
id()==ID_equal || expr.
id()==ID_notequal)
1853 bool op_changed =
false;
1854 auto new_expr = expr;
1858 if(it->is_constant())
1876 new_expr.op1() =
from_integer(i, new_expr.op1().type());
1889 expr.
op0().
id() == ID_typecast && expr.
op0().
type().
id() == ID_floatbv &&
1896 ieee_floatt const_val_converted_back=const_val_converted;
1899 if(const_val_converted_back==const_val)
1904 return std::move(result);
1913 if(expr.
id()==ID_ge &&
1920 auto new_expr = expr;
1923 if(expr.
id()==ID_equal)
1926 if(operand.
id()==ID_unary_minus)
1929 return std::move(new_expr);
1931 else if(operand.
id()==ID_plus)
1936 if(operand_plus_expr.operands().size() == 2)
1939 if(operand_plus_expr.op0().id() == ID_unary_minus)
1940 operand_plus_expr.op0().swap(operand_plus_expr.op1());
1942 if(operand_plus_expr.op1().id() == ID_unary_minus)
1945 operand_plus_expr.op0(),
1957 if(maybe_tc_op.
type().
id() == ID_pointer)
1961 bool bitwidth_unchanged =
true;
1963 while(bitwidth_unchanged && ep->
id() == ID_typecast)
1965 if(
auto t = type_try_dynamic_cast<bitvector_typet>(ep->
type()))
1967 bitwidth_unchanged = t->get_width() == p_type.
get_width();
1970 bitwidth_unchanged =
false;
1975 if(bitwidth_unchanged)
1977 if(expr.
id() == ID_equal || expr.
id() == ID_ge || expr.
id() == ID_le)
1994 expr.
op0().
id() == ID_typecast &&
2008 return lhs_typecast_op;
2012 #define NORMALISE_CONSTANT_TESTS
2013 #ifdef NORMALISE_CONSTANT_TESTS
2015 if(expr.
op0().
type().
id()==ID_unsignedbv ||
2020 if(expr.
id()==ID_notequal)
2022 auto new_rel_expr = expr;
2023 new_rel_expr.
id(ID_equal);
2027 else if(expr.
id()==ID_gt)
2036 auto new_expr = expr;
2039 new_expr.op1() =
from_integer(i, new_expr.op1().type());
2042 else if(expr.
id()==ID_lt)
2044 auto new_rel_expr = expr;
2045 new_rel_expr.
id(ID_ge);
2049 else if(expr.
id()==ID_le)
2058 auto new_rel_expr = expr;
2059 new_rel_expr.
id(ID_ge);
2061 new_rel_expr.op1() =
from_integer(i, new_rel_expr.op1().type());
2078 if(!const_bits_opt.has_value())
2081 std::reverse(const_bits_opt->begin(), const_bits_opt->end());
2088 if(!result.has_value())
2091 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 ...
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_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_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)
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.
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 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.