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