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