Skip to content

Commit 5351d7b

Browse files
committed
SMT2: implement minus on range types
This adds an implementation of minus on range types to the SMT2 backend.
1 parent 5139a19 commit 5351d7b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/solvers/smt2/smt2_conv.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -4065,6 +4065,22 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
40654065
"unsupported operand types for -: " + expr.op0().type().id_string() +
40664066
" and " + expr.op1().type().id_string());
40674067
}
4068+
else if(expr.type().id() == ID_range)
4069+
{
4070+
auto &range_type = to_range_type(expr.type());
4071+
4072+
// sub: lhs + from - (rhs + from) - from = lhs - rhs - from
4073+
mp_integer from = range_type.get_from();
4074+
const auto size = range_type.get_to() - range_type.get_from() + 1;
4075+
const auto width = address_bits(size);
4076+
4077+
out << "(bvsub (bvsub ";
4078+
convert_expr(expr.op0());
4079+
out << ' ';
4080+
convert_expr(expr.op1());
4081+
out << ") (_ bv" << range_type.get_from() << ' ' << width
4082+
<< "))"; // bv, bvsub
4083+
}
40684084
else
40694085
UNEXPECTEDCASE("unsupported type for -: "+expr.type().id_string());
40704086
}

0 commit comments

Comments
 (0)