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";
92 op0.
type() == type && op1.
type() == type,
93 "float op with mixed types:\n" + expr.
pretty());
97 float_utils.set_rounding_mode(bv2);
99 if(type.
id()==ID_floatbv)
103 if(expr.
id()==ID_floatbv_plus)
104 return float_utils.add_sub(bv0, bv1,
false);
105 else if(expr.
id()==ID_floatbv_minus)
106 return float_utils.add_sub(bv0, bv1,
true);
107 else if(expr.
id()==ID_floatbv_mult)
108 return float_utils.mul(bv0, bv1);
109 else if(expr.
id()==ID_floatbv_div)
110 return float_utils.div(bv0, bv1);
111 else if(expr.
id()==ID_floatbv_rem)
112 return float_utils.rem(bv0, bv1);
114 throw "unexpected operator "+expr.
id_string();
116 else if(type.
id()==ID_vector || type.
id()==ID_complex)
120 if(subtype.
id()==ID_floatbv)
127 if(sub_width==0 || width%sub_width!=0)
128 throw "convert_floatbv_op: unexpected vector operand width";
130 std::size_t size=width/sub_width;
134 for(std::size_t i=0; i<size; i++)
136 bvt tmp_bv0, tmp_bv1, tmp_bv;
138 tmp_bv0.assign(bv0.begin()+i*sub_width, bv0.begin()+(i+1)*sub_width);
139 tmp_bv1.assign(bv1.begin()+i*sub_width, bv1.begin()+(i+1)*sub_width);
141 if(expr.
id()==ID_floatbv_plus)
142 tmp_bv=float_utils.add_sub(tmp_bv0, tmp_bv1,
false);
143 else if(expr.
id()==ID_floatbv_minus)
144 tmp_bv=float_utils.add_sub(tmp_bv0, tmp_bv1,
true);
145 else if(expr.
id()==ID_floatbv_mult)
146 tmp_bv=float_utils.mul(tmp_bv0, tmp_bv1);
147 else if(expr.
id()==ID_floatbv_div)
148 tmp_bv=float_utils.div(tmp_bv0, tmp_bv1);
152 assert(tmp_bv.size()==sub_width);
153 assert(i*sub_width+sub_width-1<bv.size());
154 std::copy(tmp_bv.begin(), tmp_bv.end(), bv.begin()+i*sub_width);
The type of an expression.
virtual bvt convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a generic typet to a signedbv_typet.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
boolbv_widtht boolbv_width
bvt to_signed_integer(const bvt &src, std::size_t int_width)
const irep_idt & id() const
virtual const bvt & convert_bv(const exprt &expr)
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
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 generic typet to an unsignedbv_typet.
bvt from_unsigned_integer(const bvt &)
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a generic typet to a floatbv_typet.
semantic type conversion from/to floating-point formats
Base class for all expressions.
const std::string & id_string() const
bvt from_signed_integer(const bvt &)
const typet & subtype() const
#define DATA_INVARIANT(CONDITION, REASON)
std::vector< literalt > bvt