* src/vm/builtin.c (builtin_init): Documented.
[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 4960 2006-05-26 12:19:43Z edwin $
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         REG_RET, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, 
49         REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, 
50         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
51         REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
52         REG_END
53 };
54
55 s4 nregdescfloat[] = {
56         REG_RET, REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
57         REG_SAV, REG_SAV, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, 
58         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
59         REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES,
60         REG_END
61 };
62
63
64 /* md_param_alloc **************************************************************
65
66    Allocate the parameters of the given method descriptor according to the
67    calling convention of the platform.
68
69 *******************************************************************************/
70
71 void md_param_alloc(methoddesc *md)
72 {
73         paramdesc *pd;
74         s4         i;
75         s4         reguse;
76         s4         stacksize;
77
78         /* set default values */
79
80         reguse = 0;
81         stacksize = 0;
82
83         /* get params field of methoddesc */
84
85         pd = md->params;
86
87         for (i = 0; i < md->paramcount; i++, pd++) {
88                 switch (md->paramtypes[i].type) {
89                 case TYPE_INT:
90                 case TYPE_ADR:
91                 case TYPE_LNG:
92                         if (i < INT_ARG_CNT) {
93                                 pd->inmemory = false;
94                                 pd->regoff = reguse;
95                                 reguse++;
96                                 md->argintreguse = reguse;
97
98                         } else {
99                                 pd->inmemory = true;
100                                 pd->regoff = stacksize;
101                                 stacksize++;
102                         }
103                         break;
104                 case TYPE_FLT:
105                 case TYPE_DBL:
106                         if (i < FLT_ARG_CNT) {
107                                 pd->inmemory = false;
108                                 pd->regoff = reguse;
109                                 reguse++;
110                                 md->argfltreguse = reguse;
111                         } else {
112                                 pd->inmemory = true;
113                                 pd->regoff = stacksize;
114                                 stacksize++;
115                         }
116                         break;
117                 }
118         }
119
120         /* fill register and stack usage */
121
122         md->memuse = stacksize;
123 }
124
125
126 /* md_return_alloc *************************************************************
127
128    Precolor the Java Stackelement containing the Return Value. Since
129    alpha has a dedicated return register (not an reused arg or
130    reserved reg), this is striaghtforward possible, as long, as this
131    stackelement does not have to survive a method invokation
132    (SAVEDVAR)
133
134    --- in
135    m:                       Methodinfo of current method
136    return_type:             Return Type of the Method (TYPE_INT.. TYPE_ADR)
137                                                         TYPE_VOID is not allowed!
138    stackslot:               Java Stackslot to contain the Return Value
139    
140    --- out
141    if precoloring was possible:
142    stackslot->varkind       =ARGVAR
143                         ->varnum        =-1
144                         ->flags         =0
145                         ->regoff        =[REG_RESULT, REG_FRESULT]
146
147 *******************************************************************************/
148
149 void md_return_alloc(methodinfo *m, registerdata *rd, s4 return_type,
150                                          stackptr stackslot)
151 {
152         /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has not   */
153         /* to survive method invokations */
154
155         if (!(stackslot->flags & SAVEDVAR)) {
156                 stackslot->varkind = ARGVAR;
157                 stackslot->varnum = -1;
158                 stackslot->flags = 0;
159
160                 if (IS_INT_LNG_TYPE(return_type)) {
161                         stackslot->regoff = REG_RESULT;
162                 } else { /* float/double */
163                         stackslot->regoff = REG_FRESULT;
164                 }
165         }
166 }
167
168
169 /*
170  * These are local overrides for various environment variables in Emacs.
171  * Please do not remove this and leave it at the end of the file, where
172  * Emacs will automagically detect them.
173  * ---------------------------------------------------------------------
174  * Local variables:
175  * mode: c
176  * indent-tabs-mode: t
177  * c-basic-offset: 4
178  * tab-width: 4
179  * End:
180  */