19 expr.
id() == ID_plus || expr.
id() == ID_minus ||
20 expr.
id() ==
"no-overflow-plus" || expr.
id() ==
"no-overflow-minus");
24 if(type.id()!=ID_unsignedbv &&
25 type.id()!=ID_signedbv &&
26 type.id()!=ID_fixedbv &&
27 type.id()!=ID_floatbv &&
28 type.id()!=ID_range &&
29 type.id()!=ID_complex &&
42 "operator " + expr.
id_string() +
" takes at least one operand");
46 op0.type() == type,
"add/sub with mixed types:\n" + expr.
pretty());
50 bool subtract=(expr.
id()==ID_minus ||
51 expr.
id()==
"no-overflow-minus");
53 bool no_overflow=(expr.
id()==
"no-overflow-plus" ||
54 expr.
id()==
"no-overflow-minus");
56 typet arithmetic_type=
57 (type.id()==ID_vector || type.id()==ID_complex)?
61 (arithmetic_type.
id()==ID_signedbv ||
65 for(exprt::operandst::const_iterator
66 it=operands.begin()+1;
67 it!=operands.end(); it++)
70 it->type() == type,
"add/sub with mixed types:\n" + expr.
pretty());
74 if(type.id()==ID_vector || type.id()==ID_complex)
78 INVARIANT(sub_width != 0,
"vector elements shall have nonzero bit width");
80 width % sub_width == 0,
81 "total vector bit width shall be a multiple of the element bit width");
83 std::size_t size=width/sub_width;
86 for(std::size_t i=0; i<size; i++)
89 tmp_op.resize(sub_width);
91 for(std::size_t j=0; j<tmp_op.size(); j++)
93 const std::size_t index = i * sub_width + j;
94 INVARIANT(index < op.size(),
"bit index shall be within bounds");
95 tmp_op[j] = op[index];
99 tmp_result.resize(sub_width);
101 for(std::size_t j=0; j<tmp_result.size(); j++)
103 const std::size_t index = i * sub_width + j;
104 INVARIANT(index < bv.size(),
"bit index shall be within bounds");
105 tmp_result[j] = bv[index];
108 if(type.subtype().id()==ID_floatbv)
112 tmp_result=float_utils.
add_sub(tmp_result, tmp_op, subtract);
118 tmp_result.size() == sub_width,
119 "applying the add/sub operation shall not change the bitwidth");
121 for(std::size_t j=0; j<tmp_result.size(); j++)
123 const std::size_t index = i * sub_width + j;
124 INVARIANT(index < bv.size(),
"bit index shall be within bounds");
125 bv[index] = tmp_result[j];
129 else if(type.id()==ID_floatbv)
133 bv=float_utils.
add_sub(bv, op, subtract);