Go to the documentation of this file.
31 if(src_type==dest_type)
34 if(src_type.
id() == ID_c_bit_field)
47 if(src_type.
id()==ID_floatbv &&
48 dest_type.
id()==ID_floatbv)
56 else if(src_type.
id()==ID_signedbv &&
57 dest_type.
id()==ID_floatbv)
62 else if(src_type.
id()==ID_unsignedbv &&
63 dest_type.
id()==ID_floatbv)
68 else if(src_type.
id()==ID_floatbv &&
69 dest_type.
id()==ID_signedbv)
75 else if(src_type.
id()==ID_floatbv &&
76 dest_type.
id()==ID_unsignedbv)
98 "both operands of a floating point operator must match the expression type",
105 if(expr.
type().
id() == ID_floatbv)
109 if(expr.
id()==ID_floatbv_plus)
110 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
false);
111 else if(expr.
id()==ID_floatbv_minus)
112 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
true);
113 else if(expr.
id()==ID_floatbv_mult)
114 return float_utils.
mul(lhs_as_bv, rhs_as_bv);
115 else if(expr.
id()==ID_floatbv_div)
116 return float_utils.
div(lhs_as_bv, rhs_as_bv);
120 else if(expr.
type().
id() == ID_vector || expr.
type().
id() == ID_complex)
124 if(subtype.
id()==ID_floatbv)
132 sub_width > 0 && width % sub_width == 0,
133 "width of a vector subtype must be positive and evenly divide the "
134 "width of the vector");
136 std::size_t size=width/sub_width;
138 result_bv.resize(width);
140 for(std::size_t i=0; i<size; i++)
142 bvt lhs_sub_bv, rhs_sub_bv, sub_result_bv;
145 lhs_as_bv.begin() + i * sub_width,
146 lhs_as_bv.begin() + (i + 1) * sub_width);
148 rhs_as_bv.begin() + i * sub_width,
149 rhs_as_bv.begin() + (i + 1) * sub_width);
151 if(expr.
id()==ID_floatbv_plus)
152 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
false);
153 else if(expr.
id()==ID_floatbv_minus)
154 sub_result_bv = float_utils.
add_sub(lhs_sub_bv, rhs_sub_bv,
true);
155 else if(expr.
id()==ID_floatbv_mult)
156 sub_result_bv = float_utils.
mul(lhs_sub_bv, rhs_sub_bv);
157 else if(expr.
id()==ID_floatbv_div)
158 sub_result_bv = float_utils.
div(lhs_sub_bv, rhs_sub_bv);
163 sub_result_bv.size() == sub_width,
164 "we constructed a new vector of the right size");
166 i * sub_width + sub_width - 1 < result_bv.size(),
167 "the sub-bitvector fits into the result bitvector");
169 sub_result_bv.begin(),
171 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.
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.
const type_with_subtypet & to_type_with_subtype(const typet &type)
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 const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
virtual bvt div(const bvt &src1, const bvt &src2)
virtual bvt convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
const irep_idt & id() const
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
std::size_t get_width() const
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
virtual bvt convert_floatbv_op(const ieee_float_op_exprt &)
const typet & subtype() const
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.
Semantic type conversion.
bvt from_unsigned_integer(const bvt &)
virtual bvt mul(const bvt &src1, const bvt &src2)