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