Skip to content

Commit fce00aa

Browse files
committed
Move has_byte_operator to util
There is nothing solvers-specific to this function. Cleanup in preparation of moving all byte-operator lowering to util.
1 parent 1199c56 commit fce00aa

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

src/solvers/flattening/boolbv_equality.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9-
#include "boolbv.h"
10-
11-
#include <util/std_expr.h>
9+
#include <util/byte_operators.h>
1210
#include <util/invariant.h>
11+
#include <util/std_expr.h>
1312

1413
#include <solvers/lowering/expr_lowering.h>
1514

15+
#include "boolbv.h"
16+
1617
literalt boolbvt::convert_equality(const equal_exprt &expr)
1718
{
1819
const bool equality_types_match = expr.lhs().type() == expr.rhs().type();

src/solvers/lowering/byte_operators.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,21 +2483,6 @@ exprt lower_byte_update(const byte_update_exprt &src, const namespacet &ns)
24832483
return result;
24842484
}
24852485

2486-
bool has_byte_operator(const exprt &src)
2487-
{
2488-
if(src.id()==ID_byte_update_little_endian ||
2489-
src.id()==ID_byte_update_big_endian ||
2490-
src.id()==ID_byte_extract_little_endian ||
2491-
src.id()==ID_byte_extract_big_endian)
2492-
return true;
2493-
2494-
forall_operands(it, src)
2495-
if(has_byte_operator(*it))
2496-
return true;
2497-
2498-
return false;
2499-
}
2500-
25012486
exprt lower_byte_operators(const exprt &src, const namespacet &ns)
25022487
{
25032488
exprt tmp=src;

src/solvers/lowering/expr_lowering.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,4 @@ exprt lower_byte_update(const byte_update_exprt &src, const namespacet &ns);
4141
/// byte_extract_exprt or \ref byte_update_exprt.
4242
exprt lower_byte_operators(const exprt &src, const namespacet &ns);
4343

44-
bool has_byte_operator(const exprt &src);
45-
4644
#endif /* CPROVER_SOLVERS_LOWERING_EXPR_LOWERING_H */

src/util/byte_operators.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,23 @@ make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value)
5757
return byte_update_exprt{
5858
byte_update_id(), _op, _offset, _value, config.ansi_c.char_width};
5959
}
60+
61+
bool has_byte_operator(const exprt &src)
62+
{
63+
if(
64+
src.id() == ID_byte_update_little_endian ||
65+
src.id() == ID_byte_update_big_endian ||
66+
src.id() == ID_byte_extract_little_endian ||
67+
src.id() == ID_byte_extract_big_endian)
68+
{
69+
return true;
70+
}
71+
72+
for(const auto &op : src.operands())
73+
{
74+
if(has_byte_operator(op))
75+
return true;
76+
}
77+
78+
return false;
79+
}

src/util/byte_operators.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,8 @@ make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type);
162162
byte_update_exprt
163163
make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value);
164164

165+
/// Return true iff \p src or one of its operands contain a byte extract or byte
166+
/// update expression.
167+
bool has_byte_operator(const exprt &src);
168+
165169
#endif // CPROVER_UTIL_BYTE_OPERATORS_H

0 commit comments

Comments
 (0)