Skip to content

Commit 1a020c4

Browse files
committed
implement flattening for +/- for the range type
The flattening solver backend lowers the integer range type to bitvectors. This adds support for addition and subtraction for the range type via lowering to bitvector addition/subtraction.
1 parent bf58af8 commit 1a020c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/solvers/flattening/boolbv_add_sub.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ bvt boolbvt::convert_add_sub(const exprt &expr)
124124
}
125125
}
126126
}
127+
else if(type.id() == ID_range)
128+
{
129+
// add: lhs + from + rhs + from - from = lhs + rhs + from
130+
// sub: lhs + from - (rhs + from) - from = lhs - rhs - from
131+
mp_integer from = to_range_type(type).get_from();
132+
bv = bv_utils.add_sub(bv, op, subtract);
133+
bv = bv_utils.add_sub(
134+
bv, bv_utils.build_constant(from, op.size()), subtract);
135+
}
127136
else if(type.id()==ID_floatbv)
128137
{
129138
// needs to change due to rounding mode

0 commit comments

Comments
 (0)