@@ -517,11 +517,14 @@ constant_exprt smt2_convt::parse_literal(
517
517
std::size_t width=boolbv_width (type);
518
518
return constant_exprt (integer2bvrep (value, width), type);
519
519
}
520
- else if (type.id ()==ID_integer ||
521
- type.id ()==ID_range)
520
+ else if (type.id () == ID_integer)
522
521
{
523
522
return from_integer (value, type);
524
523
}
524
+ else if (type.id () == ID_range)
525
+ {
526
+ return from_integer (value + to_range_type (type).get_from (), type);
527
+ }
525
528
else
526
529
UNREACHABLE_BECAUSE (
527
530
" smt2_convt::parse_literal should not be of unsupported type " +
@@ -3783,7 +3786,7 @@ void smt2_convt::convert_plus(const plus_exprt &expr)
3783
3786
}
3784
3787
else if (
3785
3788
expr.type ().id () == ID_unsignedbv || expr.type ().id () == ID_signedbv ||
3786
- expr.type ().id () == ID_fixedbv || expr. type (). id () == ID_range )
3789
+ expr.type ().id () == ID_fixedbv)
3787
3790
{
3788
3791
// These could be chained, i.e., need not be binary,
3789
3792
// but at least MathSat doesn't like that.
@@ -3800,6 +3803,31 @@ void smt2_convt::convert_plus(const plus_exprt &expr)
3800
3803
convert_plus (to_plus_expr (make_binary (expr)));
3801
3804
}
3802
3805
}
3806
+ else if (expr.type ().id () == ID_range)
3807
+ {
3808
+ auto &range_type = to_range_type (expr.type ());
3809
+
3810
+ // These could be chained, i.e., need not be binary,
3811
+ // but at least MathSat doesn't like that.
3812
+ if (expr.operands ().size () == 2 )
3813
+ {
3814
+ // add: lhs + from + rhs + from - from = lhs + rhs + from
3815
+ mp_integer from = range_type.get_from ();
3816
+ const auto size = range_type.get_to () - range_type.get_from () + 1 ;
3817
+ const auto width = address_bits (size);
3818
+
3819
+ out << " (bvadd " ;
3820
+ convert_expr (expr.op0 ());
3821
+ out << " (bvadd " ;
3822
+ convert_expr (expr.op1 ());
3823
+ out << " (_ bv" << range_type.get_from () << ' ' << width
3824
+ << " )))" ; // bv, bvadd, bvadd
3825
+ }
3826
+ else
3827
+ {
3828
+ convert_plus (to_plus_expr (make_binary (expr)));
3829
+ }
3830
+ }
3803
3831
else if (expr.type ().id () == ID_floatbv)
3804
3832
{
3805
3833
// Floating-point additions should have be been converted
0 commit comments