LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
color.hh
Go to the documentation of this file.
1 
6 #ifndef REGALLOC_COLOR_HH
7 # define REGALLOC_COLOR_HH
8 
9 # include <vector>
10 # include <map>
11 
12 # include <temp/fwd.hh>
13 
14 # include <liveness/flowgraph.hh>
16 
17 // FIXME: should be libtarget.hh
18 # include <target/target.hh>
19 
20 namespace regalloc
21 {
23  class Color
24  {
25  // Shortand typedefs
26  public:
29 
32  typedef std::list<node_type> node_list_type;
33 
36 
39  typedef std::vector<move_set_type> move_list_map_type;
40 
42  typedef std::vector<temp::Temp> color_map_type;
43 
45  typedef std::vector<node_type> alias_map_type;
46 
49  public:
53  Color(assem::ProcFrag& frag, const target::Cpu& cpu,
54  const temp::TempMap& tempmap,
55  bool coalesce_p = false, bool trace_p = false);
60  public:
61  // The color timer.
62  const misc::timer& timer_get() const;
68  protected:
70  void import_nodes();
71 
73  void import_moves();
74 
76  void precolor();
77 
83  void priorities_compute();
84 
87  void degrees_compute();
93  void add_edge(const node_type u, const node_type v);
94 
97  void make_work_list(const node_type n);
98 
100  void make_work_list();
101 
107  node_set_type adjacent(const node_type n) const;
108 
115  bool adjacent(const node_type a, const node_type b) const;
116 
118  move_set_type node_moves(const node_type n) const;
119 
121  bool move_related(const node_type n) const;
122 
130  bool coalesce_briggs_p(const node_type a, const node_type b) const;
131 
138  bool coalesce_george_p(const node_type a, const node_type b) const;
142 
143  void coalesce();
144 
148  void add_work_list(const node_type u);
149 
150  protected:
153  node_type get_alias(const node_type a) const;
154 
162  void combine(const node_type u, const node_type v);
163 
165  void freeze_moves(const node_type u);
166 
168  void freeze();
169 
171  void select_spill();
172 
173 
175  void simplify();
176 
202  void decrement_degree(node_type n);
203 
212  void enable_moves(node_type n);
213 
215  void enable_moves(const node_set_type& nodes);
216 
217  void assign_color(node_type n);
218 
228  void assign_colors();
229 
230  public:
234  bool operator()();
235 
238  public:
240  const temp::temp_set_type spilled_get() const;
241 
245  temp::TempMap tempmap_get() const;
251  protected:
253  void trace(const std::string& what, const node_type& n) const;
254 
256  void trace(const std::string& what, const move_type& m) const;
257 
260  void dump(std::ostream& ostr, const node_type& n) const;
261 
263  void dump(std::ostream& ostr, const node_set_type& s) const;
264 
266  void dump(std::ostream& ostr, const node_list_type& s) const;
267 
270  void dump(std::ostream& ostr, const move_type& s) const;
271 
273  void dump(std::ostream& ostr, const move_set_type& s) const;
274 
276  void dump(std::ostream& ostr) const;
281  protected:
284 
287 
289  size_t nb_regs_;
290 
293 
295  bool trace_p_;
296 
299 
307 
309 
313 
317 
321 
325 
329 
334 
337 
342 
352 
354 
357 
361 
364 
367 
374 
375  std::vector<size_t> degree_;
376 
380 
384 
389 
393 
394  std::map<temp::Temp, int> temps_priority_;
395 
396 
399  private:
403  };
404 
405 } // namespace regalloc
406 
407 
408 # undef DO
409 
410 #endif // !REGALLOC_COLOR_HH