18
18
#include < util/irep.h>
19
19
#include < util/ssa_expr.h>
20
20
21
+ // / Wrapper for a \c current_names map, which maps each identifier to an SSA
22
+ // / expression and a counter.
23
+ // / This is extended by the different symex_level structures which are used
24
+ // / during symex to ensure static single assignment (SSA) form.
21
25
struct renaming_levelt
22
26
{
23
27
virtual ~renaming_levelt () = default ;
24
28
29
+ // / Map identifier to ssa_exprt and counter
25
30
typedef std::map<irep_idt, std::pair<ssa_exprt, unsigned >> current_namest;
26
31
current_namest current_names;
27
32
33
+ // / Counter corresponding to an identifier
28
34
unsigned current_count (const irep_idt &identifier) const
29
35
{
30
36
const auto it = current_names.find (identifier);
31
37
return it == current_names.end () ? 0 : it->second .second ;
32
38
}
33
39
40
+ // / Increase the counter corresponding to an identifier
34
41
void increase_counter (const irep_idt &identifier)
35
42
{
36
43
PRECONDITION (current_names.find (identifier) != current_names.end ());
37
44
++current_names[identifier].second ;
38
45
}
39
46
47
+ // / Add the \c ssa_exprt of current_names to vars
40
48
void get_variables (std::unordered_set<ssa_exprt, irep_hash> &vars) const
41
49
{
42
50
for (const auto &pair : current_names)
43
51
vars.insert (pair.second .first );
44
52
}
45
53
};
46
54
47
- // level 0 -- threads!
48
- // renaming built for one particular interleaving
55
+ // / Functor to set the level 0 renaming of SSA expressions.
56
+ // / Level 0 corresponds to threads.
57
+ // / The renaming is built for one particular interleaving.
49
58
struct symex_level0t : public renaming_levelt
50
59
{
51
60
void
@@ -55,20 +64,23 @@ struct symex_level0t : public renaming_levelt
55
64
~symex_level0t () override = default ;
56
65
};
57
66
58
- // level 1 -- function frames
59
- // this is to preserve locality in case of recursion
60
-
67
+ // / Functor to set the level 1 renaming of SSA expressions.
68
+ // / Level 1 corresponds to function frames.
69
+ // / This is to preserve locality in case of recursion
61
70
struct symex_level1t : public renaming_levelt
62
71
{
63
72
void operator ()(ssa_exprt &ssa_expr);
64
73
74
+ // / Insert the content of \p other into this renaming
65
75
void restore_from (const current_namest &other);
66
76
67
77
symex_level1t () = default ;
68
78
~symex_level1t () override = default ;
69
79
};
70
80
71
- // level 2 -- SSA
81
+ // / Functor to set the level 2 renaming of SSA expressions.
82
+ // / Level 2 corresponds to SSA.
83
+ // / This is to ensure each variable is only assigned once.
72
84
struct symex_level2t : public renaming_levelt
73
85
{
74
86
symex_level2t () = default ;
0 commit comments