Skip to content

Commit 7162259

Browse files
committed
MMIO instrument: print status
Previously, there was no indication as to whether any transformation had taken place.
1 parent 7b8fbc2 commit 7162259

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

doc/architectural/goto-program-transformations.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ See the device behaviour section of `modeling-mmio.md` for details of
6262
modeling memory-mapped I/O regions of device interfaces. This pass is always
6363
carried out but will only make changes if one of the modelling functions exist.
6464

65-
The implementation of this pass is called via the \ref mm_io(goto_modelt &)
65+
The implementation of this pass is called via the
66+
\ref mm_io(goto_modelt &, message_handlert &)
6667
"mm_io" function. Further documentation of this pass can be found in \ref
6768
mm_io.h
6869

jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ bool jdiff_parse_optionst::process_goto_program(
190190
class_hierarchyt class_hierarchy(goto_model.symbol_table);
191191
remove_instanceof(goto_model, class_hierarchy, ui_message_handler);
192192

193-
mm_io(goto_model);
193+
mm_io(goto_model, ui_message_handler);
194194

195195
// instrument library preconditions
196196
instrument_preconditions(goto_model);

regression/cbmc/mm_io1/test.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.c
33
--no-standard-checks
4+
^Replaced MMIO operations: 3 reads, 1 writes
45
^EXIT=0$
56
^SIGNAL=0$
67
^VERIFICATION SUCCESSFUL$

src/goto-programs/mm_io.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Date: April 2017
1414
#include "mm_io.h"
1515

1616
#include <util/fresh_symbol.h>
17+
#include <util/message.h>
1718
#include <util/pointer_expr.h>
1819
#include <util/pointer_offset_size.h>
1920
#include <util/pointer_predicates.h>
@@ -30,6 +31,9 @@ class mm_iot
3031

3132
void mm_io(goto_functionst::goto_functiont &goto_function);
3233

34+
std::size_t reads_replaced = 0;
35+
std::size_t writes_replaced = 0;
36+
3337
protected:
3438
const irep_idt id_r = CPROVER_PREFIX "mm_io_r";
3539
const irep_idt id_w = CPROVER_PREFIX "mm_io_w";
@@ -117,6 +121,7 @@ void mm_iot::mm_io(goto_functionst::goto_functiont &goto_function)
117121
typecast_exprt(size_opt.value(), st)},
118122
source_location);
119123
goto_function.body.insert_before_swap(it, call);
124+
++reads_replaced;
120125
it++;
121126
}
122127
}
@@ -140,21 +145,33 @@ void mm_iot::mm_io(goto_functionst::goto_functiont &goto_function)
140145
typecast_exprt(a_rhs, vt)});
141146
goto_function.body.insert_before_swap(it);
142147
*it = goto_programt::make_function_call(fc, source_location);
148+
++writes_replaced;
143149
it++;
144150
}
145151
}
146152
}
147153
}
148154

149-
void mm_io(symbol_tablet &symbol_table, goto_functionst &goto_functions)
155+
void mm_io(
156+
symbol_tablet &symbol_table,
157+
goto_functionst &goto_functions,
158+
message_handlert &message_handler)
150159
{
151160
mm_iot rewrite{symbol_table};
152161

153-
for(auto & f : goto_functions.function_map)
162+
for(auto &f : goto_functions.function_map)
154163
rewrite.mm_io(f.second);
164+
165+
if(rewrite.reads_replaced || rewrite.writes_replaced)
166+
{
167+
messaget log{message_handler};
168+
log.status() << "Replaced MMIO operations: " << rewrite.reads_replaced
169+
<< " read(s), " << rewrite.writes_replaced << " write(s)"
170+
<< messaget::eom;
171+
}
155172
}
156173

157-
void mm_io(goto_modelt &model)
174+
void mm_io(goto_modelt &model, message_handlert &message_handler)
158175
{
159-
mm_io(model.symbol_table, model.goto_functions);
176+
mm_io(model.symbol_table, model.goto_functions, message_handler);
160177
}

src/goto-programs/mm_io.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ Date: April 2017
3131

3232
class goto_functionst;
3333
class goto_modelt;
34+
class message_handlert;
3435
class symbol_tablet;
3536

36-
void mm_io(const symbol_tablet &, goto_functionst &);
37-
void mm_io(goto_modelt &);
37+
void mm_io(const symbol_tablet &, goto_functionst &, message_handlert &);
38+
void mm_io(goto_modelt &, message_handlert &);
3839

3940
#endif // CPROVER_GOTO_PROGRAMS_MM_IO_H

src/goto-programs/process_goto_program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool process_goto_program(
4545
<< messaget::eom;
4646
remove_function_pointers(log.get_message_handler(), goto_model, false);
4747

48-
mm_io(goto_model);
48+
mm_io(goto_model, log.get_message_handler());
4949

5050
// instrument library preconditions
5151
instrument_preconditions(goto_model);

0 commit comments

Comments
 (0)