20 if(type.
id()!=ID_unsignedbv &&
21 type.
id()!=ID_signedbv &&
22 type.
id()!=ID_fixedbv &&
23 type.
id()!=ID_floatbv &&
24 type.
id()!=ID_range &&
25 type.
id()!=ID_complex &&
37 throw "operator "+expr.
id_string()+
" takes at least one operand";
41 op0.
type() == type,
"add/sub with mixed types:\n" + expr.
pretty());
46 throw "convert_add_sub: unexpected operand 0 width";
48 bool subtract=(expr.
id()==ID_minus ||
49 expr.
id()==
"no-overflow-minus");
51 bool no_overflow=(expr.
id()==
"no-overflow-plus" ||
52 expr.
id()==
"no-overflow-minus");
54 typet arithmetic_type=
55 (type.
id()==ID_vector || type.
id()==ID_complex)?
59 (arithmetic_type.
id()==ID_signedbv ||
63 for(exprt::operandst::const_iterator
64 it=operands.begin()+1;
65 it!=operands.end(); it++)
68 it->type() == type,
"add/sub with mixed types:\n" + expr.
pretty());
73 throw "convert_add_sub: unexpected operand width";
75 if(type.
id()==ID_vector || type.
id()==ID_complex)
81 if(sub_width==0 || width%sub_width!=0)
82 throw "convert_add_sub: unexpected vector operand width";
84 std::size_t size=width/sub_width;
87 for(std::size_t i=0; i<size; i++)
90 tmp_op.resize(sub_width);
92 for(std::size_t j=0; j<tmp_op.size(); j++)
94 assert(i*sub_width+j<op.size());
95 tmp_op[j]=op[i*sub_width+j];
99 tmp_result.resize(sub_width);
101 for(std::size_t j=0; j<tmp_result.size(); j++)
103 assert(i*sub_width+j<bv.size());
104 tmp_result[j]=bv[i*sub_width+j];
111 tmp_result=float_utils.
add_sub(tmp_result, tmp_op, subtract);
116 assert(tmp_result.size()==sub_width);
118 for(std::size_t j=0; j<tmp_result.size(); j++)
120 assert(i*sub_width+j<bv.size());
121 bv[i*sub_width+j]=tmp_result[j];
125 else if(type.
id()==ID_floatbv)
129 bv=float_utils.
add_sub(bv, op, subtract);
The type of an expression.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
bvt add_sub_no_overflow(const bvt &op0, const bvt &op1, bool subtract, representationt rep)
boolbv_widtht boolbv_width
const irep_idt & id() const
virtual bvt convert_add_sub(const exprt &expr)
virtual const bvt & convert_bv(const exprt &expr)
void conversion_failed(const exprt &expr, bvt &bv)
const typet & follow(const typet &) const
virtual bvt add_sub(const bvt &src1, const bvt &src2, bool subtract)
std::vector< exprt > operandst
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a generic typet to a floatbv_typet.
Base class for all expressions.
const std::string & id_string() const
const typet & subtype() const
#define DATA_INVARIANT(CONDITION, REASON)
bvt add_sub(const bvt &op0, const bvt &op1, bool subtract)
std::vector< literalt > bvt