GNU header update.
[cacao.git] / src / vm / jit / lsra.h
1 /* jit/lsra.inc - linear scan register allocator header
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Ullrich
28
29    $Id: lsra.h 1735 2004-12-07 14:33:27Z twisti $
30
31 */
32
33
34 #ifndef _LSRA_H
35 #define _LSRA_H
36
37 #include "loop/loop.h"
38
39 #define LSRA_STORE 1
40 #define LSRA_LOAD 0
41 #define LSRA_POP -1
42
43 struct lifetime {
44         int i_start; /* instruction number of first use */
45         int i_end; /* instruction number of last use */
46         int v_index; /* local variable index or negative for stackslots */
47         int type;
48         int usagecount; /* number of references*/
49         int reg; /* regoffset durch lsra zugewiesen */
50         int savedvar;
51         struct stackslot *passthrough; /* List of Stackslots in Lifetime, which are passed through a Basic Block */
52         struct stackslot *local_ss; /* Stackslots for this Lifetime or NULL (=="pure" Local Var) */
53         struct _i_list *i_list; /* list of instructions with references to var */
54         struct lifetime *next;
55 };
56
57 struct active_lt {
58         struct lifetime *lt;
59         struct active_lt *next;
60 };
61
62 struct l_loop {
63         int b_first;
64         int b_last;
65         int nesting;
66 };
67
68 struct b_loop {
69         int loop;
70         int instr;
71 };
72
73 struct _i_list {
74         int b_index;
75         int instr;
76         int store;
77         struct _i_list *next;
78 };
79
80 struct stackslot {
81         stackptr s;
82         int bb;
83         struct stackslot *next;
84 };
85
86 struct lsra_reg {
87         int reg_index;
88         int use;
89 };
90
91 struct lsradata {
92         struct lifetime **ss_lifetimes;
93         struct lifetime **locals_lifetimes;
94         struct lifetime *lifetimes;
95         struct stackslot *stackslots;
96         struct active_lt *active_tmp, *active_sav;
97         int active_sav_count, active_tmp_count;
98         int var_index;
99         bool back_edge_panic;
100 };
101
102 struct freemem {
103         int off;
104         int end;
105         struct freemem *next;
106 };
107
108 struct dup {
109         struct stackslot *ss;
110         struct dup *next;
111 };
112
113 typedef struct lsradata lsradata;
114
115 /* function prototypes */
116 void lsra(methodinfo *, codegendata *, registerdata *, loopdata *, t_inlining_globals *);
117 void lsra_init(methodinfo *, codegendata *, t_inlining_globals *, lsradata *);
118 void lsra_setup(methodinfo *, codegendata *, registerdata *, lsradata *, loopdata *);
119 void lsra_clean_Graph( methodinfo *, codegendata *, lsradata *, loopdata *);
120
121 #ifdef LSRA_DEBUG
122 void lsra_dump_Graph(methodinfo *, struct depthElement **);
123 void lsra_dump_stack(stackptr );
124 #endif
125 #ifdef LSRA_PRINTLIFETIMES
126 void print_lifetimes(registerdata *, struct lifetime *);
127 #endif
128
129 int lsra_get_sbr_end(methodinfo *, loopdata *, int , int *);
130 void lsra_scan_registers_canditates(methodinfo *, lsradata *);
131 void lsra_join_lifetimes( methodinfo *, codegendata *, lsradata *, loopdata *);
132 int lsra_getmaxblock(methodinfo *, loopdata *, int );
133 void lsra_calc_lifetime_length(methodinfo *, lsradata *, codegendata *, loopdata *);
134
135 void lsra_merge_i_lists(struct lifetime *, struct lifetime *);
136 void lsra_merge_local_ss(struct lifetime *, struct lifetime *);
137
138 void _lsra_new_stack( lsradata *, stackptr , int , int, int);
139 void _lsra_from_stack(lsradata *, stackptr , int , int, int);
140 void lsra_add_ss(struct lifetime *, stackptr );
141 void lsra_usage_local(lsradata *, s4 , int , int , int , int );
142 void lsra_new_local(lsradata *, s4 , int );
143 struct _i_list *lsra_add_i_list(struct _i_list *, int, int ,int );
144
145 void lsra_sort_lt(struct lifetime **);
146 void lsra_main(methodinfo *, lsradata *, registerdata *);
147 void _lsra_main( methodinfo *, lsradata *, struct lifetime *, struct lsra_reg *, int , int , int *, int *);
148 void lsra_expire_old_intervalls(lsradata *, struct lifetime *, struct lsra_reg *);
149 void _lsra_expire_old_intervalls(struct lifetime *, struct lsra_reg *, struct active_lt **, int *);
150 void spill_at_intervall(lsradata *, struct lifetime *);
151 void _spill_at_intervall(struct lifetime *, struct active_lt **, int *);
152 void lsra_add_active(struct lifetime *, struct active_lt **, int *);
153 void lsra_alloc(methodinfo *, registerdata *, struct lifetime *, int *);
154 int lsra_getmem(struct lifetime *, struct freemem *, int *);
155 struct freemem *lsra_getnewmem(int *);
156 void lsra_align_stackslots(struct lsradata *, stackptr, stackptr);
157 void lsra_setflags(int *, int);
158 #endif /* _LSRA_H */
159
160
161 /*
162  * These are local overrides for various environment variables in Emacs.
163  * Please do not remove this and leave it at the end of the file, where
164  * Emacs will automagically detect them.
165  * ---------------------------------------------------------------------
166  * Local variables:
167  * mode: c
168  * indent-tabs-mode: t
169  * c-basic-offset: 4
170  * tab-width: 4
171  * End:
172  */