@@ -68,53 +68,58 @@ void bv_endianness_mapt::build_big_endian(const typet &src)
6868endianness_mapt
6969bv_pointerst::endianness_map (const typet &type, bool little_endian) const
7070{
71- return bv_endianness_mapt{type, little_endian, ns, bv_pointers_width };
71+ return bv_endianness_mapt{type, little_endian, ns, bv_width };
7272}
7373
74- std::size_t bv_pointerst::bv_pointers_widtht::
75- operator ()(const typet &type) const
76- {
77- if (type.id () != ID_pointer)
78- return boolbv_widtht::operator ()(type);
79-
80- // check or update the cache, just like boolbv_widtht does
81- std::pair<cachet::iterator, bool > cache_result =
82- cache.insert (std::pair<typet, entryt>(type, entryt ()));
83-
84- if (cache_result.second )
85- {
86- std::size_t &total_width = cache_result.first ->second .total_width ;
87-
88- total_width = get_address_width (to_pointer_type (type));
89- DATA_INVARIANT (total_width > 0 , " pointer width shall be greater than zero" );
90- }
91-
92- return cache_result.first ->second .total_width ;
93- }
94-
95- std::size_t bv_pointerst::bv_pointers_widtht::get_object_width (
96- const pointer_typet &type) const
74+ std::size_t bv_pointerst::get_object_width (const pointer_typet &) const
9775{
9876 // not actually type-dependent for now
99- (void )type;
10077 return config.bv_encoding .object_bits ;
10178}
10279
103- std::size_t bv_pointerst::bv_pointers_widtht::get_offset_width (
104- const pointer_typet &type) const
80+ std::size_t bv_pointerst::get_offset_width (const pointer_typet &type) const
10581{
10682 const std::size_t pointer_width = type.get_width ();
10783 const std::size_t object_width = get_object_width (type);
10884 PRECONDITION (pointer_width >= object_width);
10985 return pointer_width - object_width;
11086}
11187
112- std::size_t bv_pointerst::bv_pointers_widtht::get_address_width (
113- const pointer_typet &type) const
88+ std::size_t bv_pointerst::get_address_width (const pointer_typet &type) const
11489{
11590 return type.get_width ();
11691}
11792
93+ bvt bv_pointerst::object_literals (const bvt &bv, const pointer_typet &type)
94+ const
95+ {
96+ const std::size_t offset_width = get_offset_width (type);
97+ const std::size_t object_width = get_object_width (type);
98+ PRECONDITION (bv.size () >= offset_width + object_width);
99+
100+ return bvt (
101+ bv.begin () + offset_width, bv.begin () + offset_width + object_width);
102+ }
103+
104+ bvt bv_pointerst::offset_literals (const bvt &bv, const pointer_typet &type)
105+ const
106+ {
107+ const std::size_t offset_width = get_offset_width (type);
108+ PRECONDITION (bv.size () >= offset_width);
109+
110+ return bvt (bv.begin (), bv.begin () + offset_width);
111+ }
112+
113+ bvt bv_pointerst::object_offset_encoding (const bvt &object, const bvt &offset)
114+ {
115+ bvt result;
116+ result.reserve (offset.size () + object.size ());
117+ result.insert (result.end (), offset.begin (), offset.end ());
118+ result.insert (result.end (), object.begin (), object.end ());
119+
120+ return result;
121+ }
122+
118123literalt bv_pointerst::convert_rest (const exprt &expr)
119124{
120125 PRECONDITION (expr.type ().id () == ID_bool);
@@ -136,8 +141,7 @@ literalt bv_pointerst::convert_rest(const exprt &expr)
136141 bvt invalid_bv = object_literals (
137142 encode (pointer_logic.get_invalid_object (), type), type);
138143
139- const std::size_t object_bits =
140- bv_pointers_width.get_object_width (type);
144+ const std::size_t object_bits = get_object_width (type);
141145
142146 bvt equal_invalid_bv;
143147 equal_invalid_bv.reserve (object_bits);
@@ -210,8 +214,7 @@ bv_pointerst::bv_pointerst(
210214 message_handlert &message_handler,
211215 bool get_array_constraints)
212216 : boolbvt(_ns, _prop, message_handler, get_array_constraints),
213- pointer_logic(_ns),
214- bv_pointers_width(_ns)
217+ pointer_logic(_ns)
215218{
216219}
217220
@@ -460,7 +463,7 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
460463 count == 1 ,
461464 " there should be exactly one pointer-type operand in a pointer-type sum" );
462465
463- const std::size_t offset_bits = bv_pointers_width. get_offset_width (type);
466+ const std::size_t offset_bits = get_offset_width (type);
464467 bvt sum = bv_utils.build_constant (0 , offset_bits);
465468
466469 forall_operands (it, plus_expr)
@@ -815,8 +818,8 @@ exprt bv_pointerst::bv_get_rec(
815818
816819bvt bv_pointerst::encode (std::size_t addr, const pointer_typet &type) const
817820{
818- const std::size_t offset_bits = bv_pointers_width. get_offset_width (type);
819- const std::size_t object_bits = bv_pointers_width. get_object_width (type);
821+ const std::size_t offset_bits = get_offset_width (type);
822+ const std::size_t object_bits = get_object_width (type);
820823
821824 bvt zero_offset (offset_bits, const_literal (false ));
822825
@@ -834,7 +837,7 @@ bvt bv_pointerst::offset_arithmetic(
834837 const bvt &bv,
835838 const mp_integer &x)
836839{
837- const std::size_t offset_bits = bv_pointers_width. get_offset_width (type);
840+ const std::size_t offset_bits = get_offset_width (type);
838841
839842 return offset_arithmetic (
840843 type, bv, 1 , bv_utils.build_constant (x, offset_bits));
@@ -852,7 +855,7 @@ bvt bv_pointerst::offset_arithmetic(
852855 index.type ().id ()==ID_signedbv?bv_utilst::representationt::SIGNED:
853856 bv_utilst::representationt::UNSIGNED;
854857
855- const std::size_t offset_bits = bv_pointers_width. get_offset_width (type);
858+ const std::size_t offset_bits = get_offset_width (type);
856859 bv_index=bv_utils.extension (bv_index, offset_bits, rep);
857860
858861 return offset_arithmetic (type, bv, factor, bv_index);
@@ -874,7 +877,7 @@ bvt bv_pointerst::offset_arithmetic(
874877 bv_index = bv_utils.signed_multiplier (index, bv_factor);
875878 }
876879
877- const std::size_t offset_bits = bv_pointers_width. get_offset_width (type);
880+ const std::size_t offset_bits = get_offset_width (type);
878881 bv_index = bv_utils.sign_extension (bv_index, offset_bits);
879882
880883 bvt offset_bv = offset_literals (bv, type);
@@ -889,7 +892,7 @@ bvt bv_pointerst::add_addr(const exprt &expr)
889892 std::size_t a=pointer_logic.add_object (expr);
890893
891894 const pointer_typet type = pointer_type (expr.type ());
892- const std::size_t object_bits = bv_pointers_width. get_object_width (type);
895+ const std::size_t object_bits = get_object_width (type);
893896 const std::size_t max_objects=std::size_t (1 )<<object_bits;
894897
895898 if (a==max_objects)
0 commit comments