be_t.h 3.38 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
#include <assert.h>
15
#include <stdbool.h>
16

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

24
25
extern arch_isa_if_t const *isa_if;

26
typedef enum be_dump_flags_t {
27
28
29
30
31
32
33
	DUMP_NONE     = 0,
	DUMP_INITIAL  = 1 << 0,
	DUMP_SCHED    = 1 << 2,
	DUMP_PREPARED = 1 << 3,
	DUMP_RA       = 1 << 4,
	DUMP_FINAL    = 1 << 5,
	DUMP_BE       = 1 << 6
34
} be_dump_flags_t;
35

36
/** Backend options */
37
struct be_options_t {
38
	unsigned dump_flags;       /**< backend dumping flags */
39
40
41
42
43
44
	bool timing;               /**< time the backend phases */
	bool opt_profile_generate; /**< instrument code for profiling */
	bool opt_profile_use;      /**< use existing profile data */
	bool omit_fp;              /**< try to omit the frame pointer */
	bool pic;                  /**< create position independent code */
	bool do_verify;            /**< backend verify option */
45
46
	char ilp_server[128];      /**< the ilp server name */
	char ilp_solver[128];      /**< the ilp solver name */
47
	bool verbose_asm;          /**< dump verbose assembler */
Sebastian Hack's avatar
Sebastian Hack committed
48
};
49
extern be_options_t be_options;
Sebastian Hack's avatar
Sebastian Hack committed
50

51
52
extern after_transform_func be_after_transform;

53
54
extern asm_constraint_flags_t be_asm_constraint_flags[256];

55
struct be_main_env_t {
56
57
58
59
60
	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
61
62
};

63
void be_set_constraint_support(asm_constraint_flags_t flags, char const *constraints);
64

65
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
66

67
68
unsigned be_get_n_allocatable_regs(const ir_graph *irg,
                                   const arch_register_class_t *cls);
69

70
71
void be_after_irp_transform(const char *name);

72
73
void be_check_verify_result(bool fine, ir_graph *irg);

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

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

82
typedef enum {
83
84
	T_FIRST,
	T_ABI = T_FIRST,
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
	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;
108
ENUM_COUNTABLE(be_timer_id_t)
109
110
111
112
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
113
	assert(id <= T_LAST);
114
115
	if (!be_timing)
		return;
Matthias Braun's avatar
Matthias Braun committed
116
	ir_timer_push(be_timers[id]);
117
118
119
120
}

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

127
128
129
130
131
132
133
/**
 * A wrapper around a firm dumper. Dumps only, if flags are enabled.
 *
 * @param mask    a bitmask containing the reason what will be dumped
 * @param irg     the IR graph to dump
 * @param suffix  the suffix for the dumper
 */
134
static inline void be_dump(be_dump_flags_t const mask, ir_graph *const irg, char const *const suffix)
135
136
137
138
139
{
	if (be_options.dump_flags & mask)
		dump_ir_graph(irg, suffix);
}

140
#endif