be_t.h 5.22 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Sebastian Hack's avatar
Sebastian Hack committed
20
/**
Christian Würdig's avatar
Christian Würdig committed
21
22
23
24
 * @file
 * @brief   Internal backend global data structures.
 * @author  Sebastian Hack
 * @version $Id$
Sebastian Hack's avatar
Sebastian Hack committed
25
 */
Christian Würdig's avatar
Christian Würdig committed
26
27
#ifndef FIRM_BE_BE_T_H
#define FIRM_BE_BE_T_H
Sebastian Hack's avatar
Sebastian Hack committed
28

29
#include "firm_types.h"
30
#include "obst.h"
31
#include "debug.h"
Sebastian Hack's avatar
Sebastian Hack committed
32
#include "bitset.h"
Matthias Braun's avatar
Matthias Braun committed
33
#include "timing.h"
34
#include "pmap.h"
35

Sebastian Hack's avatar
Sebastian Hack committed
36
#include "be.h"
37
#include "be_types.h"
Daniel Grund's avatar
Daniel Grund committed
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#define DUMP_NONE       0
#define DUMP_INITIAL    (1 << 0)
#define DUMP_ABI        (1 << 1)
#define DUMP_SCHED      (1 << 2)
#define DUMP_PREPARED   (1 << 3)
#define DUMP_RA         (1 << 4)
#define DUMP_FINAL      (1 << 5)
#define DUMP_BE         (1 << 6)

enum {
	BE_TIME_OFF,
	BE_TIME_ON
};

enum {
	BE_VRFY_OFF,
	BE_VRFY_WARN,
	BE_VRFY_ASSERT
};

59
60
61
62
63
enum {
	BE_SCHED_LIST,
	BE_SCHED_ILP
};

64
/** Backend options */
65
struct be_options_t {
Christian Würdig's avatar
Christian Würdig committed
66
	unsigned dump_flags;      /**< backend dumping flags */
67
68
69
	int  timing;              /**< time the backend phases */
	int  opt_profile;         /**< instrument code for profiling */
	int  omit_fp;             /**< try to omit the frame pointer */
70
	int  omit_leaf_fp;        /**< try to omit the frame pointer in leaf routines */
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
77
	char ilp_server[128];     /**< the ilp server name */
	char ilp_solver[128];     /**< the ilp solver name */
Sebastian Hack's avatar
Sebastian Hack committed
78
	int  statev;              /**< enable stat event dumping */
79
	char filtev[128];         /**< filter mask for stat events (regex is supported) */
Sebastian Hack's avatar
Sebastian Hack committed
80
81
};

82
struct be_main_env_t {
83
	arch_env_t            *arch_env;
84
	be_options_t          *options;              /**< backend options */
85
	arch_code_generator_t *cg;
86
87
88
	const char            *cup_name;             /**< name of the compilation unit */
	pmap                  *ent_trampoline_map;   /**< A map containing PIC trampolines for methods. */
	ir_type               *pic_trampolines_type; /**< Class type containing all trampolines */
89
	pmap                  *ent_pic_symbol_map;
90
	ir_type               *pic_symbols_type;
Sebastian Hack's avatar
Sebastian Hack committed
91
92
};

93
94
95
96
extern unsigned short asm_constraint_flags[256];

void be_init_default_asm_constraint_flags(void);

Sebastian Hack's avatar
Sebastian Hack committed
97
/**
98
99
100
101
102
103
 * Put the registers to be ignored in this IRG into a bitset.
 * @param birg The backend IRG data structure.
 * @param cls  The register class.
 * @param bs   The bitset (may be NULL).
 * @return The number of registers to be ignored.
 */
Matthias Braun's avatar
Matthias Braun committed
104
105
106
unsigned be_put_ignore_regs(const be_irg_t *birg,
		const arch_register_class_t *cls, bitset_t *bs);

107
108
109
110
111

/**
 * Initialize the backend. Must be run first in init_firm();
 */
void firm_be_init(void);
yb9976's avatar
yb9976 committed
112
void firm_be_finish(void);
113

Matthias Braun's avatar
Matthias Braun committed
114
115
116
117
extern int be_timing;

#define BE_TIMER_PUSH(timer)                                              \
    if (be_timing) {                                                      \
Matthias Braun's avatar
Matthias Braun committed
118
        int res = ir_timer_push(timer);                                   \
Matthias Braun's avatar
Matthias Braun committed
119
        (void) res;                                                       \
Matthias Braun's avatar
Matthias Braun committed
120
121
122
123
124
		assert(res && "Timer already on stack, cannot be pushed twice."); \
    }

#define BE_TIMER_POP(timer)                                               \
    if (be_timing) {                                                      \
Matthias Braun's avatar
Matthias Braun committed
125
        ir_timer_t *tmp = ir_timer_pop();                                 \
Matthias Braun's avatar
Matthias Braun committed
126
        (void) tmp;                                                       \
Matthias Braun's avatar
Matthias Braun committed
127
128
129
        assert(tmp == timer && "Attempt to pop wrong timer.");            \
    }

Matthias Braun's avatar
Matthias Braun committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
extern ir_timer_t *t_abi;
extern ir_timer_t *t_codegen;
extern ir_timer_t *t_sched;
extern ir_timer_t *t_constr;
extern ir_timer_t *t_finish;
extern ir_timer_t *t_emit;
extern ir_timer_t *t_other;
extern ir_timer_t *t_execfreq;
extern ir_timer_t *t_verify;
extern ir_timer_t *t_heights;
extern ir_timer_t *t_live;         /**< timer for liveness calculation */
extern ir_timer_t *t_ssa_constr;   /**< timer for ssa reconstruction */
extern ir_timer_t *t_ra_prolog;    /**< timer for prolog */
extern ir_timer_t *t_ra_epilog;    /**< timer for epilog */
extern ir_timer_t *t_ra_constr;    /**< timer for spill constraints */
extern ir_timer_t *t_ra_spill;     /**< timer for spilling */
extern ir_timer_t *t_ra_spill_apply;
extern ir_timer_t *t_ra_color;     /**< timer for graph coloring */
extern ir_timer_t *t_ra_ifg;       /**< timer for building interference graph */
extern ir_timer_t *t_ra_copymin;   /**< timer for copy minimization */
extern ir_timer_t *t_ra_ssa;       /**< timer for ssa destruction */
extern ir_timer_t *t_ra_other;     /**< timer for remaining stuff */
Sebastian Hack's avatar
Sebastian Hack committed
152

153

Christian Würdig's avatar
Christian Würdig committed
154
#endif /* FIRM_BE_BE_T_H */