b7af46b094c50f8185d7c804af415eb8c5ff2a6d
[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 <libcore/lc_timing.h>
30
31 #include "firm_types.h"
32 #include "obst.h"
33 #include "debug.h"
34 #include "bitset.h"
35
36 #include "be.h"
37 #include "bearch.h"
38 #include "be_dbgout.h"
39 #include "beirg.h"
40
41 #define DUMP_NONE       0
42 #define DUMP_INITIAL    (1 << 0)
43 #define DUMP_ABI        (1 << 1)
44 #define DUMP_SCHED      (1 << 2)
45 #define DUMP_PREPARED   (1 << 3)
46 #define DUMP_RA         (1 << 4)
47 #define DUMP_FINAL      (1 << 5)
48 #define DUMP_BE         (1 << 6)
49
50 enum {
51         BE_TIME_OFF,
52         BE_TIME_ON
53 };
54
55 enum {
56         BE_VRFY_OFF,
57         BE_VRFY_WARN,
58         BE_VRFY_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  stabs_debug_support; /**< enable stabs debugging support */
73         int  vrfy_option;         /**< backend verify option */
74         int  scheduler;           /**< the scheduler */
75         char ilp_server[128];     /**< the ilp server name */
76         char ilp_solver[128];     /**< the ilp solver name */
77         int  statev;              /**< enable stat event dumping */
78         char printev[128];
79 };
80
81 struct be_main_env_t {
82         struct obstack         obst;
83         arch_env_t            *arch_env;
84         be_options_t          *options;
85         arch_code_generator_t *cg;
86         arch_irn_handler_t    *phi_handler;
87         dbg_handle            *db_handle;
88         const char            *cup_name;
89 };
90
91 /**
92 * Put the registers to be ignored in this IRG into a bitset.
93 * @param birg The backend IRG data structure.
94 * @param cls  The register class.
95 * @param bs   The bitset (may be NULL).
96 * @return The number of registers to be ignored.
97 */
98 unsigned be_put_ignore_regs(const be_irg_t *birg,
99                 const arch_register_class_t *cls, bitset_t *bs);
100
101 extern int be_timing;
102
103 #define BE_TIMER_PUSH(timer)                                              \
104     if (be_timing) {                                                      \
105         int res = lc_timer_push(timer);                                   \
106                 assert(res && "Timer already on stack, cannot be pushed twice."); \
107     }
108
109 #define BE_TIMER_POP(timer)                                               \
110     if (be_timing) {                                                      \
111         lc_timer_t *tmp = lc_timer_pop();                                 \
112         assert(tmp == timer && "Attempt to pop wrong timer.");            \
113     }
114
115 extern lc_timer_t *t_abi;
116 extern lc_timer_t *t_codegen;
117 extern lc_timer_t *t_sched;
118 extern lc_timer_t *t_constr;
119 extern lc_timer_t *t_finish;
120 extern lc_timer_t *t_emit;
121 extern lc_timer_t *t_other;
122 extern lc_timer_t *t_verify;
123 extern lc_timer_t *t_heights;
124 extern lc_timer_t *t_live;         /**< timer for liveness calculation */
125 extern lc_timer_t *t_ssa_constr;   /**< timer for ssa reconstruction */
126 extern lc_timer_t *t_ra_prolog;    /**< timer for prolog */
127 extern lc_timer_t *t_ra_epilog;    /**< timer for epilog */
128 extern lc_timer_t *t_ra_constr;    /**< timer for spill constraints */
129 extern lc_timer_t *t_ra_spill;     /**< timer for spilling */
130 extern lc_timer_t *t_ra_spill_apply;
131 extern lc_timer_t *t_ra_color;     /**< timer for graph coloring */
132 extern lc_timer_t *t_ra_ifg;       /**< timer for building interference graph */
133 extern lc_timer_t *t_ra_copymin;   /**< timer for copy minimization */
134 extern lc_timer_t *t_ra_ssa;       /**< timer for ssa destruction */
135 extern lc_timer_t *t_ra_other;     /**< timer for remaining stuff */
136
137 #endif /* FIRM_BE_BE_T_H */