41 std::vector<mp_integer> bytes;
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;
178 exprt::operandst::iterator constant;
186 for(exprt::operandst::iterator it =
new_operands.begin();
205 if(it->is_constant() && it->type()==expr.
type())
244 "c_sizeof_type is only set to a non-nil value "
245 "if a constant has been found");
273 return std::move(
tmp);
343 return std::move(
tmp);
425 const exprt::operandst::iterator next = std::next(it);
429 if(it->type()==next->type() &&
472 for(
const auto &op : expr.
operands())
474 if(
is_number(op.type()) && op.is_constant())
486 if(
is_number(it->type()) && it->is_constant())
508 typedef std::unordered_map<exprt, exprt::operandst::iterator, irep_hash>
526 expr_mapt::iterator
itm=expr_map.find(*it);
528 if(
itm!=expr_map.end())
540 for(exprt::operandst::iterator it =
new_operands.begin();
544 if(
is_number(it->type()) && it->is_zero())
569 return std::move(
tmp);
676 for(
const auto &op : expr.
operands())
681 else if(op.is_zero() || op.is_one())
708 else if(it->is_zero())
710 else if(it->is_one())
728 while(
new_expr.operands().size() >= 2)
745 std::function<
bool(
bool,
bool)> f;
748 f = [](
bool a,
bool b) {
return a &&
b; };
750 f = [](
bool a,
bool b) {
return a ||
b; };
752 f = [](
bool a,
bool b) {
return a !=
b; };
754 f = [](
bool a,
bool b) {
return a ==
b; };
777 for(exprt::operandst::iterator it =
new_expr.operands().begin();
780 if(it->is_zero() &&
new_expr.operands().size() > 1)
786 it->is_constant() && it->type().id() ==
ID_bv &&
803 for(exprt::operandst::iterator it =
new_expr.operands().begin();
887 const bool value = op.
is_true();
896 while(i <
new_expr.operands().size() - 1)
902 opi.is_constant() &&
opn.is_constant() &&
933 eb_i.src() ==
eb_n.src() &&
eb_i.index().is_constant() &&
934 eb_n.index().is_constant() &&
969 while(i <
new_expr.operands().size() - 1)
975 opi.is_constant() &&
opn.is_constant() &&
980 const std::string new_value=
1027 if(!distance.has_value())
1044 if(!value.has_value())
1056 if(*distance >= width)
1060 else if(*distance >= 0)
1063 *value +=
power(2, width);
1064 *value /=
power(2, *distance);
1080 if(*distance >= width)
1084 else if(*distance >= 0)
1086 *value *=
power(2, *distance);
1098 *value /=
power(2, *distance);
1108 if(*value < 0 && new_value == 0)
1118 *value *=
power(2, *distance);
1136 if(!exponent.has_value())
1139 if(exponent.value() == 0)
1142 if(exponent.value() == 1)
1145 if(!base.has_value())
1168 if(!end.has_value())
1173 if(!width.has_value())
1181 const auto start = std::optional(*end + *
result_width - 1);
1186 DATA_INVARIANT(*start >= *end,
"extractbits must have start >= end");
1200 if(!result.has_value())
1203 return std::move(*result);
1218 if(*start < offset && offset <= *end + *
op_width)
1232 if(
eb_src->index().is_constant())
1242 else if(*end == 0 && *start + 1 == *width)
1277 else if(
operand.is_constant())
1323 const auto &type = expr.
type();
1331 if(op.
type() == type)
1336 const auto new_value =
1337 make_bvrep(width, [&value, &width](std::size_t i) {
1705 "we previously converted all other cases to >= or ==");
1709 if(expr.
op0() == expr.
op1())
1785 const auto &
object =
1862 if(it->is_constant())
1909 return std::move(result);
2017 #define NORMALISE_CONSTANT_TESTS
2018 #ifdef NORMALISE_CONSTANT_TESTS
2093 if(!result.has_value())
2096 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 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.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
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.
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.
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.
bool is_constant() const
Return whether the expression is a constant.
typet & type()
Return the type of the expression.
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.
The trinary if-then-else operator.
const irep_idt & id() 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 &)
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 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)
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< 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.