20 else if(expr.
id()==ID_unary_minus)
22 else if(expr.
id()==ID_ieee_float_equal)
24 else if(expr.
id()==ID_ieee_float_notequal)
26 else if(expr.
id()==ID_floatbv_typecast)
31 if(dest_type.
id()==ID_signedbv &&
32 src_type.
id()==ID_floatbv)
39 else if(dest_type.
id()==ID_unsignedbv &&
40 src_type.
id()==ID_floatbv)
47 else if(src_type.
id()==ID_signedbv &&
48 dest_type.
id()==ID_floatbv)
51 else if(src_type.
id()==ID_unsignedbv &&
52 dest_type.
id()==ID_floatbv)
55 else if(dest_type.
id()==ID_floatbv &&
56 src_type.
id()==ID_floatbv)
63 else if(expr.
id()==ID_typecast &&
64 expr.
type().
id()==ID_bool &&
67 else if(expr.
id()==ID_floatbv_plus)
69 else if(expr.
id()==ID_floatbv_minus)
71 else if(expr.
id()==ID_floatbv_mult)
73 else if(expr.
id()==ID_floatbv_div)
75 else if(expr.
id()==ID_isnan)
77 else if(expr.
id()==ID_isfinite)
79 else if(expr.
id()==ID_isinf)
81 else if(expr.
id()==ID_isnormal)
83 else if(expr.
id()==ID_lt)
85 else if(expr.
id()==ID_gt)
87 else if(expr.
id()==ID_le)
89 else if(expr.
id()==ID_ge)
91 else if(expr.
id()==ID_sign)
131 const and_exprt both_zero(is_zero0, is_zero1);
192 exprt round_to_plus_inf_const=
194 exprt round_to_minus_inf_const=
232 return rounder(result, rm, spec);
254 return rounder(result, rm, spec);
259 std::size_t dest_width,
263 return to_integer(src, dest_width,
true, rm, spec);
268 std::size_t dest_width,
272 return to_integer(src, dest_width,
false, rm, spec);
277 std::size_t dest_width,
295 exprt result=shift_result;
339 int sourceSmallestNormalExponent = -((1 << (src_spec.
e - 1)) - 1);
340 int sourceSmallestDenormalExponent =
341 sourceSmallestNormalExponent - src_spec.
f;
345 int destSmallestNormalExponent = -((1 << (dest_spec.
e - 1)) - 1);
347 if(dest_spec.
e>=src_spec.
e &&
348 dest_spec.
f>=src_spec.
f &&
349 !(sourceSmallestDenormalExponent < destSmallestNormalExponent))
355 std::size_t padding=dest_spec.
f-src_spec.
f;
365 "the exponent needs to have a signed type");
371 if(dest_spec.
e > src_spec.
e)
376 result.
NaN=unpacked_src.
NaN;
380 return pack(
bias(result, dest_spec), dest_spec);
386 return rounder(result, rm, dest_spec);
416 return minus_exprt(extended_exponent1, extended_exponent2);
435 const sign_exprt src2_bigger(exponent_difference);
437 const exprt bigger_exponent=
441 const exprt new_fraction1=
444 const exprt new_fraction2=
448 const exprt distance=
457 const exprt fraction1_padded=
459 const exprt fraction2_padded=
464 const exprt fraction1_shifted=fraction1_padded;
466 fraction2_padded, limited_dist, sticky_bit);
474 fraction2_shifted.
type()));
477 const exprt fraction1_ext=
479 const exprt fraction2_ext=
561 return rounder(result, rm, spec);
572 if(dist_width<=nb_bits)
614 const plus_exprt added_exponent(exponent1, exponent2);
635 return rounder(result, rm, spec);
648 std::size_t fraction_width=
650 std::size_t div_width=fraction_width*2+1;
666 result.fraction=
div_exprt(fraction1, fraction2);
686 const minus_exprt added_exponent(exponent1, exponent2);
724 return rounder(result, rm, spec);
740 "relation should be equality, less-than, or less-or-equal");
745 const and_exprt both_zero(is_zero1, is_zero2);
788 return std::move(and_bv);
838 src, spec.
f+spec.
e-1, spec.
f,
874 if(exponent_bits<depth)
879 for(
int d=depth-1; d>=0; d--)
881 unsigned distance=(1<<d);
883 fraction_bits > distance,
884 "distance must be within the range of fraction bits");
890 fraction_bits - distance,
896 const shl_exprt shifted(fraction, distance);
899 if_exprt(prefix_is_zero, shifted, fraction);
902 INVARIANT(d < (
signed int)exponent_bits,
"");
952 if(fraction_bits < spec.
f+3)
961 exprt denormalisedFraction = fraction;
964 denormalisedFraction =
967 denormalisedFraction=
974 denormalisedFraction,
1004 std::size_t exponent_bits = std::max(
address_bits(spec.
f), spec.
e) + 1;
1030 return pack(
bias(result, spec), spec);
1035 const std::size_t dest_bits,
1037 const exprt &fraction,
1040 std::size_t fraction_bits=
1046 std::size_t extra_bits=fraction_bits-dest_bits;
1064 extra_bits >= 1,
"the extra bits contain at least the rounding bit");
1072 rounding_bit,
or_exprt(rounding_least, sticky_bit));
1097 std::size_t fraction_size=spec.
f+1;
1098 std::size_t result_fraction_size=
1102 if(result_fraction_size<fraction_size)
1105 std::size_t padding=fraction_size-result_fraction_size;
1112 else if(result_fraction_size==fraction_size)
1118 std::size_t extra_bits=result_fraction_size-fraction_size;
1120 extra_bits >= 1,
"the extra bits include at least the rounding bit");
1124 fraction_size, result.
sign, result.
fraction, rounding_mode_bits);
1128 result.
fraction, result_fraction_size-1, extra_bits,
1144 bv_utils.incrementer(result.
exponent, overflow);
1149 const or_exprt new_integer_part(integer_part1, integer_part0);
1152 result.
fraction.back()=new_integer_part;
1183 or_exprt(overflow, subnormal_to_normal),
1204 std::size_t result_exponent_size=
1210 if(result_exponent_size == spec.
e)
1243 exprt largest_normal_exponent=
1395 for(std::size_t stage=0; stage<dist_width; stage++)
1415 result=
if_exprt(dist_bit, tmp, result);
static void round_exponent(unbiased_floatt &result, const rounding_mode_bitst &, const ieee_float_spect &)
static exprt isinf(const exprt &, const ieee_float_spect &)
exprt from_signed_integer(const exprt &, const exprt &rm, const ieee_float_spect &) const
The type of an expression, extends irept.
bool is_signed(const typet &t)
Convenience function – is the type signed?
static exprt relation(const exprt &, relt rel, const exprt &, const ieee_float_spect &)
static ieee_float_spect get_spec(const exprt &)
Fixed-width bit-vector with unsigned binary interpretation.
constant_exprt zero_expr() const
Semantic type conversion.
static exprt add_bias(const exprt &exponent, const ieee_float_spect &)
static exprt subtract_exponents(const unbiased_floatt &src1, const unbiased_floatt &src2)
Subtracts the exponents.
A base class for relations, i.e., binary predicates.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
static exprt to_integer(const exprt &src, std::size_t dest_width, bool is_signed, const exprt &rm, const ieee_float_spect &)
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
Fixed-width bit-vector with IEEE floating-point interpretation.
static exprt is_zero(const exprt &)
static exprt pack(const biased_floatt &, const ieee_float_spect &)
static exprt sign_bit(const exprt &)
static exprt negation(const exprt &, const ieee_float_spect &)
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
static void round_fraction(unbiased_floatt &result, const rounding_mode_bitst &, const ieee_float_spect &)
static biased_floatt bias(const unbiased_floatt &, const ieee_float_spect &)
takes an unbiased float, and applies the bias
The trinary if-then-else operator.
typet & type()
Return the type of the expression.
exprt conversion(const exprt &src, const exprt &rm, const ieee_float_spect &src_spec, const ieee_float_spect &dest_spec) const
mp_integer max_exponent() const
exprt rounder(const unbiased_floatt &, const exprt &rm, const ieee_float_spect &) const
A constant literal expression.
static exprt to_unsigned_integer(const exprt &src, std::size_t dest_width, const exprt &rm, const ieee_float_spect &)
class floatbv_typet to_type() const
Concatenation of bit-vector operands.
static exprt exponent_all_ones(const exprt &, const ieee_float_spect &)
const irep_idt & id() const
Fixed-width bit-vector with two's complement interpretation.
exprt convert(const exprt &) const
static exprt isnormal(const exprt &, const ieee_float_spect &)
API to expression classes.
static exprt is_equal(const exprt &, const exprt &, const ieee_float_spect &)
#define PRECONDITION(CONDITION)
static exprt exponent_all_zeros(const exprt &, const ieee_float_spect &)
The plus expression Associativity is not specified.
exprt from_unsigned_integer(const exprt &, const exprt &rm, const ieee_float_spect &) const
static exprt abs(const exprt &, const ieee_float_spect &)
The unary minus expression.
Base class of fixed-width bit-vector types.
The Boolean constant false.
std::size_t get_width() const
exprt disjunction(const exprt::operandst &op)
1) generates a disjunction for two or more operands 2) for one operand, returns the operand 3) return...
Binary multiplication Associativity is not specified.
static exprt get_exponent(const exprt &, const ieee_float_spect &)
Gets the unbiased exponent in a floating-point bit-vector.
void get(const exprt &rm)
static exprt sub_bias(const exprt &exponent, const ieee_float_spect &)
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
static exprt fraction_rounding_decision(const std::size_t dest_bits, const exprt sign, const exprt &fraction, const rounding_mode_bitst &)
rounding decision for fraction using sticky bit
static exprt sticky_right_shift(const exprt &op, const exprt &dist, exprt &sticky)
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
Base class for all expressions.
Sign of an expression Predicate is true if _op is negative, false otherwise.
static exprt limit_distance(const exprt &dist, mp_integer limit)
Limits the shift distance.
static unbiased_floatt unpack(const exprt &, const ieee_float_spect &)
static void normalization_shift(exprt &fraction, exprt &exponent)
normalize fraction/exponent pair returns 'zero' if fraction is zero
#define UNREACHABLE
This should be used to mark dead code.
static exprt isfinite(const exprt &, const ieee_float_spect &)
const abs_exprt & to_abs_expr(const exprt &expr)
Cast an exprt to a abs_exprt.
static exprt get_fraction(const exprt &, const ieee_float_spect &)
Gets the fraction without hidden bit in a floating-point bit-vector src.
static exprt fraction_all_zeros(const exprt &, const ieee_float_spect &)
std::size_t width() const
exprt mul(const exprt &, const exprt &, const exprt &rm, const ieee_float_spect &) const
exprt add_sub(bool subtract, const exprt &, const exprt &, const exprt &rm, const ieee_float_spect &) const
Fixed-width bit-vector without numerical interpretation.
static exprt to_signed_integer(const exprt &src, std::size_t dest_width, const exprt &rm, const ieee_float_spect &)
exprt div(const exprt &, const exprt &, const exprt &rm, const ieee_float_spect &) const
static void denormalization_shift(exprt &fraction, exprt &exponent, const ieee_float_spect &)
make sure exponent is not too small; the exponent is unbiased
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
void reserve_operands(operandst::size_type n)
static exprt isnan(const exprt &, const ieee_float_spect &)