-
Notifications
You must be signed in to change notification settings - Fork 277
Use a specialised endianness map for flattening #2066
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*******************************************************************\ | ||
|
||
Module: | ||
|
||
Author: Michael Tautschnig | ||
|
||
\*******************************************************************/ | ||
|
||
#include "bv_endianness_map.h" | ||
|
||
#include <util/arith_tools.h> | ||
#include <util/c_types.h> | ||
|
||
#include "boolbv_width.h" | ||
|
||
void bv_endianness_mapt::build_little_endian(const typet &src) | ||
{ | ||
const std::size_t width = boolbv_width(src); | ||
|
||
if(width == 0) | ||
return; | ||
|
||
const std::size_t new_size = map.size() + width; | ||
map.reserve(new_size); | ||
|
||
for(std::size_t i = map.size(); i < new_size; ++i) | ||
map.push_back(i); | ||
} | ||
|
||
void bv_endianness_mapt::build_big_endian(const typet &src) | ||
{ | ||
if(src.id() == ID_pointer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I think my later implementation for extending the memory encoding will require revising this, but for now it makes more sense as you proposed. |
||
build_little_endian(src); | ||
else | ||
endianness_mapt::build_big_endian(src); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*******************************************************************\ | ||
|
||
Module: | ||
|
||
Author: Michael Tautschnig | ||
|
||
\*******************************************************************/ | ||
|
||
#ifndef CPROVER_SOLVERS_FLATTENING_BV_ENDIANNESS_MAP_H | ||
#define CPROVER_SOLVERS_FLATTENING_BV_ENDIANNESS_MAP_H | ||
|
||
#include <util/endianness_map.h> | ||
|
||
class boolbv_widtht; | ||
|
||
/// Map bytes according to the configured endianness. The key difference to | ||
/// endianness_mapt is that bv_endianness_mapt is aware of the bit-level | ||
/// encoding of types, which need not co-incide with the bit layout at | ||
/// source-code level. | ||
class bv_endianness_mapt : public endianness_mapt | ||
{ | ||
public: | ||
bv_endianness_mapt( | ||
const typet &type, | ||
bool little_endian, | ||
const namespacet &_ns, | ||
boolbv_widtht &_boolbv_width) | ||
: endianness_mapt(_ns), boolbv_width(_boolbv_width) | ||
{ | ||
build(type, little_endian); | ||
} | ||
|
||
protected: | ||
boolbv_widtht &boolbv_width; | ||
|
||
virtual void build_little_endian(const typet &type) override; | ||
virtual void build_big_endian(const typet &type) override; | ||
}; | ||
|
||
#endif // CPROVER_SOLVERS_FLATTENING_BV_ENDIANNESS_MAP_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment either here or in the header file how this differs from
endianness_mapt
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - both in the header file and the commit message.