Skip to content

Move has_byte_operator to util #7329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/solvers/flattening/boolbv_equality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ Author: Daniel Kroening, [email protected]

\*******************************************************************/

#include "boolbv.h"

#include <util/std_expr.h>
#include <util/byte_operators.h>
#include <util/invariant.h>
#include <util/std_expr.h>

#include <solvers/lowering/expr_lowering.h>

#include "boolbv.h"

literalt boolbvt::convert_equality(const equal_exprt &expr)
{
const bool equality_types_match = expr.lhs().type() == expr.rhs().type();
Expand Down
15 changes: 0 additions & 15 deletions src/solvers/lowering/byte_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2483,21 +2483,6 @@ exprt lower_byte_update(const byte_update_exprt &src, const namespacet &ns)
return result;
}

bool has_byte_operator(const exprt &src)
{
if(src.id()==ID_byte_update_little_endian ||
src.id()==ID_byte_update_big_endian ||
src.id()==ID_byte_extract_little_endian ||
src.id()==ID_byte_extract_big_endian)
return true;

forall_operands(it, src)
if(has_byte_operator(*it))
return true;

return false;
}

exprt lower_byte_operators(const exprt &src, const namespacet &ns)
{
exprt tmp=src;
Expand Down
2 changes: 0 additions & 2 deletions src/solvers/lowering/expr_lowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ exprt lower_byte_update(const byte_update_exprt &src, const namespacet &ns);
/// byte_extract_exprt or \ref byte_update_exprt.
exprt lower_byte_operators(const exprt &src, const namespacet &ns);

bool has_byte_operator(const exprt &src);

#endif /* CPROVER_SOLVERS_LOWERING_EXPR_LOWERING_H */
20 changes: 20 additions & 0 deletions src/util/byte_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,23 @@ make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value)
return byte_update_exprt{
byte_update_id(), _op, _offset, _value, config.ansi_c.char_width};
}

bool has_byte_operator(const exprt &src)
{
if(
src.id() == ID_byte_update_little_endian ||
src.id() == ID_byte_update_big_endian ||
src.id() == ID_byte_extract_little_endian ||
src.id() == ID_byte_extract_big_endian)
{
return true;
}

for(const auto &op : src.operands())
{
if(has_byte_operator(op))
return true;
}

return false;
}
4 changes: 4 additions & 0 deletions src/util/byte_operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,8 @@ make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type);
byte_update_exprt
make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value);

/// Return true iff \p src or one of its operands contain a byte extract or byte
/// update expression.
bool has_byte_operator(const exprt &src);

#endif // CPROVER_UTIL_BYTE_OPERATORS_H