90e4eff0886ea9f67f3b1e111a131b722aabc09c
[libfirm] / ir / be / bechordal_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Internal data structures for the chordal register allocator.
23  * @author      Sebastian Hack
24  * @date        25.01.2005
25  * @version     $Id$
26  */
27 #ifndef FIRM_BE_BECHORDAL_T_H
28 #define FIRM_BE_BECHORDAL_T_H
29
30 #include "firm_types.h"
31 #include "list.h"
32 #include "pmap.h"
33 #include "bitset.h"
34 #include "obst.h"
35 #include "debug.h"
36
37 #include "bechordal.h"
38 #include "beirg.h"
39 #include "beifg.h"
40
41 /** Defines an invalid register index. */
42 #define NO_COLOR (-1)
43
44 /**
45  * A liveness interval border.
46  */
47 struct border_t {
48         DEBUG_ONLY(unsigned magic;)     /**< A magic number for checking. */
49         struct list_head  list;         /**< list head for queuing. */
50         border_t         *other_end;    /**< The other end of the border. */
51         ir_node          *irn;          /**< The node. */
52         unsigned         step;          /**< The number equal to the interval border. */
53         unsigned         pressure;      /**< The pressure at this interval border. (The border itself is counting). */
54         unsigned         is_def  : 1;   /**< Does this border denote a use or a def. */
55         unsigned         is_real : 1;   /**< Is the def/use real? Or is it just
56                                              inserted at block beginnings or ends
57                                              to ensure that inside a block, each
58                                              value has one begin and one end. */
59 };
60
61 /**
62  * Environment for each of the chordal register allocator phases
63  */
64 struct be_chordal_env_t {
65         struct obstack       *obst;         /**< An obstack for temporary storage. */
66         be_ra_chordal_opts_t *opts;         /**< A pointer to the chordal ra options. */
67         be_irg_t             *birg;         /**< Back-end IRG session. */
68         ir_graph             *irg;          /**< The graph under examination. */
69         const arch_register_class_t *cls;   /**< The current register class. */
70         pmap                 *border_heads; /**< Maps blocks to border heads. */
71         be_ifg_t             *ifg;          /**< The interference graph. */
72         bitset_t             *ignore_colors;/**< A set of colors which shall be ignored in register allocation. */
73 };
74
75 static inline struct list_head *_get_block_border_head(const be_chordal_env_t *inf, ir_node *bl) {
76   return pmap_get(inf->border_heads, bl);
77 }
78
79 #define get_block_border_head(info, bl)     _get_block_border_head(info, bl)
80
81 #define foreach_border_head(head, pos)          list_for_each_entry_reverse(border_t, pos, head, list)
82 #define border_next(b)                      (list_entry((b)->list.next, border_t, list))
83 #define border_prev(b)                      (list_entry((b)->list.prev, border_t, list))
84
85 #define chordal_has_class(chordal_env, irn) \
86         arch_irn_consider_in_reg_alloc(chordal_env->cls, irn)
87
88 void be_ra_chordal_color(be_chordal_env_t *chordal_env);
89
90 enum {
91         /* Dump flags */
92         BE_CH_DUMP_NONE       = (1 << 0),
93         BE_CH_DUMP_SPILL      = (1 << 1),
94         BE_CH_DUMP_LIVE       = (1 << 2),
95         BE_CH_DUMP_COLOR      = (1 << 3),
96         BE_CH_DUMP_COPYMIN    = (1 << 4),
97         BE_CH_DUMP_SSADESTR   = (1 << 5),
98         BE_CH_DUMP_TREE_INTV  = (1 << 6),
99         BE_CH_DUMP_CONSTR     = (1 << 7),
100         BE_CH_DUMP_SPILLSLOTS = (1 << 8),
101         BE_CH_DUMP_LOWER      = (1 << 9),
102         BE_CH_DUMP_APPEL      = (1 << 10),
103         BE_CH_DUMP_ALL        = 2 * BE_CH_DUMP_APPEL - 1,
104
105         /* lower perm options */
106         BE_CH_LOWER_PERM_SWAP   = 1,
107         BE_CH_LOWER_PERM_COPY   = 2,
108
109         /* verify options */
110         BE_CH_VRFY_OFF    = 1,
111         BE_CH_VRFY_WARN   = 2,
112         BE_CH_VRFY_ASSERT = 3,
113 };
114
115 struct be_ra_chordal_opts_t {
116         int dump_flags;
117         int lower_perm_opt;
118         int vrfy_option;
119
120         char ilp_server[128];
121         char ilp_solver[128];
122 };
123
124 void check_for_memory_operands(ir_graph *irg);
125
126 #endif /* FIRM_BE_BECHORDAL_T_H */