be_t.h 2.78 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
Christian Würdig's avatar
Christian Würdig committed
4
5
 */

Sebastian Hack's avatar
Sebastian Hack committed
6
/**
Christian Würdig's avatar
Christian Würdig committed
7
8
9
 * @file
 * @brief   Internal backend global data structures.
 * @author  Sebastian Hack
Sebastian Hack's avatar
Sebastian Hack committed
10
 */
Christian Würdig's avatar
Christian Würdig committed
11
12
#ifndef FIRM_BE_BE_T_H
#define FIRM_BE_BE_T_H
Sebastian Hack's avatar
Sebastian Hack committed
13

14
15
#include <assert.h>

Sebastian Hack's avatar
Sebastian Hack committed
16
#include "be.h"
17
#include "be_types.h"
18
19
20
#include "firm_types.h"
#include "pmap.h"
#include "timing.h"
Daniel Grund's avatar
Daniel Grund committed
21

22
23
24
25
26
27
28
29
30
31
enum {
	DUMP_NONE     = 0,
	DUMP_INITIAL  = 1 << 0,
	DUMP_ABI      = 1 << 1,
	DUMP_SCHED    = 1 << 2,
	DUMP_PREPARED = 1 << 3,
	DUMP_RA       = 1 << 4,
	DUMP_FINAL    = 1 << 5,
	DUMP_BE       = 1 << 6
};
32
33
34
35
36
37
38

enum {
	BE_TIME_OFF,
	BE_TIME_ON
};

enum {
39
40
41
	BE_VERIFY_OFF,
	BE_VERIFY_WARN,
	BE_VERIFY_ASSERT
42
43
};

44
/** Backend options */
45
struct be_options_t {
46
47
48
49
50
51
52
53
54
	unsigned dump_flags;       /**< backend dumping flags */
	int  timing;               /**< time the backend phases */
	int  opt_profile_generate; /**< instrument code for profiling */
	int  opt_profile_use;      /**< use existing profile data */
	int  omit_fp;              /**< try to omit the frame pointer */
	int  pic;                  /**< create position independent code */
	int  verify_option;        /**< backend verify option */
	char ilp_server[128];      /**< the ilp server name */
	char ilp_solver[128];      /**< the ilp solver name */
55
	int  verbose_asm;          /**< dump verbose assembler */
Sebastian Hack's avatar
Sebastian Hack committed
56
};
57
extern be_options_t be_options;
Sebastian Hack's avatar
Sebastian Hack committed
58

59
struct be_main_env_t {
60
61
62
63
64
65
	arch_env_t   *arch_env;
	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 */
	pmap         *ent_pic_symbol_map;
	ir_type      *pic_symbols_type;
Sebastian Hack's avatar
Sebastian Hack committed
66
67
};

68
extern asm_constraint_flags_t asm_constraint_flags[256];
69

70
void be_get_allocatable_regs(ir_graph const *irg, arch_register_class_t const *cls, unsigned *raw_bitset);
Matthias Braun's avatar
Matthias Braun committed
71

72
73
unsigned be_get_n_allocatable_regs(const ir_graph *irg,
                                   const arch_register_class_t *cls);
74
75
76
77
78

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

Matthias Braun's avatar
Matthias Braun committed
81
82
extern int be_timing;

83
typedef enum {
84
85
	T_FIRST,
	T_ABI = T_FIRST,
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
	T_CODEGEN,
	T_RA_PREPARATION,
	T_SCHED,
	T_CONSTR,
	T_FINISH,
	T_EMIT,
	T_VERIFY,
	T_OTHER,
	T_HEIGHTS,
	T_LIVE,
	T_EXECFREQ,
	T_SSA_CONSTR,
	T_RA_EPILOG,
	T_RA_CONSTR,
	T_RA_SPILL,
	T_RA_SPILL_APPLY,
	T_RA_COLOR,
	T_RA_IFG,
	T_RA_COPYMIN,
	T_RA_SSA,
	T_RA_OTHER,
	T_LAST = T_RA_OTHER
} be_timer_id_t;
109
ENUM_COUNTABLE(be_timer_id_t)
110
111
112
113
extern ir_timer_t *be_timers[T_LAST+1];

static inline void be_timer_push(be_timer_id_t id)
{
Matthias Braun's avatar
Matthias Braun committed
114
	assert(id <= T_LAST);
115
116
	if (!be_timing)
		return;
Matthias Braun's avatar
Matthias Braun committed
117
	ir_timer_push(be_timers[id]);
118
119
120
121
}

static inline void be_timer_pop(be_timer_id_t id)
{
Matthias Braun's avatar
Matthias Braun committed
122
	assert(id <= T_LAST);
123
124
	if (!be_timing)
		return;
Matthias Braun's avatar
Matthias Braun committed
125
	ir_timer_pop(be_timers[id]);
126
127
128
}

#endif