Go to the documentation of this file.
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);
117 else if(expr.
type().
id() == ID_vector || expr.
type().
id() == ID_complex)
121 if(subtype.
id()==ID_floatbv)
129 sub_width > 0 && width % sub_width == 0,
130 "width of a vector subtype must be positive and evenly divide the "
131 "width of the vector");
133 std::size_t size=width/sub_width;
135 result_bv.resize(width);
137 for(std::size_t i=0; i<size; i++)
139 bvt lhs_sub_bv, rhs_sub_bv, sub_result_bv;
142 lhs_as_bv.begin() + i * sub_width,
143 lhs_as_bv.begin() + (i + 1) * sub_width);
145 rhs_as_bv.begin() + i * sub_width,
146 rhs_as_bv.begin() + (i + 1) * sub_width);
148 if(expr.
id()==ID_floatbv_plus)
149 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
false);
150 else if(expr.
id()==ID_floatbv_minus)
151 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
true);
152 else if(expr.
id()==ID_floatbv_mult)
153 sub_result_bv = float_utils.
mul(lhs_sub_bv, rhs_sub_bv);
154 else if(expr.
id()==ID_floatbv_div)
155 sub_result_bv = float_utils.
div(lhs_sub_bv, rhs_sub_bv);
160 sub_result_bv.size() == sub_width,
161 "we constructed a new vector of the right size");
163 i * sub_width + sub_width - 1 < result_bv.size(),
164 "the sub-bitvector fits into the result bitvector");
166 sub_result_bv.begin(),
168 result_bv.begin() + i * sub_width);
#define UNREACHABLE
This should be used to mark dead code.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
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
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
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)
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
virtual std::size_t boolbv_width(const typet &type) const
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)
Pre-defined bitvector types.
const irep_idt & id() const
API to expression classes for floating-point arithmetic.
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...
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
std::size_t get_width() const
virtual bvt convert_floatbv_op(const ieee_float_op_exprt &)
IEEE floating-point operations These have two data operands (op0 and op1) and one rounding mode (op2)...
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Semantic type conversion.
bvt from_unsigned_integer(const bvt &)
virtual bvt mul(const bvt &src1, const bvt &src2)