* src/vm/jit/alpha/md-abi.c (nregdescint): Added comments.
[cacao.git] / src / vm / jit / alpha / md-abi.c
1 /* src/vm/jit/alpha/md-abi.c - functions for Alpha ABI
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, 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., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes: Christian Ullrich
30
31    $Id: md-abi.c 5070 2006-07-03 13:46:42Z twisti $
32
33 */
34
35
36 #include "config.h"
37 #include "vm/types.h"
38
39 #include "vm/jit/alpha/md-abi.h"
40
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
43
44
45 /* register descripton array **************************************************/
46
47 s4 nregdescint[] = {
48         /*   v0,      t0,      t1,      t2,      t3,      t4,      t5,      t6,   */
49         REG_RET, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, 
50
51         /*   t7,      s0,      s1,      s2,      s3,      s4,      s5,      s6,   */
52         REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, 
53
54         /*   a0,      a1,      a2,      a3,      a4,      a5,      t8,      t9,   */
55         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
56
57         /*  t10,   itmp1,      ra,      pv,      at,   itmp3,      sp,    zero,   */
58         REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
59
60         REG_END
61 };
62
63 s4 nregdescfloat[] = {
64         REG_RET, REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
65         REG_SAV, REG_SAV, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, 
66         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
67         REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES,
68         REG_END
69 };
70
71
72 /* md_param_alloc **************************************************************
73
74    Allocate the parameters of the given method descriptor according to the
75    calling convention of the platform.
76
77 *******************************************************************************/
78
79 void md_param_alloc(methoddesc *md)
80 {
81         paramdesc *pd;
82         s4         i;
83         s4         reguse;
84         s4         stacksize;
85
86         /* set default values */
87
88         reguse = 0;
89         stacksize = 0;
90
91         /* get params field of methoddesc */
92
93         pd = md->params;
94
95         for (i = 0; i < md->paramcount; i++, pd++) {
96                 switch (md->paramtypes[i].type) {
97                 case TYPE_INT:
98                 case TYPE_ADR:
99                 case TYPE_LNG:
100                         if (i < INT_ARG_CNT) {
101                                 pd->inmemory = false;
102                                 pd->regoff = reguse;
103                                 reguse++;
104                                 md->argintreguse = reguse;
105
106                         } else {
107                                 pd->inmemory = true;
108                                 pd->regoff = stacksize;
109                                 stacksize++;
110                         }
111                         break;
112                 case TYPE_FLT:
113                 case TYPE_DBL:
114                         if (i < FLT_ARG_CNT) {
115                                 pd->inmemory = false;
116                                 pd->regoff = reguse;
117                                 reguse++;
118                                 md->argfltreguse = reguse;
119                         } else {
120                                 pd->inmemory = true;
121                                 pd->regoff = stacksize;
122                                 stacksize++;
123                         }
124                         break;
125                 }
126         }
127
128         /* fill register and stack usage */
129
130         md->memuse = stacksize;
131 }
132
133
134 /* md_return_alloc *************************************************************
135
136    Precolor the Java Stackelement containing the Return Value. Since
137    alpha has a dedicated return register (not an reused arg or
138    reserved reg), this is striaghtforward possible, as long, as this
139    stackelement does not have to survive a method invokation
140    (SAVEDVAR)
141
142    --- in
143    m:                       Methodinfo of current method
144    return_type:             Return Type of the Method (TYPE_INT.. TYPE_ADR)
145                                                         TYPE_VOID is not allowed!
146    stackslot:               Java Stackslot to contain the Return Value
147    
148    --- out
149    if precoloring was possible:
150    stackslot->varkind       =ARGVAR
151                         ->varnum        =-1
152                         ->flags         =0
153                         ->regoff        =[REG_RESULT, REG_FRESULT]
154
155 *******************************************************************************/
156
157 void md_return_alloc(methodinfo *m, registerdata *rd, s4 return_type,
158                                          stackptr stackslot)
159 {
160         /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has not   */
161         /* to survive method invokations */
162
163         if (!(stackslot->flags & SAVEDVAR)) {
164                 stackslot->varkind = ARGVAR;
165                 stackslot->varnum = -1;
166                 stackslot->flags = 0;
167
168                 if (IS_INT_LNG_TYPE(return_type)) {
169                         stackslot->regoff = REG_RESULT;
170                 } else { /* float/double */
171                         stackslot->regoff = REG_FRESULT;
172                 }
173         }
174 }
175
176
177 /*
178  * These are local overrides for various environment variables in Emacs.
179  * Please do not remove this and leave it at the end of the file, where
180  * Emacs will automagically detect them.
181  * ---------------------------------------------------------------------
182  * Local variables:
183  * mode: c
184  * indent-tabs-mode: t
185  * c-basic-offset: 4
186  * tab-width: 4
187  * End:
188  */