8f62e0432f27ab8072b7a9cdeaed34c5bba1b3e2
[cacao.git] / src / vm / jit / sparc64 / md-abi.h
1 /* src/vm/jit/sparc64/md-abi.h - defines for Sparc 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: Alexander Jordan
28
29    Changes:
30
31    $Id: md-abi.h 4357 2006-01-22 23:33:38Z twisti $
32
33 */
34
35 #ifndef _MD_ABI_H
36 #define _MD_ABI_H
37
38 /* preallocated registers *****************************************************/
39
40 /* integer registers */
41   
42 #define REG_RESULT_CALLEE       24   /* to deliver method results                                 */
43 #define REG_RESULT_CALLER        8   /* to read method results                    */
44
45 #define REG_RA_CALLEE           31   /* callee reads return address here          */
46 #define REG_RA_CALLER           15   /* caller puts address of call instr here    */
47
48 #define REG_PV_CALLEE           29   /* procedure vector, as found by callee      */
49 #define REG_PV_CALLER           13   /* caller provides PV here */
50
51
52 #define REG_METHODPTR    2   /* pointer to the place from where the procedure */
53                              /* vector has been fetched         */
54                              
55                              
56 #define REG_ITMP1        1   /* temporary register (scratch)                  */
57 #define REG_ITMP2        2   /* temporary register (application)              */
58 #define REG_ITMP3        3   /* temporary register (application)              */
59
60 #define REG_ITMP2_XPTR   2   /* exception pointer = temporary register 2      */
61 #define REG_ITMP3_XPC    3   /* exception pc = temporary register 3           */
62
63 #define REG_SP          14   /* stack pointer                                 */
64 #define REG_FP          30   /* frame pointer                                 */
65 #define REG_ZERO         0   /* always zero                                   */
66
67 #define REG_OUT0         8   /* define some argument registers                */
68 #define REG_OUT1         9
69 #define REG_OUT2        10
70 #define REG_OUT3        11
71 #define REG_OUT4        12
72 #define REG_OUT5        13   /* available only when doing a C-call            */
73
74 /* floating point registers */
75 /* only using the lower half of the floating registers for now */
76
77
78 #define REG_FRESULT      0   /* to deliver floating point method results      */
79
80 #define REG_FTMP1        1   /* temporary floating point register             */
81 #define REG_FTMP2        2   /* temporary floating point register             */
82 #define REG_FTMP3        3   /* temporary floating point register             */
83
84 #define REG_IFTMP        1   /* temporary integer and floating point register */
85
86
87 #define INT_REG_CNT     32   /* number of integer registers                   */
88 #define INT_SAV_CNT     12   /* number of int callee saved registers          */
89 #define INT_ARG_CNT      5   /* number of int argument registers (-1 for PV)  */
90 #define INT_TMP_CNT      0   /* int temp registers (%g4-%g5)                  */
91 #define INT_RES_CNT     14   /* number of reserved integer registers          */
92                              /* pv, zero, %g6, %g7, sp, ra                    */
93
94 #define FLT_REG_CNT     16   /* number of float registers                     */
95 #define FLT_SAV_CNT      0   /* number of flt callee saved registers          */
96 #define FLT_ARG_CNT      5   /* number of flt argument registers              */
97 #define FLT_TMP_CNT      7   /* number of flt temp registers                  */
98 #define FLT_RES_CNT      3   /* number of reserved float registers            */
99                              /* the one "missing" register is the return reg  */
100                              
101 /* different argument counts when following the ABI for native functions */
102 #define INT_NATARG_CNT   6
103 #define FLT_NATARG_CNT  16
104
105 #define TRACE_ARGS_NUM   6
106
107 /* helpers for stack addressing and window handling */
108
109 #define BIAS          2047    /* SPARC V9: stack @ address SP + BIAS           */
110
111 /* SPARC ABI always wants argument slots on the stack, even when not used */
112
113 #define WINSAVE_CNT     16    /* number of regs that SPARC saves onto stack    */
114 #define ABIPARAMS_CNT    6    /* param slots the ABI always requires on stack  */
115
116 #define JITSTACK_CNT    (WINSAVE_CNT + ABIPARAMS_CNT)
117 #define CSTACK_CNT      (WINSAVE_CNT + ABIPARAMS_CNT)
118
119 #define JITSTACK        ((JITSTACK_CNT) * 8 + BIAS)
120 #define CSTACK          ((CSTACK_CNT) * 8 + BIAS)
121
122
123
124 /* applies when the caller's window was saved */
125 #define REG_WINDOW_TRANSPOSE(reg) \
126         (reg + 16)
127
128 #endif /* _MD_ABI_H */
129
130
131 /*
132  * These are local overrides for various environment variables in Emacs.
133  * Please do not remove this and leave it at the end of the file, where
134  * Emacs will automagically detect them.
135  * ---------------------------------------------------------------------
136  * Local variables:
137  * mode: c
138  * indent-tabs-mode: t
139  * c-basic-offset: 4
140  * tab-width: 4
141  * End:
142  * vim:noexpandtab:sw=4:ts=4:
143  */