Skip to content

Commit 92659b5

Browse files
authored
Merge pull request #5822 from tautschnig/pointer-encoding-width
Store pointer encoding configuration in boolbv_widtht
2 parents c408367 + 5cf2b07 commit 92659b5

13 files changed

+236
-146
lines changed

scripts/expected_doxygen_warnings.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ warning: Include graph for 'cbmc_parse_options.cpp' not generated, too many node
8383
warning: Include graph for 'goto_instrument_parse_options.cpp' not generated, too many nodes (97), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
8484
warning: Included by graph for 'goto_functions.h' not generated, too many nodes (66), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
8585
warning: Included by graph for 'goto_model.h' not generated, too many nodes (109), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
86-
warning: Included by graph for 'arith_tools.h' not generated, too many nodes (182), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
87-
warning: Included by graph for 'c_types.h' not generated, too many nodes (111), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
86+
warning: Included by graph for 'arith_tools.h' not generated, too many nodes (181), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
87+
warning: Included by graph for 'c_types.h' not generated, too many nodes (110), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
8888
warning: Included by graph for 'config.h' not generated, too many nodes (85), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
8989
warning: Included by graph for 'exception_utils.h' not generated, too many nodes (61), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9090
warning: Included by graph for 'expr.h' not generated, too many nodes (87), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.

src/solvers/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ SRC = $(BOOLEFORCE_SRC) \
130130
flattening/boolbv_width.cpp \
131131
flattening/boolbv_with.cpp \
132132
flattening/bv_dimacs.cpp \
133-
flattening/bv_endianness_map.cpp \
134133
flattening/bv_minimize.cpp \
135134
flattening/bv_pointers.cpp \
136135
flattening/bv_utils.cpp \

src/solvers/flattening/boolbv.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
//
1616

1717
#include <util/byte_operators.h>
18+
#include <util/endianness_map.h>
1819
#include <util/expr.h>
1920
#include <util/mp_arith.h>
2021
#include <util/optional.h>
@@ -46,7 +47,7 @@ class boolbvt:public arrayst
4647
bool get_array_constraints = false)
4748
: arrayst(_ns, _prop, message_handler, get_array_constraints),
4849
unbounded_array(unbounded_arrayt::U_NONE),
49-
boolbv_width(_ns),
50+
bv_width(_ns),
5051
bv_utils(_prop),
5152
functions(*this),
5253
map(_prop)
@@ -92,9 +93,19 @@ class boolbvt:public arrayst
9293
return map;
9394
}
9495

95-
boolbv_widtht boolbv_width;
96+
virtual std::size_t boolbv_width(const typet &type) const
97+
{
98+
return bv_width(type);
99+
}
100+
101+
virtual endianness_mapt
102+
endianness_map(const typet &type, bool little_endian) const
103+
{
104+
return endianness_mapt{type, little_endian, ns};
105+
}
96106

97107
protected:
108+
boolbv_widtht bv_width;
98109
bv_utilst bv_utils;
99110

100111
// uninterpreted functions

src/solvers/flattening/boolbv_byte_extract.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include <solvers/lowering/expr_lowering.h>
1919

20-
#include "bv_endianness_map.h"
21-
22-
bvt map_bv(const bv_endianness_mapt &map, const bvt &src)
20+
bvt map_bv(const endianness_mapt &map, const bvt &src)
2321
{
2422
PRECONDITION(map.number_of_bits() == src.size());
2523
bvt result;
@@ -101,11 +99,11 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
10199
const bool little_endian = expr.id() == ID_byte_extract_little_endian;
102100

103101
// first do op0
104-
const bv_endianness_mapt op_map(op.type(), little_endian, ns, boolbv_width);
102+
const endianness_mapt op_map = endianness_map(op.type(), little_endian);
105103
const bvt op_bv=map_bv(op_map, convert_bv(op));
106104

107105
// do result
108-
bv_endianness_mapt result_map(expr.type(), little_endian, ns, boolbv_width);
106+
endianness_mapt result_map = endianness_map(expr.type(), little_endian);
109107
bvt bv;
110108
bv.resize(width);
111109

src/solvers/flattening/boolbv_byte_update.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Author: Daniel Kroening, [email protected]
1515

1616
#include <solvers/lowering/expr_lowering.h>
1717

18-
#include "bv_endianness_map.h"
19-
2018
bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
2119
{
2220
// if we update (from) an unbounded array, lower the expression as the array
@@ -67,8 +65,8 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
6765
}
6866
else
6967
{
70-
bv_endianness_mapt map_op(op.type(), false, ns, boolbv_width);
71-
bv_endianness_mapt map_value(value.type(), false, ns, boolbv_width);
68+
endianness_mapt map_op = endianness_map(op.type(), false);
69+
endianness_mapt map_value = endianness_map(value.type(), false);
7270

7371
const std::size_t offset_i = numeric_cast_v<std::size_t>(offset);
7472

@@ -99,8 +97,8 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
9997
offset_expr, from_integer(offset / byte_width, offset_expr.type()));
10098
literalt equal=convert(equality);
10199

102-
bv_endianness_mapt map_op(op.type(), little_endian, ns, boolbv_width);
103-
bv_endianness_mapt map_value(value.type(), little_endian, ns, boolbv_width);
100+
endianness_mapt map_op = endianness_map(op.type(), little_endian);
101+
endianness_mapt map_value = endianness_map(value.type(), little_endian);
104102

105103
for(std::size_t bit=0; bit<update_width; bit++)
106104
if(offset+bit<bv.size())

src/solvers/flattening/boolbv_union.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Author: Daniel Kroening, [email protected]
1111
#include <util/arith_tools.h>
1212
#include <util/config.h>
1313

14-
#include "bv_endianness_map.h"
15-
1614
bvt boolbvt::convert_union(const union_exprt &expr)
1715
{
1816
std::size_t width=boolbv_width(expr.type());
@@ -45,8 +43,8 @@ bvt boolbvt::convert_union(const union_exprt &expr)
4543
config.ansi_c.endianness == configt::ansi_ct::endiannesst::IS_BIG_ENDIAN,
4644
"endianness should be set to either little endian or big endian");
4745

48-
bv_endianness_mapt map_u(expr.type(), false, ns, boolbv_width);
49-
bv_endianness_mapt map_op(expr.op().type(), false, ns, boolbv_width);
46+
endianness_mapt map_u = endianness_map(expr.type(), false);
47+
endianness_mapt map_op = endianness_map(expr.op().type(), false);
5048

5149
for(std::size_t i=0; i<op_bv.size(); i++)
5250
bv[map_u.map_bit(i)]=op_bv[map_op.map_bit(i)];

src/solvers/flattening/boolbv_width.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/arith_tools.h>
1414
#include <util/exception_utils.h>
1515
#include <util/invariant.h>
16+
#include <util/namespace.h>
1617
#include <util/std_types.h>
1718

1819
boolbv_widtht::boolbv_widtht(const namespacet &_ns):ns(_ns)
1920
{
2021
}
2122

22-
boolbv_widtht::~boolbv_widtht()
23-
{
24-
}
25-
2623
const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const
2724
{
2825
// check cache first
@@ -184,11 +181,11 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const
184181
else if(type_id==ID_pointer)
185182
entry.total_width = type_checked_cast<pointer_typet>(type).get_width();
186183
else if(type_id==ID_struct_tag)
187-
entry=get_entry(ns.follow_tag(to_struct_tag_type(type)));
184+
entry.total_width = operator()(ns.follow_tag(to_struct_tag_type(type)));
188185
else if(type_id==ID_union_tag)
189-
entry=get_entry(ns.follow_tag(to_union_tag_type(type)));
186+
entry.total_width = operator()(ns.follow_tag(to_union_tag_type(type)));
190187
else if(type_id==ID_c_enum_tag)
191-
entry=get_entry(ns.follow_tag(to_c_enum_tag_type(type)));
188+
entry.total_width = operator()(ns.follow_tag(to_c_enum_tag_type(type)));
192189
else if(type_id==ID_c_bit_field)
193190
{
194191
entry.total_width=to_c_bit_field_type(type).get_width();

src/solvers/flattening/boolbv_width.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ Author: Daniel Kroening, [email protected]
1111
#define CPROVER_SOLVERS_FLATTENING_BOOLBV_WIDTH_H
1212

1313
#include <util/std_types.h>
14-
#include <util/namespace.h>
14+
15+
class namespacet;
1516

1617
class boolbv_widtht
1718
{
1819
public:
1920
explicit boolbv_widtht(const namespacet &_ns);
20-
~boolbv_widtht();
21+
virtual ~boolbv_widtht() = default;
2122

22-
std::size_t operator()(const typet &type) const
23+
virtual std::size_t operator()(const typet &type) const
2324
{
2425
return get_entry(type).total_width;
2526
}

src/solvers/flattening/boolbv_with.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/arith_tools.h>
1414
#include <util/config.h>
1515

16-
#include "bv_endianness_map.h"
17-
1816
bvt boolbvt::convert_with(const with_exprt &expr)
1917
{
2018
bvt bv = convert_bv(expr.old());
@@ -248,8 +246,8 @@ void boolbvt::convert_with_union(
248246
assert(
249247
config.ansi_c.endianness==configt::ansi_ct::endiannesst::IS_BIG_ENDIAN);
250248

251-
bv_endianness_mapt map_u(type, false, ns, boolbv_width);
252-
bv_endianness_mapt map_op2(op2.type(), false, ns, boolbv_width);
249+
endianness_mapt map_u = endianness_map(type, false);
250+
endianness_mapt map_op2 = endianness_map(op2.type(), false);
253251

254252
for(std::size_t i=0; i<op2_bv.size(); i++)
255253
next_bv[map_u.map_bit(i)]=op2_bv[map_op2.map_bit(i)];

src/solvers/flattening/bv_endianness_map.cpp

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/solvers/flattening/bv_endianness_map.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)