ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
set_property.h
Go to the documentation of this file.
1 
2 #ifndef BDWY_SET_PROPERTY_H
3 #define BDWY_SET_PROPERTY_H
4 
5 typedef std::map< std::string, setPropertyAnn *> set_property_map;
6 typedef set_property_map::iterator set_property_map_p;
7 typedef set_property_map::const_iterator set_property_map_cp;
8 
9 // -- NOTE: By choosing 1024 here, we are fixing the maximum size of sets
10 // and equivalence classes.
11 
12 typedef std::bitset< 1024 > memoryblock_bitset;
13 
15 {
16 public:
17 
18  typedef enum { Set, Equivalence } SetPropertyKind;
19 
20  typedef enum { Union, Intersect } MeetFunction;
21 
22  // -- Manage the mapping from memoryblocks to bit positions
23 
24 #ifdef __FOO
25  typedef std::map< memoryBlock *, int > memoryblock_position_map;
26  typedef memoryblock_position_map::iterator memoryblock_position_map_p;
27 
28  // -- Store the memoryBlocks in a vector to create the reverse mapping
29 
30  typedef vector< memoryBlock * > memoryblock_vector;
31  typedef memoryblock_vector::iterator memoryblock_vector_p;
32 
33  // -- Set representation: map from program points to sets of blocks
34 
35  typedef std::map< memoryAccess *, memoryblock_bitset > set_property_map;
36  typedef set_property_map::iterator set_property_map_p;
37 
38  // -- Equivalence representation: map from program points to lists of
39  // sets of blocks. Each set of blocks in the list represents an
40  // equivalence class.
41 
42  typedef list< memoryblock_bitset > memoryblock_bitset_list;
43  typedef memoryblock_bitset_list::iterator memoryblock_bitset_list_p;
44  typedef memoryblock_bitset_list::const_iterator memoryblock_bitset_list_cp;
45 
46  typedef std::map< memoryAccess *, memoryblock_bitset_list> equiv_property_map;
47  typedef equiv_property_map::iterator equiv_property_map_p;
48 #endif
49 private:
50 
54 
58 
66 
72 #ifdef __FOO
73  memoryBlock * _block;
74 
79  set_property_map _set;
80 
85  equiv_property_map _equivalence;
86 
89  memoryblock_position_map _position_of_memoryblock;
90 
93  memoryblock_vector _memoryblock_at_position;
94 
101  bool _change;
102 #endif
103 public:
104 
109  setPropertyAnn(const parserID * name,
112  MeetFunction meet);
113 
119  void clear();
120 
123  inline SetPropertyKind kind() const { return _kind; }
124 
127  inline MeetFunction meet_function() const { return _meet_function; }
128 
135  { _property_variable = var; }
136 
142  inline annVariable * property_variable() const { return _property_variable; }
143 
148 #ifdef __FOO
149  void set_property_variable_block(memoryBlock * block)
150  { _block = block; }
151 
157  memoryBlock * property_variable_block() const { return _block; }
158 
163  //{
164 
170  void to_top(memoryblock_bitset & bits);
171 
178  void to_bottom(memoryblock_bitset & bits);
179 
184  void meet(memoryblock_bitset & dest,
185  memoryblock_bitset & src);
186 
192  void lookup_set_value(memoryAccess * def_or_use,
193  memoryblock_bitset & bits);
194 
201  bool update_set_value(memoryAccess * def_or_use,
202  memoryblock_bitset & new_set);
203 
217  void current_set_value(memoryblock_bitset & bits,
218  bool & found_reaching_value);
219 
225  bool update_current_set_value(memoryblock_bitset & new_set);
226 
232  bool is_element_of(pointerValue & var);
233 
238  bool is_emptyset();
239 
244  void add_elements(pointerValue & var);
245 
254  void apply_set_merge(memoryuse_list & phi_uses,
255  memoryblock_set & changes);
256  //}
257 
262  //{
263 
268  void to_top(memoryblock_bitset_list & bits);
269 
274  void to_bottom(memoryblock_bitset_list & bits);
275 
280  void meet(memoryblock_bitset_list & dest,
281  const memoryblock_bitset_list & src);
282 
288  void lookup_equivalence_classes(memoryAccess * def_or_use,
289  memoryblock_bitset_list & bits);
290 
297  bool update_equivalence_classes(memoryAccess * def_or_use,
298  memoryblock_bitset_list & classes);
299 
308  void current_equivalence_classes(memoryblock_bitset_list & bits,
309  bool & found_reaching_value);
310 
317  bool update_current_equivalence_classes(memoryblock_bitset_list & new_set);
318 
323  bool is_equivalent(pointerValue & left,
324  pointerValue & right);
325 
330  void add_equivalence(pointerValue & left,
331  pointerValue & right);
332 
337  void apply_equivalence_merge(memoryuse_list & phi_uses,
338  memoryblock_set & changes);
339 
340  //}
341 
348  void apply_next(memoryblock_set & changes);
349 
355  void apply_merge(memoryuse_list & phi_uses,
356  memoryblock_set & changes);
357 
364  void self_assignment(memoryblock_set & changes);
365 
370  void report(std::ostream & out);
371 #endif /* __FOO */
372 
374  friend std::ostream& operator<<(std::ostream & o, const setPropertyAnn & anns) {
375  anns.print(o);
376  return o;
377  }
378 
381  void print(std::ostream & o) const;
382 
383 private:
384 
388 #ifdef __FOO
389  void build_memoryblock_bitset(pointerValue & variables,
390  memoryblock_bitset & bits);
391 
397  void add_equivalence_class(memoryblock_bitset_list & equiv,
398  const memoryblock_bitset & new_class);
399 
404  bool is_same_equivalence(memoryblock_bitset_list & equiv1,
405  memoryblock_bitset_list & equiv2);
406 
409  void print_memoryblock_bitset(const std::string & label,
410  memoryblock_bitset & bits,
411  std::ostream & out);
414  void print_memoryblock_bitset_list(const std::string & label,
415  memoryblock_bitset_list & bits,
416  std::ostream & out);
417 #endif /* __FOO */
418 };
419 
420 #endif