1 /* jit/lsra.inc - linear scan register allocator header
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 Institut f. Computersprachen, TU Wien
5 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
6 S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
7 J. Wenninger, C. Ullrich
9 This file is part of CACAO.
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2, or (at
14 your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 Contact: cacao@complang.tuwien.ac.at
28 Authors: Christian Ullrich
30 $Id: lsra.h 1953 2005-02-17 13:42:23Z christian $
38 #include "vm/jit/loop/loop.h"
40 /* #define LSRA_DEBUG */
41 /* #define LSRA_SAVEDVAR */
42 /* #define LSRA_MEMORY */
43 /* #define LSRA_PRINTLIFETIMES */
44 /* #define LSRA_EDX */
45 /* #define LSRA_TESTLT */ /* not to be used with register allocation - only INMEMORY */
46 /* #define LSRA_DUMP_LOOPDATA */
50 #define LSRA_PRINTLIFETIMES
58 int i_start; /* instruction number of first use */
59 int i_end; /* instruction number of last use */
60 int v_index; /* local variable index or negative for stackslots */
62 int usagecount; /* number of references*/
63 int reg; /* regoffset durch lsra zugewiesen */
65 struct stackslot *passthrough; /* List of Stackslots in Lifetime, which are passed through a Basic Block */
66 struct stackslot *local_ss; /* Stackslots for this Lifetime or NULL (=="pure" Local Var) */
67 struct _i_list *i_list; /* list of instructions with references to var */
68 struct lifetime *next;
73 struct active_lt *next;
97 struct stackslot *next;
106 struct lifetime **ss_lifetimes;
107 struct lifetime **locals_lifetimes;
108 struct lifetime *lifetimes;
109 struct stackslot *stackslots;
110 struct active_lt *active_tmp, *active_sav;
111 int active_sav_count, active_tmp_count;
112 struct lsra_exceptiontable *ex;
119 struct freemem *next;
123 struct stackslot *ss;
133 struct lsra_exceptiontable {
140 typedef struct lsradata lsradata;
142 /* function prototypes */
143 bool lsra(methodinfo *, codegendata *, registerdata *, loopdata *, t_inlining_globals *);
144 bool lsra_test(methodinfo *, codegendata *);
145 void lsra_init(methodinfo *, codegendata *, t_inlining_globals *, lsradata *);
146 bool lsra_setup(methodinfo *, codegendata *, registerdata *, lsradata *, loopdata *);
147 void lsra_main(methodinfo *, lsradata *, registerdata *, codegendata *, loopdata *ld);
148 void lsra_clean_Graph( methodinfo *, codegendata *, lsradata *, loopdata *);
150 #if defined(LSRA_DEBUG) || defined(LSRA_DUMP_LOOPDATA)
151 void lsra_dump_Graph(methodinfo *, struct depthElement **);
154 void lsra_dump_stack(stackptr );
156 #ifdef LSRA_PRINTLIFETIMES
157 void print_lifetimes(registerdata *, lsradata *, struct lifetime *);
160 int lsra_get_sbr_end(methodinfo *, loopdata *, int , int *);
161 void lsra_mark_blocks(methodinfo *,struct depthElement **, int *, int , int *);
162 int lsra_get_exmaxblock(methodinfo *, loopdata *, int );
163 void lsra_setup_exceptiontable( methodinfo *, codegendata *, loopdata *, lsradata *);
164 void _df( struct depthElement **, int , bool *, int *, bool *, int *);
166 void lsra_scan_registers_canditates(methodinfo *, loopdata *, lsradata *);
167 void lsra_jump( methodinfo *, loopdata *, int, int );
168 void lsra_jump_init( methodinfo *, loopdata *);
169 void lsra_sbr_call ( int , int );
170 void lsra_sbr_ret( int );
172 void lsra_join_lifetimes( methodinfo *, codegendata *, lsradata *, loopdata *);
173 void lsra_calc_lifetime_length(methodinfo *, lsradata *, codegendata *, loopdata *);
175 void lsra_merge_i_lists(struct lifetime *, struct lifetime *);
176 void lsra_merge_local_ss(struct lifetime *, struct lifetime *);
178 void _lsra_new_stack( lsradata *, stackptr , int , int, int);
179 void _lsra_from_stack(lsradata *, stackptr , int , int, int);
180 void lsra_add_ss(struct lifetime *, stackptr );
181 void lsra_usage_local(lsradata *, s4 , int , int , int , int );
182 void lsra_new_local(lsradata *, s4 , int );
183 struct _i_list *lsra_add_i_list(struct _i_list *, int, int ,int );
185 void lsra_sort_lt(struct lifetime **);
186 void _lsra_main( methodinfo *, lsradata *, struct lifetime *, struct lsra_reg *, int , int , int *, int *);
187 void lsra_expire_old_intervalls(lsradata *, struct lifetime *, struct lsra_reg *);
188 void _lsra_expire_old_intervalls(struct lifetime *, struct lsra_reg *, struct active_lt **, int *);
189 void spill_at_intervall(lsradata *, struct lifetime *);
190 void _spill_at_intervall(struct lifetime *, struct active_lt **, int *);
191 void lsra_add_active(struct lifetime *, struct active_lt **, int *);
192 void lsra_alloc(methodinfo *, registerdata *, struct lifetime *, int *);
193 int lsra_getmem(struct lifetime *, struct freemem *, int *);
194 struct freemem *lsra_getnewmem(int *);
195 void lsra_align_stackslots(struct lsradata *, stackptr, stackptr);
196 void lsra_setflags(int *, int);
199 void test_lifetimes( methodinfo *m, loopdata *ld, lsradata *ls, struct lifetime *lifet, codegendata *cd);
200 int _test_lifetimes(methodinfo *m, loopdata *ld, lsradata *ls, int b_index, int *values, bool* bb_visited, struct lifetime *lifet);
207 * These are local overrides for various environment variables in Emacs.
208 * Please do not remove this and leave it at the end of the file, where
209 * Emacs will automagically detect them.
210 * ---------------------------------------------------------------------
213 * indent-tabs-mode: t