Skip to content

Commit 9d231f7

Browse files
Document renaming_level struct
1 parent ada420d commit 9d231f7

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/goto-symex/renaming_level.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,43 @@ Author: Romain Brenguier, [email protected]
1818
#include <util/irep.h>
1919
#include <util/ssa_expr.h>
2020

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.
2125
struct renaming_levelt
2226
{
2327
virtual ~renaming_levelt() = default;
2428

29+
/// Map identifier to ssa_exprt and counter
2530
typedef std::map<irep_idt, std::pair<ssa_exprt, unsigned>> current_namest;
2631
current_namest current_names;
2732

33+
/// Counter corresponding to an identifier
2834
unsigned current_count(const irep_idt &identifier) const
2935
{
3036
const auto it = current_names.find(identifier);
3137
return it == current_names.end() ? 0 : it->second.second;
3238
}
3339

40+
/// Increase the counter corresponding to an identifier
3441
void increase_counter(const irep_idt &identifier)
3542
{
3643
PRECONDITION(current_names.find(identifier) != current_names.end());
3744
++current_names[identifier].second;
3845
}
3946

47+
/// Add the \c ssa_exprt of current_names to vars
4048
void get_variables(std::unordered_set<ssa_exprt, irep_hash> &vars) const
4149
{
4250
for(const auto &pair : current_names)
4351
vars.insert(pair.second.first);
4452
}
4553
};
4654

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.
4958
struct symex_level0t : public renaming_levelt
5059
{
5160
void
@@ -55,20 +64,23 @@ struct symex_level0t : public renaming_levelt
5564
~symex_level0t() override = default;
5665
};
5766

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
6170
struct symex_level1t : public renaming_levelt
6271
{
6372
void operator()(ssa_exprt &ssa_expr);
6473

74+
/// Insert the content of \p other into this renaming
6575
void restore_from(const current_namest &other);
6676

6777
symex_level1t() = default;
6878
~symex_level1t() override = default;
6979
};
7080

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.
7284
struct symex_level2t : public renaming_levelt
7385
{
7486
symex_level2t() = default;

0 commit comments

Comments
 (0)