Correct typo in comment.
[libfirm] / ir / be / be_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 backend global data structures.
23  * @author  Sebastian Hack
24  */
25 #ifndef FIRM_BE_BE_T_H
26 #define FIRM_BE_BE_T_H
27
28 #include "firm_types.h"
29 #include "obst.h"
30 #include "debug.h"
31 #include "bitset.h"
32 #include "timing.h"
33 #include "pmap.h"
34
35 #include "be.h"
36 #include "be_types.h"
37
38 enum {
39         DUMP_NONE     = 0,
40         DUMP_INITIAL  = 1 << 0,
41         DUMP_ABI      = 1 << 1,
42         DUMP_SCHED    = 1 << 2,
43         DUMP_PREPARED = 1 << 3,
44         DUMP_RA       = 1 << 4,
45         DUMP_FINAL    = 1 << 5,
46         DUMP_BE       = 1 << 6
47 };
48
49 enum {
50         BE_TIME_OFF,
51         BE_TIME_ON
52 };
53
54 enum {
55         BE_VERIFY_OFF,
56         BE_VERIFY_WARN,
57         BE_VERIFY_ASSERT
58 };
59
60 /** Backend options */
61 struct be_options_t {
62         unsigned dump_flags;       /**< backend dumping flags */
63         int  timing;               /**< time the backend phases */
64         int  opt_profile_generate; /**< instrument code for profiling */
65         int  opt_profile_use;      /**< use existing profile data */
66         int  omit_fp;              /**< try to omit the frame pointer */
67         int  pic;                  /**< create position independent code */
68         int  verify_option;        /**< backend verify option */
69         char ilp_server[128];      /**< the ilp server name */
70         char ilp_solver[128];      /**< the ilp solver name */
71         int  statev;               /**< enable stat event dumping */
72         char filtev[128];          /**< filter mask for stat events */
73 };
74
75 struct be_main_env_t {
76         arch_env_t   *arch_env;
77         FILE         *file_handle;
78         be_options_t *options;              /**< backend options */
79         const char   *cup_name;             /**< name of the compilation unit */
80         pmap         *ent_trampoline_map;   /**< A map containing PIC trampolines for methods. */
81         ir_type      *pic_trampolines_type; /**< Class type containing all trampolines */
82         pmap         *ent_pic_symbol_map;
83         ir_type      *pic_symbols_type;
84 };
85
86 extern asm_constraint_flags_t asm_constraint_flags[256];
87
88 void be_init_default_asm_constraint_flags(void);
89
90 void be_put_allocatable_regs(const ir_graph *irg,
91                              const arch_register_class_t *cls, bitset_t *bs);
92
93 void be_set_allocatable_regs(const ir_graph *irg,
94                              const arch_register_class_t *cls,
95                              unsigned *raw_bitset);
96
97 unsigned be_get_n_allocatable_regs(const ir_graph *irg,
98                                    const arch_register_class_t *cls);
99
100 /**
101  * Initialize the backend. Must be run first in init_firm();
102  */
103 void firm_be_init(void);
104 void firm_be_finish(void);
105
106 extern int be_timing;
107
108 typedef enum {
109         T_FIRST,
110         T_ABI = T_FIRST,
111         T_CODEGEN,
112         T_RA_PREPARATION,
113         T_SCHED,
114         T_CONSTR,
115         T_SPLIT,
116         T_FINISH,
117         T_EMIT,
118         T_VERIFY,
119         T_OTHER,
120         T_HEIGHTS,
121         T_LIVE,
122         T_EXECFREQ,
123         T_SSA_CONSTR,
124         T_RA_PROLOG,
125         T_RA_EPILOG,
126         T_RA_CONSTR,
127         T_RA_SPILL,
128         T_RA_SPILL_APPLY,
129         T_RA_COLOR,
130         T_RA_IFG,
131         T_RA_COPYMIN,
132         T_RA_SSA,
133         T_RA_OTHER,
134         T_LAST = T_RA_OTHER
135 } be_timer_id_t;
136 ENUM_COUNTABLE(be_timer_id_t)
137 extern ir_timer_t *be_timers[T_LAST+1];
138
139 static inline void be_timer_push(be_timer_id_t id)
140 {
141         int res;
142         if (!be_timing)
143                 return;
144
145         assert(id <= T_LAST);
146         res = ir_timer_push(be_timers[id]);
147         (void) res;
148         assert(res && "Timer already on stack, cannot be pushed twice.");
149 }
150
151 static inline void be_timer_pop(be_timer_id_t id)
152 {
153         ir_timer_t *tmp;
154         if (!be_timing)
155                 return;
156
157         tmp = ir_timer_pop();
158         (void) tmp;
159         (void) id;
160         assert(tmp == be_timers[id] && "Attempt to pop wrong timer.");
161 }
162
163 #endif