Merged with tip.
[cacao.git] / src / vm / jit / i386 / md-abi.c
1 /* src/vm/jit/i386/md-abi.c - functions for i386 Linux ABI
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
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.
12
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.
17
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
21    02110-1301, USA.
22
23 */
24
25
26 #include "config.h"
27 #include "vm/types.h"
28
29 #include "vm/jit/i386/md-abi.h"
30
31 #include "vm/global.h"
32
33 #include "vm/jit/abi.h"
34
35 #include "vmcore/descriptor.h"
36
37
38 /* register descripton - array ************************************************/
39
40 s4 nregdescint[] = {
41     REG_RET, REG_RES, REG_RES, REG_TMP, REG_RES, REG_SAV, REG_SAV, REG_SAV,
42     REG_END
43 };
44
45 const char *abi_registers_integer_name[] = {
46         "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
47 };
48
49 const s4 abi_registers_integer_argument[] = {
50         -1,
51 };
52
53 const s4 abi_registers_integer_saved[] = {
54         5, /* s0 */
55         6, /* s1 */
56         7, /* s2 */
57 };
58
59 const s4 abi_registers_integer_temporary[] = {
60         3, /* t0 */
61 };
62
63
64 s4 nregdescfloat[] = {
65  /* rounding problems with callee saved registers */
66  /* REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_TMP, REG_TMP, REG_RES, REG_RES, */
67  /* REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, */
68     REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
69     REG_END
70 };
71
72 const s4 abi_registers_float_argument[] = {
73         -1,
74 };
75
76 const s4 abi_registers_float_saved[] = {
77         -1,
78 };
79
80 const s4 abi_registers_float_temporary[] = {
81         -1,
82 };
83
84
85 /* md_param_alloc **************************************************************
86
87    Allocate Arguments to Stackslots according the Calling Conventions
88
89    --- in
90    md->paramcount:           Number of arguments for this method
91    md->paramtypes[].type:    Argument types
92    
93    --- out
94    md->params[].inmemory:    Argument spilled on stack
95    md->params[].regoff:      Stack offset or rd->arg[int|flt]regs index
96    md->memuse:               Stackslots needed for argument spilling
97    md->argintreguse:         max number of integer arguments used
98    md->argfltreguse:         max number of float arguments used
99
100 *******************************************************************************/
101
102 void md_param_alloc(methoddesc *md)
103 {
104         paramdesc *pd;
105         int        stacksize;
106         int        i;
107
108         pd = md->params;
109         stacksize = 0;
110
111         for (i = 0; i < md->paramcount; i++, pd++) {
112                 pd->inmemory = true;
113                 pd->index    = stacksize;
114                 pd->regoff   = stacksize * 8;
115                 stacksize++;
116         }
117
118         md->memuse       = stacksize;
119         md->argintreguse = 0;
120         md->argfltreguse = 0;
121 }
122
123
124 /* md_param_alloc_native *******************************************************
125
126    Pre-allocate arguments according the native ABI.
127
128 *******************************************************************************/
129
130 void md_param_alloc_native(methoddesc *md)
131 {
132         paramdesc *pd;
133         int        stacksize;
134         int        i;
135
136         pd = md->params;
137         stacksize = 0;
138
139         for (i = 0; i < md->paramcount; i++, pd++) {
140                 pd->inmemory  = true;
141                 pd->index     = stacksize;
142                 pd->regoff    = stacksize * 4;
143                 stacksize    += IS_2_WORD_TYPE(md->paramtypes[i].type) ? 2 : 1;
144         }
145
146         md->memuse       = stacksize;
147         md->argintreguse = 0;
148         md->argfltreguse = 0;
149 }
150
151
152 /* md_return_alloc *************************************************************
153
154    No straight forward precoloring of the Java Stackelement containing
155    the return value possible for i386, since it uses "reserved"
156    registers for return values
157
158 *******************************************************************************/
159
160 void md_return_alloc(jitdata *jd, stackelement_t *stackslot)
161 {
162         /* nothing */
163 }
164
165
166 /*
167  * These are local overrides for various environment variables in Emacs.
168  * Please do not remove this and leave it at the end of the file, where
169  * Emacs will automagically detect them.
170  * ---------------------------------------------------------------------
171  * Local variables:
172  * mode: c
173  * indent-tabs-mode: t
174  * c-basic-offset: 4
175  * tab-width: 4
176  * End:
177  */