- placed phi_handler into the be_main environment, removing unnecessary allocations
[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 "bearch_t.h"
38 #include "beirg.h"
39
40 #define DUMP_NONE       0
41 #define DUMP_INITIAL    (1 << 0)
42 #define DUMP_ABI        (1 << 1)
43 #define DUMP_SCHED      (1 << 2)
44 #define DUMP_PREPARED   (1 << 3)
45 #define DUMP_RA         (1 << 4)
46 #define DUMP_FINAL      (1 << 5)
47 #define DUMP_BE         (1 << 6)
48
49 enum {
50         BE_TIME_OFF,
51         BE_TIME_ON
52 };
53
54 enum {
55         BE_VRFY_OFF,
56         BE_VRFY_WARN,
57         BE_VRFY_ASSERT
58 };
59
60 enum {
61         BE_SCHED_LIST,
62         BE_SCHED_ILP
63 };
64
65 /** Backend options */
66 struct be_options_t {
67         unsigned dump_flags;      /**< backend dumping flags */
68         int  timing;              /**< time the backend phases */
69         int  opt_profile;         /**< instrument code for profiling */
70         int  omit_fp;             /**< try to omit the frame pointer */
71         int  pic;                 /**< create position independent code */
72         int  gprof;               /**< create gprof compatible profiling code */
73         int  vrfy_option;         /**< backend verify option */
74         int  scheduler;           /**< the scheduler */
75         char target_os[128];      /**< target operating system name */
76         char ilp_server[128];     /**< the ilp server name */
77         char ilp_solver[128];     /**< the ilp solver name */
78         int  statev;              /**< enable stat event dumping */
79         char filtev[128];         /**< filter mask for stat events (regex is supported) */
80 };
81
82 typedef struct {
83         arch_irn_handler_t irn_handler;
84         arch_irn_ops_t     irn_ops;
85         const arch_env_t   *arch_env;
86         pmap               *phi_attrs;
87 } phi_handler_t;
88
89 struct be_main_env_t {
90         arch_env_t            arch_env;
91         be_options_t          *options;              /**< backend options */
92         arch_code_generator_t *cg;
93         const char            *cup_name;             /**< name of the compilation unit */
94         pmap                  *ent_trampoline_map;   /**< A map containing PIC trampolines for methods. */
95         ir_type               *pic_trampolines_type; /**< Class type containing all trampolines */
96         pmap                  *ent_pic_symbol_map;
97         ir_type               *pic_symbols_type;
98         phi_handler_t         phi_handler;
99 };
100
101 /**
102 * Put the registers to be ignored in this IRG into a bitset.
103 * @param birg The backend IRG data structure.
104 * @param cls  The register class.
105 * @param bs   The bitset (may be NULL).
106 * @return The number of registers to be ignored.
107 */
108 unsigned be_put_ignore_regs(const be_irg_t *birg,
109                 const arch_register_class_t *cls, bitset_t *bs);
110
111 extern int be_timing;
112
113 #define BE_TIMER_PUSH(timer)                                              \
114     if (be_timing) {                                                      \
115         int res = ir_timer_push(timer);                                   \
116         (void) res;                                                       \
117                 assert(res && "Timer already on stack, cannot be pushed twice."); \
118     }
119
120 #define BE_TIMER_POP(timer)                                               \
121     if (be_timing) {                                                      \
122         ir_timer_t *tmp = ir_timer_pop();                                 \
123         (void) tmp;                                                       \
124         assert(tmp == timer && "Attempt to pop wrong timer.");            \
125     }
126
127 extern ir_timer_t *t_abi;
128 extern ir_timer_t *t_codegen;
129 extern ir_timer_t *t_sched;
130 extern ir_timer_t *t_constr;
131 extern ir_timer_t *t_finish;
132 extern ir_timer_t *t_emit;
133 extern ir_timer_t *t_other;
134 extern ir_timer_t *t_execfreq;
135 extern ir_timer_t *t_verify;
136 extern ir_timer_t *t_heights;
137 extern ir_timer_t *t_live;         /**< timer for liveness calculation */
138 extern ir_timer_t *t_ssa_constr;   /**< timer for ssa reconstruction */
139 extern ir_timer_t *t_ra_prolog;    /**< timer for prolog */
140 extern ir_timer_t *t_ra_epilog;    /**< timer for epilog */
141 extern ir_timer_t *t_ra_constr;    /**< timer for spill constraints */
142 extern ir_timer_t *t_ra_spill;     /**< timer for spilling */
143 extern ir_timer_t *t_ra_spill_apply;
144 extern ir_timer_t *t_ra_color;     /**< timer for graph coloring */
145 extern ir_timer_t *t_ra_ifg;       /**< timer for building interference graph */
146 extern ir_timer_t *t_ra_copymin;   /**< timer for copy minimization */
147 extern ir_timer_t *t_ra_ssa;       /**< timer for ssa destruction */
148 extern ir_timer_t *t_ra_other;     /**< timer for remaining stuff */
149
150 #endif /* FIRM_BE_BE_T_H */