74 if(type.
id()==ID_floatbv)
77 value.set_sign(
false);
81 else if(type.
id()==ID_signedbv ||
82 type.
id()==ID_unsignedbv)
116 if(type.
id()==ID_floatbv)
122 else if(type.
id()==ID_signedbv ||
123 type.
id()==ID_unsignedbv)
147 if(dest_type==src_type)
150 const exprt &casted_expr = expr.
op();
157 if(casted_expr.
id()==ID_floatbv_div ||
158 casted_expr.
id()==ID_floatbv_mult ||
159 casted_expr.
id()==ID_floatbv_plus ||
160 casted_expr.
id()==ID_floatbv_minus)
162 if(casted_expr.
operands().size()==3 &&
163 casted_expr.
op0().
id()==ID_typecast &&
164 casted_expr.
op1().
id()==ID_typecast &&
167 casted_expr.
op0().
type()==dest_type &&
168 casted_expr.
op1().
type()==dest_type)
170 exprt result(casted_expr.
id(), floatbv_typecast_expr.type());
174 result.
op2()=rounding_mode;
186 const auto rounding_mode_index = numeric_cast<mp_integer>(rounding_mode);
187 if(rounding_mode_index.has_value())
189 if(src_type.
id()==ID_floatbv)
191 if(dest_type.
id()==ID_floatbv)
196 *rounding_mode_index);
201 else if(dest_type.
id()==ID_signedbv ||
202 dest_type.
id()==ID_unsignedbv)
209 *rounding_mode_index);
215 else if(src_type.
id()==ID_signedbv ||
216 src_type.
id()==ID_unsignedbv)
218 const auto value = numeric_cast<mp_integer>(casted_expr);
219 if(value.has_value())
221 if(dest_type.
id()==ID_floatbv)
226 *rounding_mode_index);
232 else if(src_type.
id() == ID_c_enum_tag)
241 new_floatbv_typecast_expr.
op() = simplified_typecast;
254 if(casted_expr.
id()==ID_if)
256 auto const &casted_if_expr =
to_if_expr(casted_expr);
263 auto simplified_if_expr =
simplify_expr(
if_exprt(casted_if_expr.cond(), casted_true_case, casted_false_case, dest_type),
ns);
264 expr = simplified_if_expr;
279 expr.
id() == ID_floatbv_plus || expr.
id() == ID_floatbv_minus ||
280 expr.
id() == ID_floatbv_mult || expr.
id() == ID_floatbv_div);
288 "expression type of operand must match type of expression");
291 "expression type of operand must match type of expression");
302 const auto rounding_mode = numeric_cast<mp_integer>(op2);
303 if(rounding_mode.has_value())
312 if(expr.
id()==ID_floatbv_plus)
314 else if(expr.
id()==ID_floatbv_minus)
316 else if(expr.
id()==ID_floatbv_mult)
318 else if(expr.
id()==ID_floatbv_div)
328 if(expr.
id()==ID_floatbv_div &&
341 expr.
id() == ID_ieee_float_equal || expr.
id() == ID_ieee_float_notequal);
357 if(expr.
id()==ID_ieee_float_notequal)
359 else if(expr.
id()==ID_ieee_float_equal)
367 if(lhs_sorted.
id() == ID_floatbv_plus || lhs_sorted.
id() == ID_floatbv_mult)
370 if(rhs_sorted.
id() == ID_floatbv_plus || rhs_sorted.
id() == ID_floatbv_mult)
373 if(lhs_sorted == rhs_sorted)
378 if(expr.
id()==ID_ieee_float_notequal)
381 else if(expr.
id()==ID_ieee_float_equal)
386 return std::move(
isnan);
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.
A base class for relations, i.e., binary predicates whose two operands have the same type.
Base class for all expressions.
bool is_one() const
Return whether the expression is a constant representing 1.
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
Semantic type conversion from/to floating-point formats.
IEEE floating-point operations These have two data operands (op0 and op1) and one rounding mode (op2)...
mp_integer to_integer() const
bool ieee_equal(const ieee_floatt &other) const
constant_exprt to_expr() const
bool ieee_not_equal(const ieee_floatt &other) const
void from_integer(const mp_integer &i)
rounding_modet rounding_mode
void change_spec(const ieee_float_spect &dest_spec)
The trinary if-then-else operator.
const irep_idt & id() const
Evaluates to true if the operand is NaN.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
resultt simplify_isnan(const unary_exprt &)
resultt simplify_abs(const abs_exprt &)
resultt simplify_isnormal(const unary_exprt &)
resultt simplify_node(const exprt &)
resultt simplify_floatbv_typecast(const floatbv_typecast_exprt &)
resultt simplify_isinf(const unary_exprt &)
static resultt unchanged(exprt expr)
resultt simplify_floatbv_op(const ieee_float_op_exprt &)
resultt simplify_ieee_float_relation(const binary_relation_exprt &)
resultt simplify_sign(const sign_exprt &)
Semantic type conversion.
The type of an expression, extends irept.
Generic base class for unary expressions.
constant_exprt make_boolean_expr(bool value)
returns true_exprt if given true and false_exprt otherwise
Deprecated expression utility functions.
API to expression classes for floating-point arithmetic.
exprt simplify_expr(exprt src, const namespacet &ns)
bool sort_operands(exprt::operandst &operands)
sort operands of an expression according to ordering defined by operator<
#define UNREACHABLE
This should be used to mark dead code.
#define PRECONDITION(CONDITION)
API to expression classes.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.