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