@@ -14,6 +14,7 @@ Date: April 2017
14
14
#include " mm_io.h"
15
15
16
16
#include < util/fresh_symbol.h>
17
+ #include < util/message.h>
17
18
#include < util/pointer_expr.h>
18
19
#include < util/pointer_offset_size.h>
19
20
#include < util/pointer_predicates.h>
@@ -30,6 +31,9 @@ class mm_iot
30
31
31
32
void mm_io (goto_functionst::goto_functiont &goto_function);
32
33
34
+ std::size_t reads_replaced = 0 ;
35
+ std::size_t writes_replaced = 0 ;
36
+
33
37
protected:
34
38
const irep_idt id_r = CPROVER_PREFIX " mm_io_r" ;
35
39
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)
117
121
typecast_exprt (size_opt.value (), st)},
118
122
source_location);
119
123
goto_function.body .insert_before_swap (it, call);
124
+ ++reads_replaced;
120
125
it++;
121
126
}
122
127
}
@@ -140,21 +145,33 @@ void mm_iot::mm_io(goto_functionst::goto_functiont &goto_function)
140
145
typecast_exprt (a_rhs, vt)});
141
146
goto_function.body .insert_before_swap (it);
142
147
*it = goto_programt::make_function_call (fc, source_location);
148
+ ++writes_replaced;
143
149
it++;
144
150
}
145
151
}
146
152
}
147
153
}
148
154
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)
150
159
{
151
160
mm_iot rewrite{symbol_table};
152
161
153
- for (auto & f : goto_functions.function_map )
162
+ for (auto &f : goto_functions.function_map )
154
163
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
+ }
155
172
}
156
173
157
- void mm_io (goto_modelt &model)
174
+ void mm_io (goto_modelt &model, message_handlert &message_handler )
158
175
{
159
- mm_io (model.symbol_table , model.goto_functions );
176
+ mm_io (model.symbol_table , model.goto_functions , message_handler );
160
177
}
0 commit comments