15
15
#include " bitvector_expr.h"
16
16
#include " byte_operators.h"
17
17
#include " expr_util.h"
18
+ #include " floatbv_expr.h"
18
19
#include " format_type.h"
19
20
#include " ieee_float.h"
20
21
#include " mathematical_expr.h"
@@ -158,6 +159,14 @@ static std::ostream &format_rec(std::ostream &os, const unary_exprt &src)
158
159
return os << format (src.op ());
159
160
}
160
161
162
+ // / This formats a ternary expression
163
+ static std::ostream &format_rec (std::ostream &os, const ternary_exprt &src)
164
+ {
165
+ os << src.id () << ' (' << format (src.op0 ()) << " , " << format (src.op1 ())
166
+ << " , " << format (src.op2 ()) << ' )' ;
167
+ return os;
168
+ }
169
+
161
170
// / This formats a constant
162
171
static std::ostream &format_rec (std::ostream &os, const constant_exprt &src)
163
172
{
@@ -278,19 +287,30 @@ void format_expr_configt::setup()
278
287
expr_map[ID_or] = multi_ary_expr;
279
288
expr_map[ID_xor] = multi_ary_expr;
280
289
281
- auto binary_expr = [](std::ostream &os, const exprt &expr) -> std::ostream & {
290
+ auto binary_infix_expr =
291
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
282
292
return format_rec (os, to_binary_expr (expr));
283
293
};
284
294
285
- expr_map[ID_lt] = binary_expr;
286
- expr_map[ID_gt] = binary_expr;
287
- expr_map[ID_ge] = binary_expr;
288
- expr_map[ID_le] = binary_expr;
289
- expr_map[ID_div] = binary_expr;
290
- expr_map[ID_minus] = binary_expr;
291
- expr_map[ID_implies] = binary_expr;
292
- expr_map[ID_equal] = binary_expr;
293
- expr_map[ID_notequal] = binary_expr;
295
+ expr_map[ID_lt] = binary_infix_expr;
296
+ expr_map[ID_gt] = binary_infix_expr;
297
+ expr_map[ID_ge] = binary_infix_expr;
298
+ expr_map[ID_le] = binary_infix_expr;
299
+ expr_map[ID_div] = binary_infix_expr;
300
+ expr_map[ID_minus] = binary_infix_expr;
301
+ expr_map[ID_implies] = binary_infix_expr;
302
+ expr_map[ID_equal] = binary_infix_expr;
303
+ expr_map[ID_notequal] = binary_infix_expr;
304
+
305
+ auto binary_prefix_expr =
306
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
307
+ os << expr.id () << ' (' << format (to_binary_expr (expr).op0 ()) << " , "
308
+ << format (to_binary_expr (expr).op1 ()) << ' )' ;
309
+ return os;
310
+ };
311
+
312
+ expr_map[ID_ieee_float_equal] = binary_prefix_expr;
313
+ expr_map[ID_ieee_float_notequal] = binary_prefix_expr;
294
314
295
315
auto unary_expr = [](std::ostream &os, const exprt &expr) -> std::ostream & {
296
316
return format_rec (os, to_unary_expr (expr));
@@ -299,6 +319,27 @@ void format_expr_configt::setup()
299
319
expr_map[ID_not] = unary_expr;
300
320
expr_map[ID_unary_minus] = unary_expr;
301
321
322
+ auto unary_with_parentheses_expr =
323
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
324
+ return os << expr.id () << ' (' << format (to_unary_expr (expr).op ()) << ' )' ;
325
+ };
326
+
327
+ expr_map[ID_isnan] = unary_with_parentheses_expr;
328
+ expr_map[ID_isinf] = unary_with_parentheses_expr;
329
+ expr_map[ID_isfinite] = unary_with_parentheses_expr;
330
+ expr_map[ID_isnormal] = unary_with_parentheses_expr;
331
+
332
+ auto ternary_expr =
333
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
334
+ return format_rec (os, to_ternary_expr (expr));
335
+ };
336
+
337
+ expr_map[ID_floatbv_plus] = ternary_expr;
338
+ expr_map[ID_floatbv_minus] = ternary_expr;
339
+ expr_map[ID_floatbv_mult] = ternary_expr;
340
+ expr_map[ID_floatbv_div] = ternary_expr;
341
+ expr_map[ID_floatbv_mod] = ternary_expr;
342
+
302
343
expr_map[ID_constant] =
303
344
[](std::ostream &os, const exprt &expr) -> std::ostream & {
304
345
return format_rec (os, to_constant_expr (expr));
@@ -322,6 +363,14 @@ void format_expr_configt::setup()
322
363
<< format (expr.type ()) << ' )' ;
323
364
};
324
365
366
+ expr_map[ID_floatbv_typecast] =
367
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
368
+ const auto &floatbv_typecast_expr = to_floatbv_typecast_expr (expr);
369
+ return os << " floatbv_typecast(" << format (floatbv_typecast_expr.op ())
370
+ << " , " << format (floatbv_typecast_expr.type ()) << " , "
371
+ << format (floatbv_typecast_expr.rounding_mode ()) << ' )' ;
372
+ };
373
+
325
374
auto byte_extract =
326
375
[](std::ostream &os, const exprt &expr) -> std::ostream & {
327
376
const auto &byte_extract_expr = to_byte_extract_expr (expr);
0 commit comments