30 if(src_type==dest_type)
33 if(src_type.
id() == ID_c_bit_field)
44 if(src_type.
id()==ID_floatbv &&
45 dest_type.
id()==ID_floatbv)
53 else if(src_type.
id()==ID_signedbv &&
54 dest_type.
id()==ID_floatbv)
59 else if(src_type.
id()==ID_unsignedbv &&
60 dest_type.
id()==ID_floatbv)
65 else if(src_type.
id()==ID_floatbv &&
66 dest_type.
id()==ID_signedbv)
72 else if(src_type.
id()==ID_floatbv &&
73 dest_type.
id()==ID_unsignedbv)
95 "both operands of a floating point operator must match the expression type",
102 if(expr.
type().
id() == ID_floatbv)
106 if(expr.
id()==ID_floatbv_plus)
107 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
false);
108 else if(expr.
id()==ID_floatbv_minus)
109 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
true);
110 else if(expr.
id()==ID_floatbv_mult)
111 return float_utils.
mul(lhs_as_bv, rhs_as_bv);
112 else if(expr.
id()==ID_floatbv_div)
113 return float_utils.
div(lhs_as_bv, rhs_as_bv);
114 else if(expr.
id()==ID_floatbv_rem)
115 return float_utils.
rem(lhs_as_bv, rhs_as_bv);
119 else if(expr.
type().
id() == ID_vector || expr.
type().
id() == ID_complex)
123 if(subtype.
id()==ID_floatbv)
131 sub_width > 0 && width % sub_width == 0,
132 "width of a vector subtype must be positive and evenly divide the "
133 "width of the vector");
135 std::size_t size=width/sub_width;
137 result_bv.resize(width);
139 for(std::size_t i=0; i<size; i++)
141 bvt lhs_sub_bv, rhs_sub_bv, sub_result_bv;
144 lhs_as_bv.begin() + i * sub_width,
145 lhs_as_bv.begin() + (i + 1) * sub_width);
147 rhs_as_bv.begin() + i * sub_width,
148 rhs_as_bv.begin() + (i + 1) * sub_width);
150 if(expr.
id()==ID_floatbv_plus)
151 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
false);
152 else if(expr.
id()==ID_floatbv_minus)
153 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
true);
154 else if(expr.
id()==ID_floatbv_mult)
155 sub_result_bv = float_utils.
mul(lhs_sub_bv, rhs_sub_bv);
156 else if(expr.
id()==ID_floatbv_div)
157 sub_result_bv = float_utils.
div(lhs_sub_bv, rhs_sub_bv);
162 sub_result_bv.size() == sub_width,
163 "we constructed a new vector of the right size");
165 i * sub_width + sub_width - 1 < result_bv.size(),
166 "the sub-bitvector fits into the result bitvector");
168 sub_result_bv.begin(),
170 result_bv.begin() + i * sub_width);
std::size_t get_width() const
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width=nullopt)
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
void conversion_failed(const exprt &expr, bvt &bv)
virtual bvt convert_floatbv_op(const ieee_float_op_exprt &)
virtual std::size_t boolbv_width(const typet &type) const
virtual bvt convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
Base class for all expressions.
typet & type()
Return the type of the expression.
virtual bvt rem(const bvt &src1, const bvt &src2)
void set_rounding_mode(const bvt &)
bvt from_unsigned_integer(const bvt &)
virtual bvt mul(const bvt &src1, const bvt &src2)
bvt to_unsigned_integer(const bvt &src, std::size_t int_width)
virtual bvt div(const bvt &src1, const bvt &src2)
bvt from_signed_integer(const bvt &)
bvt conversion(const bvt &src, const ieee_float_spect &dest_spec)
virtual bvt add_sub(const bvt &src1, const bvt &src2, bool subtract)
bvt to_signed_integer(const bvt &src, std::size_t int_width)
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)...
const irep_idt & id() const
Semantic type conversion.
The type of an expression, extends irept.
const typet & subtype() const
API to expression classes for floating-point arithmetic.
std::vector< literalt > bvt
#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 DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.