1 /* src/vm/jit/sparc64/emit.c - Sparc code emitter functions
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
8 This file is part of CACAO.
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.
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.
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
25 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
32 $Id: emitfuncs.c 4398 2006-01-31 23:43:08Z twisti $
40 #include "vm/jit/jit.h"
41 #include "vm/jit/dseg.h"
42 #include "vm/jit/emit-common.h"
43 #include "vm/jit/sparc64/codegen.h"
46 /* code generation functions **************************************************/
48 /* emit_load *******************************************************************
50 Emits a possible load of an operand.
52 *******************************************************************************/
54 s4 emit_load(jitdata *jd, instruction *iptr, stackptr src, s4 tempreg)
59 /* get required compiler data */
63 if (src->flags & INMEMORY) {
66 if (IS_FLT_DBL_TYPE(src->type))
67 M_DLD(tempreg, REG_SP, src->regoff * 8);
69 M_LDX(tempreg, REG_SP, src->regoff * 8);
80 /* emit_store ******************************************************************
82 Emit a possible store for the given variable.
84 *******************************************************************************/
86 void emit_store(jitdata *jd, instruction *iptr, stackptr dst, s4 d)
90 /* get required compiler data */
94 if (dst->flags & INMEMORY) {
97 if (IS_FLT_DBL_TYPE(dst->type))
98 M_DST(d, REG_SP, dst->regoff * 8);
100 M_STX(d, REG_SP, dst->regoff * 8);
105 /* emit_copy *******************************************************************
107 Generates a register/memory to register/memory copy.
109 *******************************************************************************/
111 void emit_copy(jitdata *jd, instruction *iptr, stackptr src, stackptr dst)
117 /* get required compiler data */
122 if ((src->regoff != dst->regoff) ||
123 ((src->flags ^ dst->flags) & INMEMORY)) {
125 /* If one of the variables resides in memory, we can eliminate
126 the register move from/to the temporary register with the
127 order of getting the destination register and the load. */
129 if (IS_INMEMORY(src->flags)) {
130 d = codegen_reg_of_var(rd, iptr->opc, dst, REG_IFTMP);
131 s1 = emit_load(jd, iptr, src, d);
134 s1 = emit_load(jd, iptr, src, REG_IFTMP);
135 d = codegen_reg_of_var(rd, iptr->opc, dst, s1);
139 if (IS_FLT_DBL_TYPE(src->type))
145 emit_store(jd, iptr, dst, d);
150 /* emit_iconst *****************************************************************
154 *******************************************************************************/
156 void emit_iconst(codegendata *cd, s4 d, s4 value)
160 if ((value >= -4096) && (value <= 4095)) {
161 M_XOR(REG_ZERO, value, d);
163 disp = dseg_adds4(cd, value);
164 M_ILD(d, REG_PV_CALLEE, disp);
169 /* emit_lconst *****************************************************************
173 *******************************************************************************/
175 void emit_lconst(codegendata *cd, s4 d, s8 value)
179 if ((value >= -4096) && (value <= 4095)) {
180 M_XOR(REG_ZERO, value, d);
182 disp = dseg_adds8(cd, value);
183 M_LDX(d, REG_PV_CALLEE, disp);
188 /* emit_exception_stubs ********************************************************
190 Generates the code for the exception stubs.
192 *******************************************************************************/
194 void emit_exception_stubs(jitdata *jd)
198 /* emit_patcher_stubs **********************************************************
200 Generates the code for the patcher stubs.
202 *******************************************************************************/
204 void emit_patcher_stubs(jitdata *jd)
208 /* emit_replacement_stubs ******************************************************
210 Generates the code for the replacement stubs.
212 *******************************************************************************/
214 void emit_replacement_stubs(jitdata *jd)
220 * These are local overrides for various environment variables in Emacs.
221 * Please do not remove this and leave it at the end of the file, where
222 * Emacs will automagically detect them.
223 * ---------------------------------------------------------------------
226 * indent-tabs-mode: t
230 * vim:noexpandtab:sw=4:ts=4: