1 /* src/vm/jit/allocator/lsra.h - linear scan register allocator header
3 Copyright (C) 2005, 2006, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33 # define LSRA_DEBUG_CHECK
34 # define LSRA_DEBUG_VERBOSE
37 #ifdef SSA_DEBUG_CHECK
38 # define _LSRA_CHECK_BOUNDS(i,l,h) assert( ((i) >= (l)) && ((i) < (h)));
39 # define _LSRA_ASSERT(a) assert((a));
41 # define _LSRA_CHECK_BOUNDS(i,l,h)
42 # define _LSRA_ASSERT(a)
45 /* #define LSRA_DEBUG */ /* lsra debug messages */
46 /* #define LSRA_SAVEDVAR */
47 /* #define LSRA_MEMORY */
48 #if defined(__I386__) || defined(__X86_64__)
49 #define JOIN_DEST_STACK /* The destination stackslot gets the same */
50 /* register as one of the src stackslots. Important for i386 & X86_64 */
51 /* since they do not have "3 operand" arithmetic instructions to */
52 /* prevent usage of a reserved register (REG_ITMPX) */
54 #define JOIN_DUP_STACK /* join "identical" stackslots created by dup* */
56 #define USAGE_COUNT /* influence LSRA with usagecount */
57 #define USEAGE_COUNT_EXACT /* search all active lifetimes and regard */
59 #define USAGE_PER_INSTR /* divide usagecount by lifetimelength */
67 /* join types and flags*/
68 #define JOIN 0 /* joins that are not in any way dangerous */
69 #define JOIN_BB 1 /* join Stackslots over Basic Block Boundaries */
70 #define JOIN_DUP 2 /* join of two possibly concurring lifeteimes through DUP* */
71 #define JOIN_OP 4 /* join of src operand with dst operand on i386 and x86_64 */
73 /* JOIN_DUP and JOIN_OP is mutually exclusive as JOIN_OP */
75 #define JOINING 8 /* set while joining for DUP or OP to prevent assignement */
76 /* to a REG_RES before all involved lifetimes have been */
79 #define min(a,b) ((a)<(b)?(a):(b))
80 #define max(a,b) ((a)<(b)?(b):(a))
91 struct _backedge *next;
95 int i_start; /* instruction number of first use */
96 int i_end; /* instruction number of last use */
97 int v_index; /* local variable index or negative for stackslots */
98 int type; /* TYPE_* or -1 for unused lifetime */
99 long usagecount; /* number of references*/
100 int reg; /* regoffset allocated by lsra*/
103 struct stackslot *local_ss; /* Stackslots for this Lifetime or NULL ( == */
104 /* "pure" Local Var) */
126 struct stackslot *next;
129 struct lsra_register {
143 int header; /* BB Index of subroutine start (SBR_HEADER) */
144 struct _list *ret; /* List of possible return BB indizes */
149 #if defined(LSRA_USES_REG_RES)
150 int reg_res_free[REG_RES_CNT];
152 struct _list **succ; /* CFG successors*/
153 struct _list **pred; /* CFG predecessors */
154 int *num_pred; /* CFG number of predecessors */
155 int *sorted; /* BB sorted in reverse post order */
156 int *sorted_rev; /* BB reverse lookup of sorted */
158 struct _backedge **backedge; /* backedge data structure */
159 int backedge_count; /* number of backedges */
161 struct _sbr sbr; /* list of subroutines, sorted by header */
163 long *nesting; /* Nesting level of BB*/
165 int maxlifetimes; /* copy from methodinfo to prevent passing methodinfo */
168 struct lifetime *lifetime; /* array of lifetimes */
169 int lifetimecount; /* number of lifetimes */
170 int *lt_used; /* index to lifetimearray for used lifetimes */
171 int *lt_int; /* index to lifetimearray for int lifetimes */
172 int lt_int_count; /* number of int/[lng]/[adr] lifetimes */
173 int *lt_flt; /* index to lifetimearray for float lifetimes */
174 int lt_flt_count; /* number of float/double lifetimes */
175 int *lt_mem; /* index to lifetimearray for all lifetimes */
176 /* not to be allocated in registers */
177 int lt_mem_count; /* number of this other lifetimes */
179 struct lifetime **active_tmp, **active_sav;
180 int active_tmp_top, active_sav_top;
182 struct lsra_exceptiontable *ex;
183 int v_index; /* next free index for stack slot lifetimes */
184 /* decrements from -1 */
191 struct freemem *next;
194 typedef struct lsradata lsradata;
197 /* function prototypes ********************************************************/
199 bool lsra(jitdata *jd);
205 * These are local overrides for various environment variables in Emacs.
206 * Please do not remove this and leave it at the end of the file, where
207 * Emacs will automagically detect them.
208 * ---------------------------------------------------------------------
211 * indent-tabs-mode: t
215 * vim:noexpandtab:sw=4:ts=4: