ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
ir_ieee_conv.h
Go to the documentation of this file.
1#ifndef SOLVERS_SMT_FP_IR_IEEE_CONV_H_
2#define SOLVERS_SMT_FP_IR_IEEE_CONV_H_
3
5#include <irep2/irep2_expr.h>
6#include <irep2/irep2_type.h>
7#include <string>
8#include <unordered_map>
9#include <unordered_set>
10#include <utility>
11
13
28{
29public:
30 explicit ir_ieee_convt(smt_solver_baset *ctx);
31
38
42
46 const std::string &name,
47 smt_astt sym_ast,
48 const symbol2t &sym);
49
55 smt_astt sym_ast,
56 const floatbv_type2t &fbv_type);
57
62
66
68 smt_astt encode_ieee_add(const expr2tc &expr);
69
71 smt_astt encode_ieee_sub(const expr2tc &expr);
72
74 smt_astt encode_ieee_mul(const expr2tc &expr);
75
77 smt_astt encode_ieee_div(const expr2tc &expr);
78
80 smt_astt encode_ieee_fma(const expr2tc &expr);
81
85 smt_astt encode_ieee_rem(const expr2tc &expr);
86
90 void store_nan_pred(smt_astt t, smt_astt nan_pred);
91
94
99
106 smt_astt apply_nan_cmp(smt_astt cmp, smt_astt a, smt_astt b, bool is_neq);
107
112
119 void store_neg_zero_pred(smt_astt t, smt_astt neg_zero_pred);
120
124
136
145 smt_astt outer,
146 smt_astt inner,
147 smt_astt guard);
148
152 std::pair<smt_astt, smt_astt> apply_ieee754_rne_enclosure(
153 smt_astt real_result,
154 smt_astt lo_r,
155 smt_astt hi_r,
156 const floatbv_type2t &fbv_type);
157
159 std::pair<smt_astt, smt_astt> apply_ieee754_rna_enclosure(
160 smt_astt real_result,
161 smt_astt lo_r,
162 smt_astt hi_r,
163 const floatbv_type2t &fbv_type);
164
166 std::pair<smt_astt, smt_astt> apply_ieee754_rup_enclosure(
167 smt_astt real_result,
168 smt_astt lo_r,
169 smt_astt hi_r,
170 const floatbv_type2t &fbv_type);
171
173 std::pair<smt_astt, smt_astt> apply_ieee754_rdn_enclosure(
174 smt_astt real_result,
175 smt_astt lo_r,
176 smt_astt hi_r,
177 const floatbv_type2t &fbv_type);
178
180 std::pair<smt_astt, smt_astt> apply_ieee754_rtz_enclosure(
181 smt_astt real_result,
182 smt_astt lo_r,
183 smt_astt hi_r,
184 const floatbv_type2t &fbv_type);
185
186private:
187 smt_solver_baset *ctx;
188
192 std::unordered_map<const smt_ast *, ra_interval_t> ir_ra_interval_map;
193
197 std::unordered_map<const smt_ast *, smt_astt> ir_ieee_nan_map;
198
218 std::unordered_map<const smt_ast *, smt_astt> ir_ieee_neg_zero_map;
219
222 std::unordered_set<std::string> ir_ieee_ranged_syms;
223
226 void store_combined_nan_pred(smt_astt result, smt_astt s1, smt_astt s2);
227
229 smt_astt get_max_normal_real(const floatbv_type2t &fbv_type) const;
230
233 smt_astt is_pos_inf_real(smt_astt x, const floatbv_type2t &fbv_type) const;
234
237 smt_astt is_neg_inf_real(smt_astt x, const floatbv_type2t &fbv_type) const;
238
240 smt_astt is_inf_real(smt_astt x, const floatbv_type2t &fbv_type) const;
241
243 std::pair<smt_astt, smt_astt> apply_enclosure(
244 smt_astt real_result,
245 smt_astt lo_r,
246 smt_astt hi_r,
247 const floatbv_type2t &fbv_type,
248 const expr2tc &rounding_mode);
249
252 std::pair<smt_astt, smt_astt> widen_for_flush(smt_astt lo, smt_astt hi);
253};
254
255#endif /* SOLVERS_SMT_FP_IR_IEEE_CONV_H_ */
Floating-point bitvector type.
Definition irep2_type.h:621
smt_astt encode_ieee_mul(const expr2tc &expr)
Integer-encoding path for ieee_mul.
Definition ir_ieee_conv.cpp:581
std::pair< smt_astt, smt_astt > apply_ieee754_rne_enclosure(smt_astt real_result, smt_astt lo_r, smt_astt hi_r, const floatbv_type2t &fbv_type)
Interval-lifted RNE enclosure helper.
Definition ir_ieee_conv.cpp:175
void propagate_nan_pred(smt_astt lhs, smt_astt rhs)
Propagate a NaN predicate from rhs to lhs after an SSA assignment.
Definition ir_ieee_conv.cpp:81
void propagate_neg_zero_through_ite(smt_astt outer, smt_astt inner, smt_astt guard)
Re-attach inner's negative-zero predicate (if any) to outer, guarded by guard (the condition under wh...
Definition ir_ieee_conv.cpp:106
smt_astt apply_nan_cmp(smt_astt cmp, smt_astt a, smt_astt b, bool is_neq)
Wrap a comparison result with IEEE NaN semantics.
Definition ir_ieee_conv.cpp:167
void propagate_interval(smt_astt lhs, smt_astt rhs)
Propagate interval metadata from rhs to lhs after an SSA assignment.
Definition ir_ieee_conv.cpp:11
smt_astt encode_ieee_rem(const expr2tc &expr)
Encode ieee_rem2t (IEEE 754 remainder, C's remainder()).
Definition ir_ieee_conv.cpp:867
void store_neg_zero_pred(smt_astt t, smt_astt neg_zero_pred)
Record a predicate that is true iff the SMT AST t represents IEEE 754 -0.0.
Definition ir_ieee_conv.cpp:88
smt_astt encode_ieee_sub(const expr2tc &expr)
Integer-encoding path for ieee_sub.
Definition ir_ieee_conv.cpp:541
void store_nan_pred(smt_astt t, smt_astt nan_pred)
Record that the SMT AST t may be NaN; nan_pred is a boolean SMT term that is true iff t holds a NaN v...
Definition ir_ieee_conv.cpp:70
ra_interval_t get_interval(smt_astt t) const
Look up the tracked interval for t; fall back to the point interval {t, t}.
Definition ir_ieee_conv.cpp:59
std::pair< smt_astt, smt_astt > apply_ieee754_rna_enclosure(smt_astt real_result, smt_astt lo_r, smt_astt hi_r, const floatbv_type2t &fbv_type)
Interval-lifted RNA enclosure helper (round-to-nearest-away).
Definition ir_ieee_conv.cpp:230
ir_ieee_convt(smt_solver_baset *ctx)
Definition ir_ieee_conv.cpp:7
std::pair< smt_astt, smt_astt > apply_ieee754_rtz_enclosure(smt_astt real_result, smt_astt lo_r, smt_astt hi_r, const floatbv_type2t &fbv_type)
Interval-lifted RTZ enclosure helper (round-to-zero / truncation).
Definition ir_ieee_conv.cpp:385
std::pair< smt_astt, smt_astt > apply_ieee754_rup_enclosure(smt_astt real_result, smt_astt lo_r, smt_astt hi_r, const floatbv_type2t &fbv_type)
Interval-lifted RUP enclosure helper (round-to-plus-infinity).
Definition ir_ieee_conv.cpp:285
smt_astt encode_ieee_div(const expr2tc &expr)
Integer-encoding path for ieee_div.
Definition ir_ieee_conv.cpp:654
smt_astt combine_nan_preds(smt_astt a, smt_astt b) const
Combine two NaN predicates with OR.
Definition ir_ieee_conv.cpp:116
void propagate_neg_zero_pred(smt_astt lhs, smt_astt rhs)
Propagate a negative-zero predicate from rhs to lhs after an SSA assignment.
Definition ir_ieee_conv.cpp:99
smt_astt encode_ieee_fma(const expr2tc &expr)
Integer-encoding path for ieee_fma (fused multiply-add).
Definition ir_ieee_conv.cpp:770
void store_interval(smt_astt t, smt_astt lo, smt_astt hi)
Store an interval for t in the map.
Definition ir_ieee_conv.cpp:65
smt_astt get_nan_pred(smt_astt t) const
Return the stored NaN predicate for t, or nullptr if none is known.
Definition ir_ieee_conv.cpp:75
smt_astt get_neg_zero_pred(smt_astt t) const
Return the stored negative-zero predicate for t, or nullptr if no negative-zero metadata is recorded ...
Definition ir_ieee_conv.cpp:93
std::pair< smt_astt, smt_astt > apply_ieee754_rdn_enclosure(smt_astt real_result, smt_astt lo_r, smt_astt hi_r, const floatbv_type2t &fbv_type)
Interval-lifted RDN enclosure helper (round-to-minus-infinity).
Definition ir_ieee_conv.cpp:335
void assert_symbol_range(const std::string &name, smt_astt sym_ast, const symbol2t &sym)
Assert C integer type range for narrow symbols (width < 32 bits).
Definition ir_ieee_conv.cpp:18
void assert_representable_magnitude(smt_astt sym_ast, const floatbv_type2t &fbv_type)
Assert that a float symbol's real value is representable: every finite value has magnitude at most ma...
Definition ir_ieee_conv.cpp:45
smt_astt encode_ieee_add(const expr2tc &expr)
Integer-encoding path for ieee_add.
Definition ir_ieee_conv.cpp:501
The base SMT-conversion class/interface.
Definition smt_solver.h:170
Symbol type.
Definition irep2_expr.h:625
irep_container< expr2t > expr2tc
Definition irep2.h:431
const smt_ast * smt_astt
Definition smt_ast.h:30
Interval [lo, hi] in the real-arithmetic SMT encoding.
Definition ir_ieee_conv.h:34
smt_astt hi
Definition ir_ieee_conv.h:36
smt_astt lo
Definition ir_ieee_conv.h:35