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