CBMC
accelerate.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Loop Acceleration
4 
5 Author: Matt Lewis
6 
7 \*******************************************************************/
8 
11 
12 #include "accelerate.h"
13 
14 #include <analyses/natural_loops.h>
15 
17 
18 #include <util/arith_tools.h>
19 #include <util/find_symbols.h>
20 #include <util/std_code.h>
21 #include <util/std_expr.h>
22 
23 #include <iostream>
24 #include <list>
25 
26 #include "accelerator.h"
28 #include "overflow_instrumenter.h"
29 #include "path.h"
30 #include "scratch_program.h"
31 #include "util.h"
32 
33 #ifdef DEBUG
34 # include <util/format_expr.h>
35 #endif
36 
38  goto_programt::targett loop_header)
39 {
41  natural_loops.loop_map.at(loop_header);
42  goto_programt::targett back_jump=loop_header;
43 
44  for(const auto &t : loop)
45  {
46  if(
47  t->is_goto() && t->condition().is_true() && t->targets.size() == 1 &&
48  t->targets.front() == loop_header &&
49  t->location_number > back_jump->location_number)
50  {
51  back_jump=t;
52  }
53  }
54 
55  return back_jump;
56 }
57 
59 {
61  natural_loops.loop_map.at(loop_header);
62 
63  for(const auto &t : loop)
64  {
65  if(t->is_backwards_goto())
66  {
67  if(t->targets.size()!=1 ||
68  t->get_target()!=loop_header)
69  {
70  return true;
71  }
72  }
73 
74  // Header of some other loop?
75  if(t != loop_header && natural_loops.is_loop_header(t))
76  {
77  return true;
78  }
79  }
80 
81  return false;
82 }
83 
85 {
86  pathst loop_paths, exit_paths;
87  goto_programt::targett back_jump=find_back_jump(loop_header);
88  int num_accelerated=0;
89  std::list<path_acceleratort> accelerators;
91  natural_loops.loop_map.at(loop_header);
92 
93  if(contains_nested_loops(loop_header))
94  {
95  // For now, only accelerate innermost loops.
96 #ifdef DEBUG
97  std::cout << "Not accelerating an outer loop\n";
98 #endif
99  return 0;
100  }
101 
102  goto_programt::targett overflow_loc;
103  make_overflow_loc(loop_header, back_jump, overflow_loc);
104  program.update();
105 
106 #if 1
107  enumerating_loop_accelerationt acceleration(
109  symbol_table,
111  program,
112  loop,
113  loop_header,
115  guard_manager);
116 #else
118  acceleration(symbol_table, goto_functions, program, loop, loop_header);
119 #endif
120 
121  path_acceleratort accelerator;
122 
123  while(acceleration.accelerate(accelerator) &&
124  (accelerate_limit < 0 ||
125  num_accelerated < accelerate_limit))
126  {
127  // set_dirty_vars(accelerator);
128 
129  if(is_underapproximate(accelerator))
130  {
131  // We have some underapproximated variables -- just punt for now.
132 #ifdef DEBUG
133  std::cout << "Not inserting accelerator because of underapproximation\n";
134 #endif
135 
136  continue;
137  }
138 
139  accelerators.push_back(accelerator);
140  num_accelerated++;
141 
142 #ifdef DEBUG
143  std::cout << "Accelerated path:\n";
144  output_path(accelerator.path, program, ns, std::cout);
145 
146  std::cout << "Accelerator has "
147  << accelerator.pure_accelerator.instructions.size()
148  << " instructions\n";
149 #endif
150  }
151 
153  program.insert_before_swap(loop_header, skip);
154 
155  goto_programt::targett new_inst=loop_header;
156  ++new_inst;
157 
158  loop.insert_instruction(new_inst);
159 
160  std::cout << "Overflow loc is " << overflow_loc->location_number << '\n';
161  std::cout << "Back jump is " << back_jump->location_number << '\n';
162 
163  for(std::list<path_acceleratort>::iterator it=accelerators.begin();
164  it!=accelerators.end();
165  ++it)
166  {
167  subsumed_patht inserted(it->path);
168 
169  insert_accelerator(loop_header, back_jump, *it, inserted);
170  subsumed.push_back(inserted);
171  num_accelerated++;
172  }
173 
174  return num_accelerated;
175 }
176 
178  goto_programt::targett &loop_header,
179  goto_programt::targett &back_jump,
180  path_acceleratort &accelerator,
181  subsumed_patht &subsumed_path)
182 {
184  loop_header,
185  back_jump,
186  accelerator.pure_accelerator,
187  subsumed_path.accelerator);
188 
189  if(!accelerator.overflow_path.instructions.empty())
190  {
192  loop_header, back_jump, accelerator.overflow_path, subsumed_path.residue);
193  }
194 }
195 
196 /*
197  * Insert a looping path (usually an accelerator) into a goto-program,
198  * beginning at loop_header and jumping back to loop_header via back_jump.
199  * Stores the locations at which the looping path was added in inserted_path.
200  *
201  * THIS DESTROYS looping_path!!
202  */
204  goto_programt::targett &loop_header,
205  goto_programt::targett &back_jump,
206  goto_programt &looping_path,
207  patht &inserted_path)
208 {
209  goto_programt::targett loop_body=loop_header;
210  ++loop_body;
211 
213  loop_body,
215  loop_body,
217  loop_body->source_location()));
218 
219  program.destructive_insert(loop_body, looping_path);
220 
221  jump = program.insert_before(
222  loop_body, goto_programt::make_goto(back_jump, true_exprt()));
223 
224  for(goto_programt::targett t=loop_header;
225  t!=loop_body;
226  ++t)
227  {
228  inserted_path.push_back(path_nodet(t));
229  }
230 
231  inserted_path.push_back(path_nodet(back_jump));
232 }
233 
235  goto_programt::targett loop_header,
236  goto_programt::targett &loop_end,
237  goto_programt::targett &overflow_loc)
238 {
239  symbolt overflow_sym=utils.fresh_symbol("accelerate::overflow", bool_typet());
240  const exprt &overflow_var=overflow_sym.symbol_expr();
242  natural_loops.loop_map.at(loop_header);
243  overflow_instrumentert instrumenter(program, overflow_var, symbol_table);
244 
245  for(const auto &loop_instruction : loop)
246  {
247  overflow_locs[loop_instruction] = goto_programt::targetst();
248  goto_programt::targetst &added = overflow_locs[loop_instruction];
249 
250  instrumenter.add_overflow_checks(loop_instruction, added);
251  for(const auto &new_instruction : added)
252  loop.insert_instruction(new_instruction);
253  }
254 
256  loop_header,
258  t->swap(*loop_header);
259  loop.insert_instruction(t);
260  overflow_locs[loop_header].push_back(t);
261 
262  overflow_loc = program.insert_after(loop_end, goto_programt::make_skip());
263  overflow_loc->swap(*loop_end);
264  loop.insert_instruction(overflow_loc);
265 
267  loop_end, goto_programt::make_goto(overflow_loc, not_exprt(overflow_var)));
268  t2->swap(*loop_end);
269  overflow_locs[overflow_loc].push_back(t2);
270  loop.insert_instruction(t2);
271 
272  goto_programt::targett tmp=overflow_loc;
273  overflow_loc=loop_end;
274  loop_end=tmp;
275 }
276 
278 {
279  trace_automatont automaton(program);
280 
281  for(subsumed_pathst::iterator it=subsumed.begin();
282  it!=subsumed.end();
283  ++it)
284  {
285  if(!it->subsumed.empty())
286  {
287 #ifdef DEBUG
289  std::cout << "Restricting path:\n";
290  output_path(it->subsumed, program, ns, std::cout);
291 #endif
292 
293  automaton.add_path(it->subsumed);
294  }
295 
296  patht double_accelerator;
297  patht::iterator jt=double_accelerator.begin();
298  double_accelerator.insert(
299  jt, it->accelerator.begin(), it->accelerator.end());
300  double_accelerator.insert(
301  jt, it->accelerator.begin(), it->accelerator.end());
302 
303 #ifdef DEBUG
305  std::cout << "Restricting path:\n";
306  output_path(double_accelerator, program, ns, std::cout);
307 #endif
308  automaton.add_path(double_accelerator);
309  }
310 
311  std::cout << "Building trace automaton...\n";
312 
313  automaton.build();
314  insert_automaton(automaton);
315 }
316 
318 {
319  for(std::set<exprt>::iterator it=accelerator.dirty_vars.begin();
320  it!=accelerator.dirty_vars.end();
321  ++it)
322  {
323  expr_mapt::iterator jt=dirty_vars_map.find(*it);
324  exprt dirty_var;
325 
326  if(jt==dirty_vars_map.end())
327  {
329  symbolt new_sym=utils.fresh_symbol("accelerate::dirty", bool_typet());
330  dirty_var=new_sym.symbol_expr();
331  dirty_vars_map[*it]=dirty_var;
332  }
333  else
334  {
335  dirty_var=jt->second;
336  }
337 
338 #ifdef DEBUG
339  std::cout << "Setting dirty flag " << format(dirty_var) << " for "
340  << format(*it) << '\n';
341 #endif
342 
343  accelerator.pure_accelerator.add(
345  }
346 }
347 
349 {
350  for(expr_mapt::iterator it=dirty_vars_map.begin();
351  it!=dirty_vars_map.end();
352  ++it)
353  {
357  }
358 
360 
362  it!=program.instructions.end();
363  it=next)
364  {
365  next=it;
366  ++next;
367 
368  // If this is an assign to a tracked variable, clear the dirty flag.
369  // Note: this order of insertions means that we assume each of the read
370  // variables is clean _before_ clearing any dirty flags.
371  if(it->is_assign())
372  {
373  const exprt &lhs = it->assign_lhs();
374  expr_mapt::iterator dirty_var=dirty_vars_map.find(lhs);
375 
376  if(dirty_var!=dirty_vars_map.end())
377  {
379  code_assignt(dirty_var->second, false_exprt()));
380  program.insert_before_swap(it, clear_flag);
381  }
382  }
383 
384  // Find which symbols are read, i.e. those appearing in a guard or on
385  // the right hand side of an assignment. Assume each is not dirty.
386  std::set<symbol_exprt> read;
387 
388  if(it->has_condition())
389  find_symbols(it->condition(), read);
390 
391  if(it->is_assign())
392  find_symbols(it->assign_rhs(), read);
393 
394  for(const auto &var : read)
395  {
396  expr_mapt::iterator dirty_var=dirty_vars_map.find(var);
397 
398  if(dirty_var==dirty_vars_map.end())
399  {
400  continue;
401  }
402 
403  goto_programt::instructiont not_dirty =
404  goto_programt::make_assumption(not_exprt(dirty_var->second));
405  program.insert_before_swap(it, not_dirty);
406  }
407  }
408 }
409 
411 {
412  for(std::set<exprt>::iterator it=accelerator.dirty_vars.begin();
413  it!=accelerator.dirty_vars.end();
414  ++it)
415  {
416  if(it->id()==ID_symbol && it->type() == bool_typet())
417  {
418  const irep_idt &id=to_symbol_expr(*it).get_identifier();
419  const symbolt &sym = symbol_table.lookup_ref(id);
420 
421  if(sym.module=="scratch")
422  {
423  continue;
424  }
425  }
426 
427 #ifdef DEBUG
428  std::cout << "Underapproximate variable: " << format(*it) << '\n';
429 #endif
430  return true;
431  }
432 
433  return false;
434 }
435 
436 symbolt acceleratet::make_symbol(std::string name, typet type)
437 {
438  symbolt ret;
439  ret.module="accelerate";
440  ret.name=name;
441  ret.base_name=name;
442  ret.pretty_name=name;
443  ret.type=type;
444 
445  symbol_table.add(ret);
446 
447  return ret;
448 }
449 
451 {
452 #if 0
454  code_declt code(sym);
455 
456  decl->make_decl();
457  decl->code=code;
458 #endif
459 }
460 
462 {
463  decl(sym, t);
464 
467 }
468 
470 {
471  symbolt state_sym=make_symbol("trace_automaton::state",
473  symbolt next_state_sym=make_symbol("trace_automaton::next_state",
475  symbol_exprt state=state_sym.symbol_expr();
476  symbol_exprt next_state=next_state_sym.symbol_expr();
477 
478  trace_automatont::sym_mapt transitions;
479  state_sett accept_states;
480 
481  automaton.get_transitions(transitions);
482  automaton.accept_states(accept_states);
483 
484  std::cout
485  << "Inserting trace automaton with "
486  << automaton.num_states() << " states, "
487  << accept_states.size() << " accepting states and "
488  << transitions.size() << " transitions\n";
489 
490  // Declare the variables we'll use to encode the state machine.
492  decl(state, t, from_integer(automaton.init_state(), state.type()));
493  decl(next_state, t);
494 
495  // Now for each program location that appears as a symbol in the
496  // trace automaton, add the appropriate code to drive the state
497  // machine.
498  for(const auto &sym : automaton.alphabet)
499  {
500  scratch_programt state_machine{
502  trace_automatont::sym_range_pairt p=transitions.equal_range(sym);
503 
504  build_state_machine(p.first, p.second, accept_states, state, next_state,
505  state_machine);
506 
507  program.insert_before_swap(sym, state_machine);
508  }
509 }
510 
512  trace_automatont::sym_mapt::iterator begin,
513  trace_automatont::sym_mapt::iterator end,
514  state_sett &accept_states,
515  symbol_exprt state,
516  symbol_exprt next_state,
517  scratch_programt &state_machine)
518 {
519  std::map<unsigned int, unsigned int> successor_counts;
520  unsigned int max_count=0;
521  unsigned int likely_next=0;
522 
523  // Optimisation: find the most common successor state and initialise
524  // next_state to that value. This reduces the size of the state machine
525  // driver substantially.
526  for(trace_automatont::sym_mapt::iterator p=begin; p!=end; ++p)
527  {
528  trace_automatont::state_pairt state_pair=p->second;
529  unsigned int to=state_pair.second;
530  unsigned int count=0;
531 
532  if(successor_counts.find(to)==successor_counts.end())
533  {
534  count=1;
535  }
536  else
537  {
538  count=successor_counts[to] + 1;
539  }
540 
541  successor_counts[to]=count;
542 
543  if(count > max_count)
544  {
545  max_count=count;
546  likely_next=to;
547  }
548  }
549 
550  // Optimisation: if there is only one possible successor state, just
551  // jump straight to it instead of driving the whole machine.
552  if(successor_counts.size()==1)
553  {
554  if(accept_states.find(likely_next)!=accept_states.end())
555  {
556  // It's an accept state. Just assume(false).
557  state_machine.assume(false_exprt());
558  }
559  else
560  {
561  state_machine.assign(state,
562  from_integer(likely_next, next_state.type()));
563  }
564 
565  return;
566  }
567 
568  state_machine.assign(next_state,
569  from_integer(likely_next, next_state.type()));
570 
571  for(trace_automatont::sym_mapt::iterator p=begin; p!=end; ++p)
572  {
573  trace_automatont::state_pairt state_pair=p->second;
574  unsigned int from=state_pair.first;
575  unsigned int to=state_pair.second;
576 
577  if(to==likely_next)
578  {
579  continue;
580  }
581 
582  // We're encoding the transition
583  //
584  // from -loc-> to
585  //
586  // which we encode by inserting:
587  //
588  // next_state=(state==from) ? to : next_state;
589  //
590  // just before loc.
591  equal_exprt guard(state, from_integer(from, state.type()));
592  if_exprt rhs(guard, from_integer(to, next_state.type()), next_state);
593  state_machine.assign(next_state, rhs);
594  }
595 
596  // Update the state and assume(false) if we've hit an accept state.
597  state_machine.assign(state, next_state);
598 
599  for(state_sett::iterator it=accept_states.begin();
600  it!=accept_states.end();
601  ++it)
602  {
603  state_machine.assume(
604  not_exprt(equal_exprt(state, from_integer(*it, state.type()))));
605  }
606 }
607 
609 {
610  int num_accelerated=0;
611 
612  for(natural_loops_mutablet::loop_mapt::iterator it =
613  natural_loops.loop_map.begin();
614  it!=natural_loops.loop_map.end();
615  ++it)
616  {
617  goto_programt::targett t=it->first;
618  num_accelerated += accelerate_loop(t);
619  }
620 
621  program.update();
622 
623  if(num_accelerated > 0)
624  {
625  std::cout << "Engaging crush mode...\n";
626 
627  restrict_traces();
628  // add_dirty_checks();
629  program.update();
630 
631  std::cout << "Crush mode engaged.\n";
632  }
633 
634  return num_accelerated;
635 }
636 
638  goto_modelt &goto_model,
639  message_handlert &message_handler,
640  bool use_z3,
641  guard_managert &guard_manager)
642 {
643  for(auto &gf_entry : goto_model.goto_functions.function_map)
644  {
645  std::cout << "Accelerating function " << gf_entry.first << '\n';
646  acceleratet accelerate(
647  gf_entry.second.body, goto_model, message_handler, use_z3, guard_manager);
648 
649  int num_accelerated=accelerate.accelerate_loops();
650 
651  if(num_accelerated > 0)
652  {
653  std::cout << "Added " << num_accelerated
654  << " accelerator(s)\n";
655  }
656  }
657 }
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
acceleratet::restrict_traces
void restrict_traces()
Definition: accelerate.cpp:277
subsumed_patht
Definition: subsumed.h:19
path.h
format
static format_containert< T > format(const T &o)
Definition: format.h:37
overflow_instrumenter.h
acceleratet::accelerate_limit
static const int accelerate_limit
Definition: accelerate.h:54
symbol_table_baset::lookup_ref
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
Definition: symbol_table_base.h:104
acceleratet::utils
acceleration_utilst utils
Definition: accelerate.h:118
loop_analysist::is_loop_header
bool is_loop_header(const T instruction) const
Returns true if instruction is the header of any loop.
Definition: loop_analysis.h:93
find_symbols
static bool find_symbols(symbol_kindt, const typet &, std::function< bool(const symbol_exprt &)>, std::unordered_set< irep_idt > &bindings)
Definition: find_symbols.cpp:122
acceleratet::insert_looping_path
void insert_looping_path(goto_programt::targett &loop_header, goto_programt::targett &back_jump, goto_programt &looping_path, patht &inserted_path)
Definition: accelerate.cpp:203
arith_tools.h
trace_automatont::accept_states
void accept_states(state_sett &states)
Definition: trace_automaton.h:110
acceleratet::guard_manager
guard_managert & guard_manager
Definition: accelerate.h:114
typet
The type of an expression, extends irept.
Definition: type.h:28
acceleration_utilst::fresh_symbol
symbolt fresh_symbol(std::string base, typet type)
Definition: acceleration_utils.cpp:1248
pathst
std::list< patht > pathst
Definition: path.h:45
symbolt::type
typet type
Type of symbol.
Definition: symbol.h:31
acceleratet::symbol_table
symbol_tablet & symbol_table
Definition: accelerate.h:113
trace_automatont::get_transitions
void get_transitions(sym_mapt &transitions)
Definition: trace_automaton.cpp:346
acceleratet
Definition: accelerate.h:26
if_exprt
The trinary if-then-else operator.
Definition: std_expr.h:2322
goto_programt::update
void update()
Update all indices.
Definition: goto_program.cpp:617
code_declt
A goto_instruction_codet representing the declaration of a local variable.
Definition: goto_instruction_code.h:204
goto_programt::add
targett add(instructiont &&instruction)
Adds a given instruction at the end.
Definition: goto_program.h:709
exprt
Base class for all expressions.
Definition: expr.h:55
acceleratet::message_handler
message_handlert & message_handler
Definition: accelerate.h:57
goto_modelt
Definition: goto_model.h:25
trace_automatont::state_pairt
std::pair< statet, statet > state_pairt
Definition: trace_automaton.h:115
symbolt::base_name
irep_idt base_name
Base (non-scoped) name.
Definition: symbol.h:46
path_nodet
Definition: path.h:22
scratch_program.h
bool_typet
The Boolean type.
Definition: std_types.h:35
trace_automatont::build
void build()
Definition: trace_automaton.cpp:24
path_acceleratort::dirty_vars
std::set< exprt > dirty_vars
Definition: accelerator.h:66
goto_functionst::function_map
function_mapt function_map
Definition: goto_functions.h:29
symbol_exprt
Expression to hold a symbol (variable)
Definition: std_expr.h:112
acceleratet::set_dirty_vars
void set_dirty_vars(path_acceleratort &accelerator)
Definition: accelerate.cpp:317
acceleratet::subsumed
subsumed_pathst subsumed
Definition: accelerate.h:117
equal_exprt
Equality.
Definition: std_expr.h:1305
goto_programt::make_assignment
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
Definition: goto_program.h:1056
trace_automatont::sym_range_pairt
std::pair< sym_mapt::iterator, sym_mapt::iterator > sym_range_pairt
Definition: trace_automaton.h:117
unsigned_poly_type
unsignedbv_typet unsigned_poly_type()
Definition: util.cpp:25
goto_programt::make_goto
static instructiont make_goto(targett _target, const source_locationt &l=source_locationt::nil())
Definition: goto_program.h:1030
acceleratet::is_underapproximate
bool is_underapproximate(path_acceleratort &accelerator)
Definition: accelerate.cpp:410
symbolt::pretty_name
irep_idt pretty_name
Language-specific display name.
Definition: symbol.h:52
output_path
void output_path(const patht &path, std::ostream &str)
Definition: path.cpp:16
acceleratet::accelerate_loop
int accelerate_loop(goto_programt::targett &loop_header)
Definition: accelerate.cpp:84
goto_programt::targetst
std::list< targett > targetst
Definition: goto_program.h:588
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
guard_expr_managert
This is unused by this implementation of guards, but can be used by other implementations of the same...
Definition: guard_expr.h:19
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
trace_automatont::add_path
void add_path(patht &path)
Definition: trace_automaton.cpp:69
goto_programt::insert_before
targett insert_before(const_targett target)
Insertion before the instruction pointed-to by the given instruction iterator target.
Definition: goto_program.h:662
trace_automatont
Definition: trace_automaton.h:88
find_symbols.h
goto_programt::destructive_insert
void destructive_insert(const_targett target, goto_programt &p)
Inserts the given program p before target.
Definition: goto_program.h:700
scratch_programt
Definition: scratch_program.h:61
goto_programt::make_skip
static instructiont make_skip(const source_locationt &l=source_locationt::nil())
Definition: goto_program.h:882
typet::source_location
const source_locationt & source_location() const
Definition: type.h:90
symbol_exprt::get_identifier
const irep_idt & get_identifier() const
Definition: std_expr.h:142
trace_automatont::alphabet
alphabett alphabet
Definition: trace_automaton.h:127
acceleratet::add_dirty_checks
void add_dirty_checks()
Definition: accelerate.cpp:348
symbolt::symbol_expr
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
Definition: symbol.cpp:121
path_acceleratort::path
patht path
Definition: accelerator.h:62
path_acceleratort::overflow_path
goto_programt overflow_path
Definition: accelerator.h:64
loop_templatet
A loop, specified as a set of instructions.
Definition: loop_analysis.h:23
path_acceleratort
Definition: accelerator.h:26
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:222
accelerate.h
scratch_programt::assume
targett assume(const exprt &guard)
Definition: scratch_program.cpp:109
path_acceleratort::pure_accelerator
goto_programt pure_accelerator
Definition: accelerator.h:63
message_handlert
Definition: message.h:27
subsumed_patht::residue
patht residue
Definition: subsumed.h:30
false_exprt
The Boolean constant false.
Definition: std_expr.h:3016
disjunctive_polynomial_accelerationt::accelerate
bool accelerate(path_acceleratort &accelerator)
Definition: disjunctive_polynomial_acceleration.cpp:37
overflow_instrumentert
Definition: overflow_instrumenter.h:24
acceleratet::program
goto_programt & program
Definition: accelerate.h:111
SKIP
@ SKIP
Definition: goto_program.h:38
std_code.h
disjunctive_polynomial_accelerationt
Definition: disjunctive_polynomial_acceleration.h:30
trace_automatont::sym_mapt
std::multimap< goto_programt::targett, state_pairt > sym_mapt
Definition: trace_automaton.h:116
acceleratet::make_symbol
symbolt make_symbol(std::string name, typet type)
Definition: accelerate.cpp:436
side_effect_expr_nondett
A side_effect_exprt that returns a non-deterministically chosen value.
Definition: std_code.h:1519
subsumed_patht::accelerator
patht accelerator
Definition: subsumed.h:29
symbol_table_baset::add
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
Definition: symbol_table_base.cpp:18
goto_programt::instructions
instructionst instructions
The list of instructions in the goto program.
Definition: goto_program.h:592
acceleratet::overflow_locs
overflow_mapt overflow_locs
Definition: accelerate.h:122
format_expr.h
goto_modelt::goto_functions
goto_functionst goto_functions
GOTO functions.
Definition: goto_model.h:33
trace_automatont::init_state
statet init_state()
Definition: trace_automaton.h:105
acceleratet::accelerate_loops
int accelerate_loops()
Definition: accelerate.cpp:608
patht
std::list< path_nodet > patht
Definition: path.h:44
accelerator.h
symbolt
Symbol table entry.
Definition: symbol.h:27
from_integer
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Definition: arith_tools.cpp:100
natural_loops.h
acceleratet::insert_accelerator
void insert_accelerator(goto_programt::targett &loop_header, goto_programt::targett &back_jump, path_acceleratort &accelerator, subsumed_patht &subsumed_path)
Definition: accelerate.cpp:177
acceleratet::find_back_jump
goto_programt::targett find_back_jump(goto_programt::targett loop_header)
Definition: accelerate.cpp:37
accelerate_functions
void accelerate_functions(goto_modelt &goto_model, message_handlert &message_handler, bool use_z3, guard_managert &guard_manager)
Definition: accelerate.cpp:637
goto_functions.h
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:72
acceleratet::decl
void decl(symbol_exprt &sym, goto_programt::targett t)
Definition: accelerate.cpp:450
loop_templatet::insert_instruction
bool insert_instruction(const T instruction)
Adds instruction to this loop.
Definition: loop_analysis.h:74
goto_programt::insert_after
targett insert_after(const_targett target)
Insertion after the instruction pointed-to by the given instruction iterator target.
Definition: goto_program.h:678
acceleratet::ns
namespacet ns
Definition: accelerate.h:115
goto_programt::make_assumption
static instructiont make_assumption(const exprt &g, const source_locationt &l=source_locationt::nil())
Definition: goto_program.h:936
acceleratet::insert_automaton
void insert_automaton(trace_automatont &automaton)
Definition: accelerate.cpp:469
enumerating_loop_acceleration.h
acceleratet::build_state_machine
void build_state_machine(trace_automatont::sym_mapt::iterator p, trace_automatont::sym_mapt::iterator end, state_sett &accept_states, symbol_exprt state, symbol_exprt next_state, scratch_programt &state_machine)
Definition: accelerate.cpp:511
goto_programt::insert_before_swap
void insert_before_swap(targett target)
Insertion that preserves jumps to "target".
Definition: goto_program.h:613
code_assignt
A goto_instruction_codet representing an assignment in the program.
Definition: goto_instruction_code.h:22
true_exprt
The Boolean constant true.
Definition: std_expr.h:3007
symbolt::module
irep_idt module
Name of module the symbol belongs to.
Definition: symbol.h:43
goto_programt::instructiont
This class represents an instruction in the GOTO intermediate representation.
Definition: goto_program.h:180
std_expr.h
scratch_programt::assign
targett assign(const exprt &lhs, const exprt &rhs)
Definition: scratch_program.cpp:102
acceleratet::natural_loops
natural_loops_mutablet natural_loops
Definition: accelerate.h:116
util.h
exprt::source_location
const source_locationt & source_location() const
Definition: expr.h:211
trace_automatont::num_states
unsigned num_states()
Definition: trace_automaton.h:121
symbolt::name
irep_idt name
The unique identifier.
Definition: symbol.h:40
acceleratet::goto_functions
goto_functionst & goto_functions
Definition: accelerate.h:112
overflow_instrumentert::add_overflow_checks
void add_overflow_checks()
Definition: overflow_instrumenter.cpp:29
acceleratet::dirty_vars_map
expr_mapt dirty_vars_map
Definition: accelerate.h:124
goto_programt::targett
instructionst::iterator targett
Definition: goto_program.h:586
loop_analysist::loop_map
loop_mapt loop_map
Definition: loop_analysis.h:88
state_sett
std::set< statet > state_sett
Definition: trace_automaton.h:25
acceleratet::make_overflow_loc
void make_overflow_loc(goto_programt::targett loop_header, goto_programt::targett &loop_end, goto_programt::targett &overflow_loc)
Definition: accelerate.cpp:234
acceleratet::contains_nested_loops
bool contains_nested_loops(goto_programt::targett &loop_header)
Definition: accelerate.cpp:58
enumerating_loop_accelerationt
Definition: enumerating_loop_acceleration.h:28
not_exprt
Boolean negation.
Definition: std_expr.h:2277