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"
47 /* emit_load *******************************************************************
49 Emits a possible load of an operand.
51 *******************************************************************************/
53 s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
59 /* get required compiler data */
63 if (src->flags & INMEMORY) {
66 disp = src->vv.regoff * 8;
68 if (IS_FLT_DBL_TYPE(src->type))
69 M_DLD(tempreg, REG_SP, disp);
71 M_LDX(tempreg, REG_SP, disp);
82 /* emit_store ******************************************************************
84 Emits a possible store to variable.
86 *******************************************************************************/
88 void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
93 /* get required compiler data */
97 if (dst->flags & INMEMORY) {
100 disp = dst->vv.regoff * 8;
102 if (IS_FLT_DBL_TYPE(dst->type))
103 M_DST(d, REG_SP, disp);
105 M_STX(d, REG_SP, disp);
110 /* emit_copy *******************************************************************
112 Generates a register/memory to register/memory copy.
114 *******************************************************************************/
116 void emit_copy(jitdata *jd, instruction *iptr, varinfo *src, varinfo *dst)
122 /* get required compiler data */
127 if ((src->vv.regoff != dst->vv.regoff) ||
128 ((src->flags ^ dst->flags) & INMEMORY)) {
130 /* If one of the variables resides in memory, we can eliminate
131 the register move from/to the temporary register with the
132 order of getting the destination register and the load. */
134 if (IS_INMEMORY(src->flags)) {
135 d = codegen_reg_of_var(iptr->opc, dst, REG_IFTMP);
136 s1 = emit_load(jd, iptr, src, d);
139 s1 = emit_load(jd, iptr, src, REG_IFTMP);
140 d = codegen_reg_of_var(iptr->opc, dst, s1);
144 if (IS_FLT_DBL_TYPE(src->type))
150 emit_store(jd, iptr, dst, d);
155 /* emit_iconst *****************************************************************
159 *******************************************************************************/
161 void emit_iconst(codegendata *cd, s4 d, s4 value)
165 if ((value >= -4096) && (value <= 4095)) {
166 M_XOR(REG_ZERO, value, d);
168 disp = dseg_adds4(cd, value);
169 M_ILD(d, REG_PV_CALLEE, disp);
174 /* emit_lconst *****************************************************************
178 *******************************************************************************/
180 void emit_lconst(codegendata *cd, s4 d, s8 value)
184 if ((value >= -4096) && (value <= 4095)) {
185 M_XOR(REG_ZERO, value, d);
187 disp = dseg_adds8(cd, value);
188 M_LDX(d, REG_PV_CALLEE, disp);
193 /* emit_exception_stubs ********************************************************
195 Generates the code for the exception stubs.
197 *******************************************************************************/
199 void emit_exception_stubs(jitdata *jd)
203 /* emit_patcher_stubs **********************************************************
205 Generates the code for the patcher stubs.
207 *******************************************************************************/
209 void emit_patcher_stubs(jitdata *jd)
213 /* emit_replacement_stubs ******************************************************
215 Generates the code for the replacement stubs.
217 *******************************************************************************/
219 void emit_replacement_stubs(jitdata *jd)
225 * These are local overrides for various environment variables in Emacs.
226 * Please do not remove this and leave it at the end of the file, where
227 * Emacs will automagically detect them.
228 * ---------------------------------------------------------------------
231 * indent-tabs-mode: t
235 * vim:noexpandtab:sw=4:ts=4: