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 &&
39 "operator " + expr.
id_string() +
" takes at least one operand");
43 op0.
type() == type,
"add/sub with mixed types:\n" + expr.
pretty());
47 bool subtract=(expr.
id()==ID_minus ||
48 expr.
id()==
"no-overflow-minus");
50 bool no_overflow=(expr.
id()==
"no-overflow-plus" ||
51 expr.
id()==
"no-overflow-minus");
53 typet arithmetic_type = (type.
id() == ID_vector || type.
id() == ID_complex)
58 (arithmetic_type.
id()==ID_signedbv ||
62 for(exprt::operandst::const_iterator
63 it=operands.begin()+1;
64 it!=operands.end(); it++)
67 it->type() == type,
"add/sub with mixed types:\n" + expr.
pretty());
71 if(type.
id()==ID_vector || type.
id()==ID_complex)
73 std::size_t sub_width =
76 INVARIANT(sub_width != 0,
"vector elements shall have nonzero bit width");
78 width % sub_width == 0,
79 "total vector bit width shall be a multiple of the element bit width");
81 std::size_t size=width/sub_width;
84 for(std::size_t i=0; i<size; i++)
87 tmp_op.resize(sub_width);
89 for(std::size_t j=0; j<tmp_op.size(); j++)
91 const std::size_t index = i * sub_width + j;
92 INVARIANT(index < op.size(),
"bit index shall be within bounds");
93 tmp_op[j] = op[index];
97 tmp_result.resize(sub_width);
99 for(std::size_t j=0; j<tmp_result.size(); j++)
101 const std::size_t index = i * sub_width + j;
102 INVARIANT(index < bv.size(),
"bit index shall be within bounds");
103 tmp_result[j] = bv[index];
111 tmp_result=float_utils.
add_sub(tmp_result, tmp_op, subtract);
117 tmp_result.size() == sub_width,
118 "applying the add/sub operation shall not change the bitwidth");
120 for(std::size_t j=0; j<tmp_result.size(); j++)
122 const std::size_t index = i * sub_width + j;
123 INVARIANT(index < bv.size(),
"bit index shall be within bounds");
124 bv[index] = tmp_result[j];
128 else if(type.
id()==ID_floatbv)
132 bv=float_utils.
add_sub(bv, op, subtract);
146 expr.
id() == ID_saturating_minus || expr.
id() == ID_saturating_plus);
151 type.
id() != ID_unsignedbv && type.
id() != ID_signedbv &&
152 type.
id() != ID_fixedbv && type.
id() != ID_complex &&
153 type.
id() != ID_vector)
162 "saturating add/sub with mixed types:\n" + expr.
pretty());
164 const bool subtract = expr.
id() == ID_saturating_minus;
166 typet arithmetic_type = (type.
id() == ID_vector || type.
id() == ID_complex)
171 (arithmetic_type.
id() == ID_signedbv || arithmetic_type.
id() == ID_fixedbv)
178 if(type.
id() != ID_vector && type.
id() != ID_complex)
183 INVARIANT(sub_width != 0,
"vector elements shall have nonzero bit width");
185 width % sub_width == 0,
186 "total vector bit width shall be a multiple of the element bit width");
188 std::size_t size = width / sub_width;
190 for(std::size_t i = 0; i < size; i++)
193 tmp_op.resize(sub_width);
195 for(std::size_t j = 0; j < tmp_op.size(); j++)
197 const std::size_t index = i * sub_width + j;
198 INVARIANT(index < op.size(),
"bit index shall be within bounds");
199 tmp_op[j] = op[index];
203 tmp_result.resize(sub_width);
205 for(std::size_t j = 0; j < tmp_result.size(); j++)
207 const std::size_t index = i * sub_width + j;
208 INVARIANT(index < bv.size(),
"bit index shall be within bounds");
209 tmp_result[j] = bv[index];
215 tmp_result.size() == sub_width,
216 "applying the add/sub operation shall not change the bitwidth");
218 for(std::size_t j = 0; j < tmp_result.size(); j++)
220 const std::size_t index = i * sub_width + j;
221 INVARIANT(index < bv.size(),
"bit index shall be within bounds");
222 bv[index] = tmp_result[j];