bechordal_t.h 4.09 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
25
 * @file
 * @brief       Internal data structures for the chordal register allocator.
 * @author      Sebastian Hack
 * @date        25.01.2005
 * @version     $Id$
Sebastian Hack's avatar
Sebastian Hack committed
26
 */
Christian Würdig's avatar
Christian Würdig committed
27
28
#ifndef FIRM_BE_BECHORDAL_T_H
#define FIRM_BE_BECHORDAL_T_H
Sebastian Hack's avatar
Sebastian Hack committed
29

Michael Beck's avatar
Michael Beck committed
30
#include "firm_types.h"
31
32
#include "list.h"
#include "pmap.h"
Christian Würdig's avatar
Christian Würdig committed
33
34
35
#include "bitset.h"
#include "obst.h"
#include "debug.h"
Sebastian Hack's avatar
Sebastian Hack committed
36

Sebastian Hack's avatar
Sebastian Hack committed
37
#include "bechordal.h"
Christian Würdig's avatar
Christian Würdig committed
38
39
#include "beirg.h"
#include "beifg.h"
Sebastian Hack's avatar
Sebastian Hack committed
40

Sebastian Hack's avatar
Sebastian Hack committed
41
42
43
/**
 * A liveness interval border.
 */
44
struct border_t {
45
	DEBUG_ONLY(unsigned magic;)     /**< A magic number for checking. */
46
47
48
49
50
	struct list_head  list;         /**< list head for queuing. */
	border_t         *other_end;    /**< The other end of the border. */
	ir_node          *irn;          /**< The node. */
	unsigned         step;          /**< The number equal to the interval border. */
	unsigned         pressure;      /**< The pressure at this interval border. (The border itself is counting). */
Christian Würdig's avatar
Christian Würdig committed
51
	unsigned         is_def  : 1;   /**< Does this border denote a use or a def. */
52
53
54
55
56
	unsigned         is_real : 1;   /**< Is the def/use real? Or is it just
	                                     inserted at block beginnings or ends
	                                     to ensure that inside a block, each
	                                     value has one begin and one end. */
};
Sebastian Hack's avatar
Sebastian Hack committed
57

58
59
60
/**
 * Environment for each of the chordal register allocator phases
 */
61
struct be_chordal_env_t {
Michael Beck's avatar
Michael Beck committed
62
	struct obstack       *obst;         /**< An obstack for temporary storage. */
63
	be_ra_chordal_opts_t *opts;         /**< A pointer to the chordal ra options. */
64
	ir_graph             *irg;          /**< The graph under examination. */
65
	const arch_register_class_t *cls;   /**< The current register class. */
66
67
	pmap                 *border_heads; /**< Maps blocks to border heads. */
	be_ifg_t             *ifg;          /**< The interference graph. */
68
	bitset_t             *allocatable_regs; /**< set of allocatable registers */
69
70
};

71
static inline struct list_head *_get_block_border_head(const be_chordal_env_t *inf, ir_node *bl) {
72
  return (list_head*)pmap_get(inf->border_heads, bl);
73
74
75
76
}

#define get_block_border_head(info, bl)     _get_block_border_head(info, bl)

77
#define foreach_border_head(head, pos)      list_for_each_entry_reverse(border_t, pos, head, list)
78
79
#define border_next(b)                      (list_entry((b)->list.next, border_t, list))
#define border_prev(b)                      (list_entry((b)->list.prev, border_t, list))
80

Sebastian Hack's avatar
Sebastian Hack committed
81
#define chordal_has_class(chordal_env, irn) \
82
	arch_irn_consider_in_reg_alloc(chordal_env->cls, irn)
Daniel Grund's avatar
Daniel Grund committed
83

Sebastian Hack's avatar
Sebastian Hack committed
84
void be_ra_chordal_color(be_chordal_env_t *chordal_env);
Daniel Grund's avatar
Daniel Grund committed
85

Sebastian Hack's avatar
Sebastian Hack committed
86
87
enum {
	/* Dump flags */
88
89
	BE_CH_DUMP_NONE       = (1 << 0),
	BE_CH_DUMP_SPILL      = (1 << 1),
Sebastian Hack's avatar
Sebastian Hack committed
90
91
92
93
94
95
	BE_CH_DUMP_LIVE       = (1 << 2),
	BE_CH_DUMP_COLOR      = (1 << 3),
	BE_CH_DUMP_COPYMIN    = (1 << 4),
	BE_CH_DUMP_SSADESTR   = (1 << 5),
	BE_CH_DUMP_TREE_INTV  = (1 << 6),
	BE_CH_DUMP_CONSTR     = (1 << 7),
Matthias Braun's avatar
Matthias Braun committed
96
97
98
99
	BE_CH_DUMP_SPILLSLOTS = (1 << 8),
	BE_CH_DUMP_LOWER      = (1 << 9),
	BE_CH_DUMP_APPEL      = (1 << 10),
	BE_CH_DUMP_ALL        = 2 * BE_CH_DUMP_APPEL - 1,
Daniel Grund's avatar
Daniel Grund committed
100

101
	/* lower perm options */
102
103
	BE_CH_LOWER_PERM_SWAP   = 1,
	BE_CH_LOWER_PERM_COPY   = 2,
Christian Würdig's avatar
Christian Würdig committed
104
105
106
107
108

	/* verify options */
	BE_CH_VRFY_OFF    = 1,
	BE_CH_VRFY_WARN   = 2,
	BE_CH_VRFY_ASSERT = 3,
Sebastian Hack's avatar
Sebastian Hack committed
109
};
Sebastian Hack's avatar
Sebastian Hack committed
110

111
struct be_ra_chordal_opts_t {
112
113
114
	unsigned dump_flags;
	int      lower_perm_opt;
	int      vrfy_option;
Sebastian Hack's avatar
Sebastian Hack committed
115

Sebastian Hack's avatar
Sebastian Hack committed
116
117
	char ilp_server[128];
	char ilp_solver[128];
Sebastian Hack's avatar
Sebastian Hack committed
118
};
Sebastian Hack's avatar
Sebastian Hack committed
119

Matthias Braun's avatar
Matthias Braun committed
120
121
void check_for_memory_operands(ir_graph *irg);

Christian Würdig's avatar
Christian Würdig committed
122
#endif /* FIRM_BE_BECHORDAL_T_H */