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