29 if(src_type==dest_type)
36 if(src_type.
id()==ID_floatbv &&
37 dest_type.
id()==ID_floatbv)
45 else if(src_type.
id()==ID_signedbv &&
46 dest_type.
id()==ID_floatbv)
51 else if(src_type.
id()==ID_unsignedbv &&
52 dest_type.
id()==ID_floatbv)
57 else if(src_type.
id()==ID_floatbv &&
58 dest_type.
id()==ID_signedbv)
64 else if(src_type.
id()==ID_floatbv &&
65 dest_type.
id()==ID_unsignedbv)
79 if(operands.size()!=3)
80 throw "operator "+expr.
id_string()+
" takes three operands";
84 const exprt &rounding_mode = expr.
op2();
92 lhs.
type() == resolved_type && rhs.
type() == resolved_type,
93 "both operands of a floating point operator must have the same type",
98 float_utils.set_rounding_mode(rounding_mode_as_bv);
100 if(resolved_type.
id() == ID_floatbv)
104 if(expr.
id()==ID_floatbv_plus)
105 return float_utils.add_sub(lhs_as_bv, rhs_as_bv,
false);
106 else if(expr.
id()==ID_floatbv_minus)
107 return float_utils.add_sub(lhs_as_bv, rhs_as_bv,
true);
108 else if(expr.
id()==ID_floatbv_mult)
109 return float_utils.mul(lhs_as_bv, rhs_as_bv);
110 else if(expr.
id()==ID_floatbv_div)
111 return float_utils.div(lhs_as_bv, rhs_as_bv);
112 else if(expr.
id()==ID_floatbv_rem)
113 return float_utils.rem(lhs_as_bv, rhs_as_bv);
117 else if(resolved_type.
id() == ID_vector || resolved_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);
The type of an expression, extends irept.
virtual bvt convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
boolbv_widtht boolbv_width
bvt to_signed_integer(const bvt &src, std::size_t int_width)
typet & type()
Return the type of the expression.
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width=nullopt)
const irep_idt & id() const
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
bvt to_unsigned_integer(const bvt &src, std::size_t int_width)
bvt conversion(const bvt &src, const ieee_float_spect &dest_spec)
virtual bvt convert_floatbv_op(const exprt &expr)
void conversion_failed(const exprt &expr, bvt &bv)
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
std::size_t get_width() const
std::vector< exprt > operandst
void set_rounding_mode(const bvt &)
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
bvt from_unsigned_integer(const bvt &)
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
Semantic type conversion from/to floating-point formats.
Base class for all expressions.
#define UNREACHABLE
This should be used to mark dead code.
const std::string & id_string() const
bvt from_signed_integer(const bvt &)
const typet & subtype() const
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions, goto_programs, exprts, etc.
std::vector< literalt > bvt