Go to the documentation of this file.
29 if(src_type==dest_type)
32 if(src_type.
id() == ID_c_bit_field)
43 if(src_type.
id()==ID_floatbv &&
44 dest_type.
id()==ID_floatbv)
52 else if(src_type.
id()==ID_signedbv &&
53 dest_type.
id()==ID_floatbv)
58 else if(src_type.
id()==ID_unsignedbv &&
59 dest_type.
id()==ID_floatbv)
64 else if(src_type.
id()==ID_floatbv &&
65 dest_type.
id()==ID_signedbv)
71 else if(src_type.
id()==ID_floatbv &&
72 dest_type.
id()==ID_unsignedbv)
94 "both operands of a floating point operator must match the expression type",
101 if(expr.
type().
id() == ID_floatbv)
105 if(expr.
id()==ID_floatbv_plus)
106 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
false);
107 else if(expr.
id()==ID_floatbv_minus)
108 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
true);
109 else if(expr.
id()==ID_floatbv_mult)
110 return float_utils.
mul(lhs_as_bv, rhs_as_bv);
111 else if(expr.
id()==ID_floatbv_div)
112 return float_utils.
div(lhs_as_bv, rhs_as_bv);
113 else if(expr.
id()==ID_floatbv_rem)
114 return float_utils.
rem(lhs_as_bv, rhs_as_bv);
118 else if(expr.
type().
id() == ID_vector || expr.
type().
id() == ID_complex)
122 if(subtype.
id()==ID_floatbv)
130 sub_width > 0 && width % sub_width == 0,
131 "width of a vector subtype must be positive and evenly divide the "
132 "width of the vector");
134 std::size_t size=width/sub_width;
136 result_bv.resize(width);
138 for(std::size_t i=0; i<size; i++)
140 bvt lhs_sub_bv, rhs_sub_bv, sub_result_bv;
143 lhs_as_bv.begin() + i * sub_width,
144 lhs_as_bv.begin() + (i + 1) * sub_width);
146 rhs_as_bv.begin() + i * sub_width,
147 rhs_as_bv.begin() + (i + 1) * sub_width);
149 if(expr.
id()==ID_floatbv_plus)
150 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
false);
151 else if(expr.
id()==ID_floatbv_minus)
152 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
true);
153 else if(expr.
id()==ID_floatbv_mult)
154 sub_result_bv = float_utils.
mul(lhs_sub_bv, rhs_sub_bv);
155 else if(expr.
id()==ID_floatbv_div)
156 sub_result_bv = float_utils.
div(lhs_sub_bv, rhs_sub_bv);
161 sub_result_bv.size() == sub_width,
162 "we constructed a new vector of the right size");
164 i * sub_width + sub_width - 1 < result_bv.size(),
165 "the sub-bitvector fits into the result bitvector");
167 sub_result_bv.begin(),
169 result_bv.begin() + i * sub_width);
#define UNREACHABLE
This should be used to mark dead code.
const typet & subtype() const
bvt to_signed_integer(const bvt &src, std::size_t int_width)
virtual bvt add_sub(const bvt &src1, const bvt &src2, bool subtract)
The type of an expression, extends irept.
std::vector< literalt > bvt
Base class for all expressions.
void set_rounding_mode(const bvt &)
bvt to_unsigned_integer(const bvt &src, std::size_t int_width)
bvt from_signed_integer(const bvt &)
typet & type()
Return the type of the expression.
bvt conversion(const bvt &src, const ieee_float_spect &dest_spec)
virtual bvt rem(const bvt &src1, const bvt &src2)
boolbv_widtht boolbv_width
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
void conversion_failed(const exprt &expr, bvt &bv)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Semantic type conversion from/to floating-point formats.
virtual bvt div(const bvt &src1, const bvt &src2)
virtual bvt convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
const irep_idt & id() 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...
std::size_t get_width() const
virtual bvt convert_floatbv_op(const ieee_float_op_exprt &)
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
IEEE floating-point operations These have two data operands (op0 and op1) and one rounding mode (op2)...
Semantic type conversion.
bvt from_unsigned_integer(const bvt &)
virtual bvt mul(const bvt &src1, const bvt &src2)