30 if(src_type==dest_type)
33 if(src_type.
id() == ID_c_bit_field)
46 if(src_type.
id()==ID_floatbv &&
47 dest_type.
id()==ID_floatbv)
55 else if(src_type.
id()==ID_signedbv &&
56 dest_type.
id()==ID_floatbv)
61 else if(src_type.
id()==ID_unsignedbv &&
62 dest_type.
id()==ID_floatbv)
67 else if(src_type.
id()==ID_floatbv &&
68 dest_type.
id()==ID_signedbv)
74 else if(src_type.
id()==ID_floatbv &&
75 dest_type.
id()==ID_unsignedbv)
97 "both operands of a floating point operator must match the expression type",
104 if(expr.
type().
id() == ID_floatbv)
108 if(expr.
id()==ID_floatbv_plus)
109 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
false);
110 else if(expr.
id()==ID_floatbv_minus)
111 return float_utils.
add_sub(lhs_as_bv, rhs_as_bv,
true);
112 else if(expr.
id()==ID_floatbv_mult)
113 return float_utils.
mul(lhs_as_bv, rhs_as_bv);
114 else if(expr.
id()==ID_floatbv_div)
115 return float_utils.
div(lhs_as_bv, rhs_as_bv);
119 else if(expr.
type().
id() == ID_complex)
123 if(subtype.
id()==ID_floatbv)
131 sub_width > 0 && width % sub_width == 0,
132 "width of a complex subtype must be positive and evenly divide the "
133 "width of the complex expression");
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 complex 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);
Pre-defined bitvector types.
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.
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
std::size_t get_width() const
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
virtual bvt convert_floatbv_op(const ieee_float_op_exprt &)
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
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.
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
const typet & subtype() const
Semantic type conversion.
The type of an expression, extends irept.
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 type_with_subtypet & to_type_with_subtype(const typet &type)