CBMC
unwindset.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Loop unwinding setup
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_GOTO_INSTRUMENT_UNWINDSET_H
13 #define CPROVER_GOTO_INSTRUMENT_UNWINDSET_H
14 
16 
17 #include <list>
18 #include <map>
19 #include <string>
20 
21 class message_handlert;
22 
24 {
25 public:
26  // We have
27  // 1) a global limit
28  // 2) a limit per loop, all threads
29  // 3) a limit for a particular thread.
30  // We use the most specific of the above.
32  {
33  }
34 
35  // global limit for all loops
36  void parse_unwind(const std::string &unwind);
37 
38  // limit for instances of a loop
39  void parse_unwindset(
40  const std::list<std::string> &unwindset,
41  message_handlert &message_handler);
42 
43  // queries
44  optionalt<unsigned> get_limit(const irep_idt &loop, unsigned thread_id) const;
45 
46  // read unwindset directives from a file
48  const std::string &file_name,
49  message_handlert &message_handler);
50 
51 protected:
53 
55 
56  // Limit for all instances of a loop.
57  // This may have 'no value'.
58  typedef std::map<irep_idt, optionalt<unsigned>> loop_mapt;
60 
61  // separate limits per thread
62  using thread_loop_mapt =
63  std::map<std::pair<irep_idt, unsigned>, optionalt<unsigned>>;
65 
67  std::string loop_limit,
68  message_handlert &message_handler);
69 };
70 
71 #define OPT_UNWINDSET \
72  "(show-loops)" \
73  "(unwind):" \
74  "(unwindset):"
75 
76 #define HELP_UNWINDSET \
77  " --show-loops show the loops in the program\n" \
78  " --unwind nr unwind nr times\n" \
79  " --unwindset [T:]L:B,... unwind loop L with a bound of B\n" \
80  " (optionally restricted to thread T)\n" \
81  " (use --show-loops to get the loop IDs)\n"
82 
83 #endif // CPROVER_GOTO_INSTRUMENT_UNWINDSET_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
unwindsett::parse_unwindset_file
void parse_unwindset_file(const std::string &file_name, message_handlert &message_handler)
Definition: unwindset.cpp:207
thread_id
const std::string thread_id
Definition: java_bytecode_concurrency_instrumentation.cpp:24
goto_model.h
unwindsett::thread_loop_map
thread_loop_mapt thread_loop_map
Definition: unwindset.h:64
unwindsett::parse_unwindset
void parse_unwindset(const std::list< std::string > &unwindset, message_handlert &message_handler)
Definition: unwindset.cpp:177
unwindsett::parse_unwind
void parse_unwind(const std::string &unwind)
Definition: unwindset.cpp:22
unwindsett::get_limit
optionalt< unsigned > get_limit(const irep_idt &loop, unsigned thread_id) const
Definition: unwindset.cpp:186
unwindsett::goto_model
abstract_goto_modelt & goto_model
Definition: unwindset.h:52
unwindsett
Definition: unwindset.h:23
message_handlert
Definition: message.h:27
unwindsett::parse_unwindset_one_loop
void parse_unwindset_one_loop(std::string loop_limit, message_handlert &message_handler)
Definition: unwindset.cpp:28
unwindsett::loop_map
loop_mapt loop_map
Definition: unwindset.h:59
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
unwindsett::loop_mapt
std::map< irep_idt, optionalt< unsigned > > loop_mapt
Definition: unwindset.h:58
unwindsett::thread_loop_mapt
std::map< std::pair< irep_idt, unsigned >, optionalt< unsigned > > thread_loop_mapt
Definition: unwindset.h:63
unwindsett::unwindsett
unwindsett(abstract_goto_modelt &goto_model)
Definition: unwindset.h:31
abstract_goto_modelt
Abstract interface to eager or lazy GOTO models.
Definition: abstract_goto_model.h:20
unwindsett::global_limit
optionalt< unsigned > global_limit
Definition: unwindset.h:54