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