@@ -2687,10 +2687,10 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
2687
2687
2688
2688
if (use_FPA_theory)
2689
2689
{
2690
- // This conversion is non-trivial as it requires creating a
2691
- // new bit-vector variable and then asserting that it converts
2692
- // to the required floating-point number.
2693
- SMT2_TODO ( " bit-wise floatbv to bv " ) ;
2690
+ defined_expressionst::const_iterator it =
2691
+ defined_expressions. find (expr);
2692
+ CHECK_RETURN (it != defined_expressions. end ());
2693
+ out << it-> second ;
2694
2694
}
2695
2695
else
2696
2696
{
@@ -5440,6 +5440,35 @@ void smt2_convt::find_symbols(const exprt &expr)
5440
5440
out << " )\n " ; // define-fun
5441
5441
}
5442
5442
}
5443
+ else if (
5444
+ use_FPA_theory && expr.id () == ID_typecast &&
5445
+ to_typecast_expr (expr).op ().type ().id () == ID_floatbv &&
5446
+ expr.type ().id () == ID_bv)
5447
+ {
5448
+ // This is _NOT_ a semantic conversion, but bit-wise.
5449
+ if (defined_expressions.find (expr) == defined_expressions.end ())
5450
+ {
5451
+ // This conversion is non-trivial as it requires creating a
5452
+ // new bit-vector variable and then asserting that it converts
5453
+ // to the required floating-point number.
5454
+ const irep_idt id =
5455
+ " bvfromfloat." + std::to_string (defined_expressions.size ());
5456
+ out << " (declare-fun " << id << " () " ;
5457
+ convert_type (expr.type ());
5458
+ out << ' )' << ' \n ' ;
5459
+
5460
+ const typecast_exprt &tc = to_typecast_expr (expr);
5461
+ const auto &floatbv_type = to_floatbv_type (tc.op ().type ());
5462
+ out << " (assert (= " ;
5463
+ out << " ((_ to_fp " << floatbv_type.get_e () << " "
5464
+ << floatbv_type.get_f () + 1 << " ) " << id << ' )' ;
5465
+ convert_expr (tc.op ());
5466
+ out << ' )' ; // =
5467
+ out << ' )' << ' \n ' ;
5468
+
5469
+ defined_expressions[expr] = id;
5470
+ }
5471
+ }
5443
5472
else if (expr.id () == ID_initial_state)
5444
5473
{
5445
5474
irep_idt function = " initial-state" ;
0 commit comments