ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
fp_conv.h
Go to the documentation of this file.
1#ifndef SOLVERS_SMT_FP_CONV_H_
2#define SOLVERS_SMT_FP_CONV_H_
3
6
8{
9public:
10 explicit fp_convt(smt_solver_baset *_ctx);
11 virtual ~fp_convt() = default;
12
18 virtual smt_astt mk_smt_fpbv(const ieee_floatt &thereal);
19
25 virtual smt_sortt mk_fpbv_sort(const unsigned ew, const unsigned sw);
26
30 virtual smt_sortt mk_fpbv_rm_sort();
31
36 virtual smt_astt mk_smt_fpbv_nan(bool sgn, unsigned ew, unsigned sw);
37
43 virtual smt_astt mk_smt_fpbv_inf(bool sgn, unsigned ew, unsigned sw);
44
49
54 virtual smt_astt
55 mk_smt_typecast_from_fpbv_to_ubv(smt_astt from, std::size_t width);
56
61 virtual smt_astt
62 mk_smt_typecast_from_fpbv_to_sbv(smt_astt from, std::size_t width);
63
69 virtual smt_astt
71
77 virtual smt_astt
79
85 virtual smt_astt
87
94
100 virtual smt_astt mk_smt_fpbv_add(smt_astt lhs, smt_astt rhs, smt_astt rm);
101
107 virtual smt_astt mk_smt_fpbv_sub(smt_astt lhs, smt_astt rhs, smt_astt rm);
108
114 virtual smt_astt mk_smt_fpbv_mul(smt_astt lhs, smt_astt rhs, smt_astt rm);
115
121 virtual smt_astt mk_smt_fpbv_div(smt_astt lhs, smt_astt rhs, smt_astt rm);
122
128 virtual smt_astt mk_smt_fpbv_rem(smt_astt lhs, smt_astt rhs);
129
135
143 virtual smt_astt
145
150 virtual smt_astt mk_smt_fpbv_eq(smt_astt lhs, smt_astt rhs);
151
156 virtual smt_astt mk_smt_fpbv_gt(smt_astt lhs, smt_astt rhs);
157
162 virtual smt_astt mk_smt_fpbv_lt(smt_astt lhs, smt_astt rhs);
163
168 virtual smt_astt mk_smt_fpbv_gte(smt_astt lhs, smt_astt rhs);
169
174 virtual smt_astt mk_smt_fpbv_lte(smt_astt lhs, smt_astt rhs);
175
180
185
190
195
200
205
210
215
219 virtual ieee_floatt get_fpbv(smt_astt a);
220
226
231
232private:
233 smt_solver_baset *ctx;
234
235 void unpack(
236 smt_astt &src,
237 smt_astt &sgn,
238 smt_astt &sig,
239 smt_astt &exp,
240 smt_astt &lz,
241 bool normalize);
242
243 smt_astt mk_unbias(smt_astt &src);
244 smt_astt mk_leading_zeros(smt_astt &src, std::size_t max_bits);
245
246 void round(
247 smt_astt &rm,
248 smt_astt &sgn,
249 smt_astt &sig,
250 smt_astt &exp,
251 unsigned ebits,
252 unsigned sbits,
253 smt_astt &result);
254
255 smt_astt mk_rounding_decision(
256 smt_astt &rm,
257 smt_astt &sgn,
258 smt_astt &last,
259 smt_astt &round,
260 smt_astt &sticky);
261
263
264 smt_astt mk_top_exp(std::size_t sz);
265 smt_astt mk_bot_exp(std::size_t sz);
266 smt_astt mk_min_exp(std::size_t ebits);
267 smt_astt mk_max_exp(std::size_t ebits);
268 smt_astt mk_bias(smt_astt e);
269
270 smt_astt mk_pzero(unsigned ew, unsigned sw);
271 smt_astt mk_nzero(unsigned ew, unsigned sw);
272 smt_astt mk_pinf(unsigned ew, unsigned sw);
273 smt_astt mk_ninf(unsigned ew, unsigned sw);
274 smt_astt mk_one(smt_astt sgn, unsigned ew, unsigned sw);
275
276 smt_astt mk_is_pos(smt_astt op);
277 smt_astt mk_is_neg(smt_astt op);
278 smt_astt mk_is_pzero(smt_astt op);
279 smt_astt mk_is_nzero(smt_astt op);
280 smt_astt mk_is_pinf(smt_astt op);
281 smt_astt mk_is_ninf(smt_astt op);
282 smt_astt mk_is_denormal(smt_astt op);
283
284 smt_astt mk_to_bv(smt_astt from, bool is_signed, std::size_t width);
285};
286
287#endif /* SOLVERS_SMT_FP_CONV_H_ */
virtual smt_astt mk_smt_fpbv_is_inf(smt_astt op)
Convert an ieee is_inf operation.
Definition fp_conv.cpp:1799
virtual smt_astt mk_smt_fpbv_is_normal(smt_astt op)
Convert an ieee is_normal operation.
Definition fp_conv.cpp:1826
virtual smt_astt mk_smt_fpbv_sqrt(smt_astt rd, smt_astt rm)
Convert the ieee arithmetic square-root (sqrt).
Definition fp_conv.cpp:250
virtual smt_astt mk_smt_fpbv_gt(smt_astt lhs, smt_astt rhs)
Convert an ieee greater than.
Definition fp_conv.cpp:1722
virtual smt_astt mk_smt_typecast_from_fpbv_to_fpbv(smt_astt from, smt_sortt to, smt_astt rm)
Typecast from a floating point.
Definition fp_conv.cpp:785
virtual smt_astt mk_smt_fpbv_is_nan(smt_astt op)
Convert an ieee is_nan operation.
Definition fp_conv.cpp:1783
virtual smt_astt mk_smt_fpbv_is_zero(smt_astt op)
Convert an ieee is_zero operation.
Definition fp_conv.cpp:1844
virtual smt_astt mk_smt_nearbyint_from_float(smt_astt from, smt_astt rm)
Calculate the nearby int from a floating point, considering the rounding mode.
Definition fp_conv.cpp:73
virtual smt_astt mk_smt_fpbv_gte(smt_astt lhs, smt_astt rhs)
Convert an ieee greater than or equal.
Definition fp_conv.cpp:1770
virtual smt_astt mk_smt_fpbv_nan(bool sgn, unsigned ew, unsigned sw)
Create a NaN floating point bitvector.
Definition fp_conv.cpp:46
fp_convt(smt_solver_baset *_ctx)
Definition fp_conv.cpp:26
virtual smt_astt mk_smt_typecast_from_fpbv_to_sbv(smt_astt from, std::size_t width)
Typecast from a floating point.
Definition fp_conv.cpp:780
virtual smt_astt mk_from_bv_to_fp(smt_astt op, smt_sortt to)
Convert BV to FP.
Definition fp_conv.cpp:2367
virtual smt_astt mk_smt_fpbv_fma(smt_astt v1, smt_astt v2, smt_astt v3, smt_astt rm)
Convert the ieee arithmetic fused-multiply add (fma): round((v1 * v2) + v3).
Definition fp_conv.cpp:355
virtual smt_astt mk_from_fp_to_bv(smt_astt op)
Convert FP to BV.
Definition fp_conv.cpp:2372
virtual smt_astt mk_smt_fpbv_neg(smt_astt op)
Convert an ieee negation operation.
Definition fp_conv.cpp:1883
virtual ~fp_convt()=default
virtual smt_astt mk_smt_typecast_from_fpbv_to_ubv(smt_astt from, std::size_t width)
Typecast from a floating point.
Definition fp_conv.cpp:774
virtual smt_astt mk_smt_fpbv(const ieee_floatt &thereal)
Create a floating point bitvector.
Definition fp_conv.cpp:30
virtual smt_astt mk_smt_typecast_sbv_to_fpbv(smt_astt from, smt_sortt to, smt_astt rm)
Typecast to a floating point.
Definition fp_conv.cpp:1032
virtual smt_astt mk_smt_fpbv_lt(smt_astt lhs, smt_astt rhs)
Convert an ieee less than.
Definition fp_conv.cpp:1728
virtual smt_astt mk_smt_fpbv_rem(smt_astt lhs, smt_astt rhs)
Convert the ieee remainder (SMT-LIB fp.rem, C's remainder()).
Definition fp_conv.cpp:1558
virtual smt_astt mk_smt_fpbv_is_negative(smt_astt op)
Convert an ieee is_neg operation.
Definition fp_conv.cpp:1857
virtual smt_astt mk_smt_fpbv_add(smt_astt lhs, smt_astt rhs, smt_astt rm)
Convert a ieee addition.
Definition fp_conv.cpp:1235
virtual smt_astt mk_smt_fpbv_eq(smt_astt lhs, smt_astt rhs)
Convert an ieee equality.
Definition fp_conv.cpp:1702
virtual smt_sortt mk_fpbv_rm_sort()
Create a sort representing a floating-point rounding mode.
Definition fp_conv.cpp:41
virtual smt_astt mk_smt_fpbv_inf(bool sgn, unsigned ew, unsigned sw)
Create a (+/-)inf floating point bitvector.
Definition fp_conv.cpp:58
virtual smt_astt mk_smt_typecast_ubv_to_fpbv(smt_astt from, smt_sortt to, smt_astt rm)
Typecast to a floating point.
Definition fp_conv.cpp:926
virtual smt_sortt mk_fpbv_sort(const unsigned ew, const unsigned sw)
Create a sort representing a floating-point number.
Definition fp_conv.cpp:36
virtual smt_astt mk_smt_fpbv_lte(smt_astt lhs, smt_astt rhs)
Convert an ieee less than or equal.
Definition fp_conv.cpp:1776
virtual smt_astt mk_smt_fpbv_sub(smt_astt lhs, smt_astt rhs, smt_astt rm)
Convert a ieee subtraction.
Definition fp_conv.cpp:1334
virtual smt_astt mk_smt_fpbv_abs(smt_astt op)
Convert an ieee abs operation.
Definition fp_conv.cpp:1873
virtual smt_astt mk_smt_fpbv_is_positive(smt_astt op)
Convert an ieee is_pos operation.
Definition fp_conv.cpp:1865
virtual smt_astt mk_smt_fpbv_mul(smt_astt lhs, smt_astt rhs, smt_astt rm)
Convert a ieee multiplication.
Definition fp_conv.cpp:1340
virtual ieee_floatt get_fpbv(smt_astt a)
Extract the assignment to a floating-point from the SMT solvers model.
Definition fp_conv.cpp:1142
virtual smt_astt mk_smt_fpbv_div(smt_astt lhs, smt_astt rhs, smt_astt rm)
Convert the ieee division.
Definition fp_conv.cpp:1442
virtual smt_astt mk_smt_fpbv_rm(ieee_floatt::rounding_modet rm)
Create a rounding mode to be used by floating point cast and arith ops.
Definition fp_conv.cpp:68
Definition ieee_float.h:75
rounding_modet
Definition ieee_float.h:78
The base SMT-conversion class/interface.
Definition smt_solver.h:170
double exp(double x)
Definition exp.c:84
const smt_ast * smt_astt
Definition smt_ast.h:30
const smt_sort * smt_sortt
Definition smt_sort.h:37