Go to the documentation of this file.
9 #ifndef CPROVER_UTIL_BITVECTOR_EXPR_H
10 #define CPROVER_UTIL_BITVECTOR_EXPR_H
22 :
unary_exprt(ID_bswap, std::move(_op), std::move(_type))
47 return base.
id() == ID_bswap;
54 value.
op().
type() == value.
type(),
"bswap type must match operand type");
92 return base.
id() == ID_bitnot;
136 return base.
id() == ID_bitor;
171 return base.
id() == ID_bitxor;
206 return base.
id() == ID_bitand;
233 :
binary_exprt(std::move(_src), _id, std::move(_distance))
263 return base.
id() == ID_shl || base.
id() == ID_ashr || base.
id() == ID_lshr ||
264 base.
id() == ID_ror || base.
id() == ID_rol;
298 :
shift_exprt(std::move(_src), ID_shl, std::move(_distance))
311 return base.
id() == ID_shl;
342 :
shift_exprt(std::move(_src), ID_ashr, std::move(_distance))
355 return base.
id() == ID_ashr;
363 :
shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
368 :
shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
376 return base.
id() == ID_lshr;
415 return base.
id() == ID_extractbit;
459 {std::move(_src), std::move(_upper), std::move(_lower)})
465 const std::size_t _upper,
466 const std::size_t _lower,
503 return base.
id() == ID_extractbits;
571 return base.
id() == ID_replication;
611 :
multi_ary_exprt(ID_concatenation, std::move(_operands), std::move(_type))
618 {std::move(_op0), std::move(_op1)},
627 return base.
id() == ID_concatenation;
654 :
unary_exprt(ID_popcount, std::move(_op), std::move(_type))
671 return base.
id() == ID_popcount;
712 "The kind used to construct binary_overflow_exprt should be in the set "
713 "of expected valid kinds.");
722 if(expr.
id() != ID_overflow_shl)
728 "operand types must match");
743 return id == ID_overflow_plus ||
id == ID_overflow_mult ||
744 id == ID_overflow_minus ||
id == ID_overflow_shl;
766 value, 2,
"binary overflow expression must have two operands");
778 expr.
id() == ID_overflow_plus || expr.
id() == ID_overflow_mult ||
779 expr.
id() == ID_overflow_minus || expr.
id() == ID_overflow_shl);
790 expr.
id() == ID_overflow_plus || expr.
id() == ID_overflow_mult ||
791 expr.
id() == ID_overflow_minus || expr.
id() == ID_overflow_shl);
813 return base.
id() == ID_overflow_plus;
832 return base.
id() == ID_overflow_minus;
851 return base.
id() == ID_overflow_mult;
866 return base.
id() == ID_overflow_shl;
898 return base.
id() == ID_overflow_unary_minus;
904 value, 1,
"unary overflow expression must have one operand");
936 return base.
id() == ID_overflow_unary_minus;
942 value, 1,
"unary minus overflow expression must have one operand");
978 :
unary_exprt(ID_count_leading_zeros, std::move(_op), std::move(_type))
990 return !
get_bool(ID_C_bounds_check);
995 set(ID_C_bounds_check, !value);
1005 "unary expression must have a single operand");
1009 "operand must be of bitvector type");
1028 return base.
id() == ID_count_leading_zeros;
1071 :
unary_exprt(ID_count_trailing_zeros, std::move(_op), std::move(_type))
1083 return !
get_bool(ID_C_bounds_check);
1088 set(ID_C_bounds_check, !value);
1098 "unary expression must have a single operand");
1102 "operand must be of bitvector type");
1121 return base.
id() == ID_count_trailing_zeros;
1172 return base.
id() == ID_bitreverse;
1208 :
binary_exprt(std::move(_lhs), ID_saturating_plus, std::move(_rhs))
1225 return base.
id() == ID_saturating_plus;
1262 :
binary_exprt(std::move(_lhs), ID_saturating_minus, std::move(_rhs))
1270 return base.
id() == ID_saturating_minus;
1311 {{ID_value, _lhs.
type()},
1313 {_lhs, std::move(_rhs)})
1317 "The kind used to construct overflow_result_exprt should be in the set "
1318 "of expected valid kinds.");
1325 {{ID_value, _op.
type()},
1331 "The kind used to construct overflow_result_exprt should be in the set "
1332 "of expected valid kinds.");
1348 if(expr.
id() != ID_overflow_result_unary_minus)
1352 expr.
id() != ID_overflow_result_unary_minus &&
1353 expr.
id() != ID_overflow_result_shl)
1359 "operand types must match");
1374 return id == ID_overflow_result_plus ||
id == ID_overflow_result_mult ||
1375 id == ID_overflow_result_minus ||
id == ID_overflow_result_shl ||
1376 id == ID_overflow_result_unary_minus;
1382 return "overflow_result-" +
id2string(kind);
1394 if(value.
id() == ID_overflow_result_unary_minus)
1397 value, 1,
"unary overflow expression must have two operands");
1402 value, 2,
"binary overflow expression must have two operands");
1436 :
unary_exprt(ID_find_first_set, std::move(_op), std::move(_type))
1452 "unary expression must have a single operand");
1456 "operand must be of bitvector type");
1475 return base.
id() == ID_find_first_set;
1507 #endif // CPROVER_UTIL_BITVECTOR_EXPR_H
static irep_idt make_id(const irep_idt &kind)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
binary_overflow_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
find_first_set_exprt(const exprt &_op)
std::size_t get_size_t(const irep_idt &name) const
plus_overflow_exprt(exprt _lhs, exprt _rhs)
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
shl_exprt(exprt _src, const std::size_t _distance)
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
bool can_cast_expr< saturating_minus_exprt >(const exprt &base)
A base class for multi-ary expressions Associativity is not specified.
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
mult_overflow_exprt(exprt _lhs, exprt _rhs)
shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
bool can_cast_expr< bitor_exprt >(const exprt &base)
The count trailing zeros (counting the number of zero bits starting from the least-significant bit) e...
exprt lower() const
Lower a count_leading_zeros_exprt to arithmetic and logic expressions.
bool can_cast_expr< count_trailing_zeros_exprt >(const exprt &base)
lshr_exprt(exprt _src, exprt _distance)
bool can_cast_expr< replication_exprt >(const exprt &base)
unary_overflow_exprt(const irep_idt &kind, exprt _op)
const bitor_exprt & to_bitor_expr(const exprt &expr)
Cast an exprt to a bitor_exprt.
bool can_cast_expr< count_leading_zeros_exprt >(const exprt &base)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
The type of an expression, extends irept.
bool can_cast_expr< shift_exprt >(const exprt &base)
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of an overflow_exprt.
bool can_cast_expr< concatenation_exprt >(const exprt &base)
exprt lower() const
Lower a count_trailing_zeros_exprt to arithmetic and logic expressions.
exprt lower() const
Lower a plus_overflow_exprt to arithmetic and logic expressions.
void validate_operands(const exprt &value, exprt::operandst::size_type number, const char *message, bool allow_more=false)
exprt lower() const
Lower a popcount_exprt to arithmetic and logic expressions.
bool can_cast_expr< bitand_exprt >(const exprt &base)
unary_minus_overflow_exprt(exprt _op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
bitxor_exprt(exprt _op0, exprt _op1)
static irep_idt make_id(const irep_idt &kind)
bool can_cast_expr< saturating_plus_exprt >(const exprt &base)
bool zero_permitted() const
Base class for all expressions.
minus_overflow_exprt(exprt _lhs, exprt _rhs)
const exprt & op3() const =delete
Generic base class for unary expressions.
ashr_exprt(exprt _src, exprt _distance)
A base class for binary expressions.
An expression returning both the result of the arithmetic operation under wrap-around semantics as we...
saturating_plus_exprt(exprt _lhs, exprt _rhs, typet _type)
bswap_exprt(exprt _op, std::size_t bits_per_byte)
std::size_t get_bits_per_byte() const
exprt lower() const
Lower a mult_overflow_exprt to arithmetic and logic expressions.
Concatenation of bit-vector operands.
const bitnot_exprt & to_bitnot_expr(const exprt &expr)
Cast an exprt to a bitnot_exprt.
exprt lower() const
Lower a find_first_set_exprt to arithmetic and logic expressions.
replication_exprt(constant_exprt _times, exprt _src, typet _type)
bool can_cast_expr< bitnot_exprt >(const exprt &base)
Saturating subtraction expression.
const popcount_exprt & to_popcount_expr(const exprt &expr)
Cast an exprt to a popcount_exprt.
count_trailing_zeros_exprt(const exprt &_op)
const find_first_set_exprt & to_find_first_set_expr(const exprt &expr)
Cast an exprt to a find_first_set_exprt.
bool can_cast_expr< find_first_set_exprt >(const exprt &base)
count_leading_zeros_exprt(const exprt &_op)
bool can_cast_expr< extractbit_exprt >(const exprt &base)
The saturating plus expression.
bool can_cast_expr< lshr_exprt >(const exprt &base)
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const bswap_exprt & to_bswap_expr(const exprt &expr)
Cast an exprt to a bswap_exprt.
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
void validate_expr(const bswap_exprt &value)
bool can_cast_expr< bitreverse_exprt >(const exprt &base)
void zero_permitted(bool value)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool can_cast_expr< overflow_result_exprt >(const exprt &base)
typet & type()
Return the type of the expression.
bool zero_permitted() const
bool can_cast_expr< unary_minus_overflow_exprt >(const exprt &base)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
overflow_result_exprt(exprt _op, const irep_idt &kind)
const std::string & id2string(const irep_idt &d)
bitor_exprt(const exprt &_op0, exprt _op1)
void set(const irep_idt &name, const irep_idt &value)
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
#define PRECONDITION(CONDITION)
bool can_cast_expr< plus_overflow_exprt >(const exprt &base)
void zero_permitted(bool value)
shl_exprt(exprt _src, exprt _distance)
const unary_overflow_exprt & to_unary_overflow_expr(const exprt &expr)
Cast an exprt to a unary_overflow_exprt.
find_first_set_exprt(exprt _op, typet _type)
concatenation_exprt(operandst _operands, typet _type)
overflow_result_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
saturating_plus_exprt(exprt _lhs, exprt _rhs)
const irep_idt & id() const
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
popcount_exprt(const exprt &_op)
std::vector< exprt > operandst
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
const shl_exprt & to_shl_expr(const exprt &expr)
Cast an exprt to a shl_exprt.
void set_size_t(const irep_idt &name, const std::size_t value)
saturating_minus_exprt(exprt _lhs, exprt _rhs)
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
const binary_overflow_exprt & to_binary_overflow_expr(const exprt &expr)
Cast an exprt to a binary_overflow_exprt.
Bit-wise negation of bit-vectors.
const concatenation_exprt & to_concatenation_expr(const exprt &expr)
Cast an exprt to a concatenation_exprt.
A Boolean expression returning true, iff operation kind would result in an overflow when applied to t...
A base class for shift and rotate operators.
static void check(const exprt &, const validation_modet)
Check that the expression is well-formed (shallow checks only, i.e., subexpressions and its type are ...
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Structure type, corresponds to C style structs.
bool can_cast_expr< bitxor_exprt >(const exprt &base)
shl_overflow_exprt(exprt _lhs, exprt _rhs)
A Boolean expression returning true, iff negation would result in an overflow when applied to the (si...
bitand_exprt(const exprt &_op0, exprt _op1)
const bitreverse_exprt & to_bitreverse_expr(const exprt &expr)
Cast an exprt to a bitreverse_exprt.
bool can_cast_expr< bswap_exprt >(const exprt &base)
bool can_cast_expr< binary_overflow_exprt >(const exprt &base)
lshr_exprt(exprt _src, const std::size_t _distance)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
bool can_cast_expr< unary_overflow_exprt >(const exprt &base)
bool can_cast_expr< shl_exprt >(const exprt &base)
bool can_cast_expr< extractbits_exprt >(const exprt &base)
void set_bits_per_byte(std::size_t bits_per_byte)
bool can_cast_expr< mult_overflow_exprt >(const exprt &base)
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
bool can_cast_expr< popcount_exprt >(const exprt &base)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
concatenation_exprt(exprt _op0, exprt _op1, typet _type)
const overflow_result_exprt & to_overflow_result_expr(const exprt &expr)
Cast an exprt to a overflow_result_exprt.
The byte swap expression.
const exprt & distance() const
const saturating_minus_exprt & to_saturating_minus_expr(const exprt &expr)
Cast an exprt to a saturating_minus_exprt.
exprt lower() const
Lower a bitreverse_exprt to arithmetic and logic expressions.
Returns one plus the index of the least-significant one bit, or zero if the operand is zero.
count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
ashr_exprt(exprt _src, const std::size_t _distance)
bool can_cast_expr< ashr_exprt >(const exprt &base)
exprt lower() const
Lower a minus_overflow_exprt to arithmetic and logic expressions.
const bitand_exprt & to_bitand_expr(const exprt &expr)
Cast an exprt to a bitand_exprt.
The popcount (counting the number of bits set to 1) expression.
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
const constant_exprt & times() const
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of a binary_overflow_exprt.
A constant literal expression.
const exprt & op2() const =delete
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
bswap_exprt(exprt _op, std::size_t bits_per_byte, typet _type)
bool can_cast_expr< shl_overflow_exprt >(const exprt &base)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly one argu...
popcount_exprt(exprt _op, typet _type)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
bool get_bool(const irep_idt &name) const
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
const count_leading_zeros_exprt & to_count_leading_zeros_expr(const exprt &expr)
Cast an exprt to a count_leading_zeros_exprt.
const replication_exprt & to_replication_expr(const exprt &expr)
Cast an exprt to a replication_exprt.
bitreverse_exprt(exprt op)
Base class for all expressions.
const saturating_plus_exprt & to_saturating_plus_expr(const exprt &expr)
Cast an exprt to a saturating_plus_exprt.
The count leading zeros (counting the number of zero bits starting from the most-significant bit) exp...
bool can_cast_expr< minus_overflow_exprt >(const exprt &base)
Reverse the order of bits in a bit-vector.
const bitxor_exprt & to_bitxor_expr(const exprt &expr)
Cast an exprt to a bitxor_exprt.