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/sparc64/codegen.h"
42 #include "vm/jit/sparc64/emit.h"
45 /* code generation functions **************************************************/
47 /* emit_load_s1 ****************************************************************
49 Emits a possible load of the first source operand.
51 *******************************************************************************/
53 s4 emit_load_s1(jitdata *jd, instruction *iptr, stackptr src, s4 tempreg)
58 /* get required compiler data */
62 if (src->flags & INMEMORY) {
65 if (IS_FLT_DBL_TYPE(src->type))
66 M_LDDF(REG_SP, src->regoff * 8, tempreg);
68 M_LDX(REG_SP, src->regoff * 8, tempreg);
78 /* emit_load_s2 ****************************************************************
80 Emits a possible load of the second source operand.
82 *******************************************************************************/
84 s4 emit_load_s2(jitdata *jd, instruction *iptr, stackptr src, s4 tempreg)
89 /* get required compiler data */
93 if (src->flags & INMEMORY) {
96 if (IS_FLT_DBL_TYPE(src->type))
97 M_LDDF(REG_SP, src->regoff * 8, tempreg);
99 M_LDX(REG_SP, src->regoff * 8, tempreg);
109 /* emit_load_s3 ****************************************************************
111 Emits a possible load of the third source operand.
113 *******************************************************************************/
115 s4 emit_load_s3(jitdata *jd, instruction *iptr, stackptr src, s4 tempreg)
120 /* get required compiler data */
124 if (src->flags & INMEMORY) {
127 if (IS_FLT_DBL_TYPE(src->type))
128 M_LDDF(REG_SP, src->regoff * 8, tempreg);
130 M_LDX(REG_SP, src->regoff * 8, tempreg);
140 /* emit_store ******************************************************************
144 *******************************************************************************/
146 void emit_store(jitdata *jd, instruction *iptr, stackptr dst, s4 d)
150 /* get required compiler data */
154 if (dst->flags & INMEMORY) {
157 if (IS_FLT_DBL_TYPE(dst->type))
158 M_STDF(d, REG_SP, dst->regoff * 8);
160 M_STX(d, REG_SP, dst->regoff * 8);
165 void emit_copy(jitdata *jd, instruction *iptr, stackptr src, stackptr dst)
171 /* get required compiler data */
176 d = codegen_reg_of_var(rd, iptr->opc, dst, REG_IFTMP);
178 if ((src->regoff != dst->regoff) ||
179 ((src->flags ^ dst->flags) & INMEMORY)) {
180 s1 = emit_load_s1(jd, iptr, src, d);
182 if (IS_FLT_DBL_TYPE(src->type)) {
183 /* always move doubles for now */
189 emit_store(jd, iptr, dst, d);
194 void emit_iconst(codegendata *cd, s4 d, s4 value)
198 if ((value >= -4096) && (value <= 4095)) {
199 M_IOR(REG_ZERO, value, d, IMM);
201 disp = dseg_adds4(cd, value);
202 M_ILD(d, REG_PV, disp);
208 * These are local overrides for various environment variables in Emacs.
209 * Please do not remove this and leave it at the end of the file, where
210 * Emacs will automagically detect them.
211 * ---------------------------------------------------------------------
214 * indent-tabs-mode: t
218 * vim:noexpandtab:sw=4:ts=4: