1 /* src/vm/jit/mips/md.h - machine dependent MIPS functions
3 Copyright (C) 1996-2005, 2006, 2007 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
28 #ifndef _VM_JIT_MIPS_MD_H
29 #define _VM_JIT_MIPS_MD_H
36 #include <sys/cachectl.h>
43 /* md_stacktrace_get_returnaddress *********************************************
45 Returns the return address of the current stackframe, specified by
46 the passed stack pointer and the stack frame size.
48 *******************************************************************************/
50 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
54 /* On MIPS the return address is located on the top of the
57 ra = *((void **) (((uintptr_t) sp) + stackframesize - 8));
63 /* md_codegen_get_pv_from_pc ***************************************************
69 27feff9c addiu s8,ra,-100
71 *******************************************************************************/
73 inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
79 /* get the offset of the instructions */
81 /* get first instruction word after jump */
85 /* check if we have 2 instructions (lui, daddiu) */
87 if ((mcode >> 16) == 0x3c19) {
88 /* get displacement of first instruction (lui) */
90 offset = (s4) (mcode << 16);
92 /* get displacement of second instruction (daddiu) */
94 mcode = *((u4 *) (ra + 1 * 4));
96 #if SIZEOF_VOID_P == 8
97 assert((mcode >> 16) == 0x6739);
99 assert((mcode >> 16) == 0x2739);
102 offset += (s2) (mcode & 0x0000ffff);
105 /* get offset of first instruction (daddiu) */
107 mcode = *((u4 *) ra);
109 #if SIZEOF_VOID_P == 8
110 assert((mcode >> 16) == 0x67fe);
112 assert((mcode >> 16) == 0x27fe);
115 offset = (s2) (mcode & 0x0000ffff);
118 /* calculate PV via RA + offset */
126 /* md_cacheflush ***************************************************************
128 Calls the system's function to flush the instruction and data
131 *******************************************************************************/
133 inline static void md_cacheflush(void *addr, int nbytes)
135 cacheflush(addr, nbytes, BCACHE);
139 /* md_icacheflush **************************************************************
141 Calls the system's function to flush the instruction cache.
143 *******************************************************************************/
145 inline static void md_icacheflush(void *addr, int nbytes)
147 cacheflush(addr, nbytes, ICACHE);
151 /* md_dcacheflush **************************************************************
153 Calls the system's function to flush the data cache.
155 *******************************************************************************/
157 inline static void md_dcacheflush(void *addr, int nbytes)
159 cacheflush(addr, nbytes, DCACHE);
162 #endif /* _VM_JIT_MIPS_MD_H */
166 * These are local overrides for various environment variables in Emacs.
167 * Please do not remove this and leave it at the end of the file, where
168 * Emacs will automagically detect them.
169 * ---------------------------------------------------------------------
172 * indent-tabs-mode: t
176 * vim:noexpandtab:sw=4:ts=4: