* configure.ac: Added support for compiling on sparc64
[cacao.git] / src / vm / jit / sparc64 / md-abi.c
1
2 #include "config.h"
3 #include "vm/types.h"
4
5 #include "vm/jit/sparc64/md-abi.h"
6
7 #include "vm/descriptor.h"
8 #include "vm/global.h"
9
10
11 /* register descripton array **************************************************/
12
13 /* callee point-of-view, after SAVE has been called */
14 s4 nregdescint[] = {
15         /* zero  itmp1/g1 itmp2/g2 itmp3/g3 temp/g4  temp/g5  sys/g6   sys/g7 */  
16         REG_RES, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_RES, REG_RES,
17         
18         /* o0    o1       o2       o3       o4       o5       sp/o6    o7     */
19         REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_TMP,
20         
21         /* l0    l1       l2       l3       l4       l5       l6       l7     */
22         REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
23         
24         /* i0    i1       i2       i3       i4       pv/i5    fp/i6    ra/i7  */
25         REG_RET, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES,
26         REG_END
27         
28         /* XXX i1 - i4: SAV OR ARG ??? */
29 };
30
31 s4 nregdescfloat[] = {
32         REG_RET, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
33         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
34         REG_END
35 };
36
37
38 /* md_param_alloc **************************************************************
39
40    XXX
41
42 *******************************************************************************/
43
44 void md_param_alloc(methoddesc *md)
45 {
46         paramdesc *pd;
47         s4         i;
48         s4         reguse;
49         s4         stacksize;
50
51         /* set default values */
52
53         reguse = 0;
54         stacksize = 0;
55
56         /* get params field of methoddesc */
57
58         pd = md->params;
59
60         for (i = 0; i < md->paramcount; i++, pd++) {
61                 switch (md->paramtypes[i].type) {
62                 case TYPE_INT:
63                 case TYPE_ADR:
64                 case TYPE_LNG:
65                         if (i < INT_ARG_CNT) {
66                                 pd->inmemory = false;
67                                 pd->regoff = reguse;
68                                 reguse++;
69                                 md->argintreguse = reguse;
70
71                         } else {
72                                 pd->inmemory = true;
73                                 pd->regoff = stacksize;
74                                 stacksize++;
75                         }
76                         break;
77                 case TYPE_FLT:
78                 case TYPE_DBL:
79                         if (i < FLT_ARG_CNT) {
80                                 pd->inmemory = false;
81                                 pd->regoff = reguse;
82                                 reguse++;
83                                 md->argfltreguse = reguse;
84                         } else {
85                                 pd->inmemory = true;
86                                 pd->regoff = stacksize;
87                                 stacksize++;
88                         }
89                         break;
90                 }
91         }
92
93         /* fill register and stack usage */
94
95         md->memuse = stacksize;
96 }
97
98
99 /* md_return_alloc *************************************************************
100
101    Precolor the Java Stackelement containing the Return Value. Since
102    alpha has a dedicated return register (not an reused arg or
103    reserved reg), this is striaghtforward possible, as long, as this
104    stackelement does not have to survive a method invokation
105    (SAVEDVAR)
106
107    --- in
108    m:                       Methodinfo of current method
109    return_type:             Return Type of the Method (TYPE_INT.. TYPE_ADR)
110                                                         TYPE_VOID is not allowed!
111    stackslot:               Java Stackslot to contain the Return Value
112    
113    --- out
114    if precoloring was possible:
115    stackslot->varkind       =ARGVAR
116                         ->varnum        =-1
117                         ->flags         =0
118                         ->regoff        =[REG_RESULT, REG_FRESULT]
119
120 *******************************************************************************/
121
122 void md_return_alloc(methodinfo *m, registerdata *rd, s4 return_type,
123                                          stackptr stackslot)
124 {
125         /* Only precolor the stackslot, if it is not used for parameter precoloring AND */
126         /* it is not a SAVEDVAR <-> has not to survive method invokations */
127
128         if (!m->isleafmethod || (m->parseddesc->paramcount == 0)) {
129
130                 if (!(stackslot->flags & SAVEDVAR)) {
131                         stackslot->varkind = ARGVAR;
132                         stackslot->varnum = -1;
133                         stackslot->flags = 0;
134
135                         if (IS_INT_LNG_TYPE(return_type)) {
136                                 stackslot->regoff = REG_RESULT_CALLEE;
137                         } else { /* float/double */
138                                 stackslot->regoff = REG_FRESULT;
139                         }
140                 }
141         }       
142 }
143
144
145 /*
146  * These are local overrides for various environment variables in Emacs.
147  * Please do not remove this and leave it at the end of the file, where
148  * Emacs will automagically detect them.
149  * ---------------------------------------------------------------------
150  * Local variables:
151  * mode: c
152  * indent-tabs-mode: t
153  * c-basic-offset: 4
154  * tab-width: 4
155  * End:
156  */