1 /* src/vm/jit/powerpc/md.h - machine dependent PowerPC functions
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #ifndef _VM_JIT_POWERPC_MD_H
27 #define _VM_JIT_POWERPC_MD_H
34 #include "vm/jit/powerpc/codegen.h"
36 #include "vm/global.h"
39 #include "vm/jit/asmpart.h"
40 #include "vm/jit/codegen-common.hpp"
44 * Returns the size (in bytes) of the current stackframe, specified by
45 * the passed codeinfo structure.
47 inline static int32_t md_stacktrace_get_framesize(codeinfo* code)
49 // Check for the asm_vm_call_method special case.
53 // On PowerPC we use 8-byte stackslots.
54 return code->stackframesize * 8;
58 /* md_stacktrace_get_returnaddress *********************************************
60 Returns the return address of the current stackframe, specified by
61 the passed stack pointer and the stack frame size.
63 *******************************************************************************/
65 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
69 /* Pn PowerPC the return address is located in the linkage
72 ra = *((void **) (((uintptr_t) sp) + stackframesize + LA_LR_OFFSET));
78 /* md_codegen_get_pv_from_pc ***************************************************
83 39abffe0 addi r13,r11,-32
88 3dabffff addis r13,r11,-1
89 39ad68b0 addi r13,r13,26800
91 *******************************************************************************/
93 inline static void* md_codegen_get_pv_from_pc(void* ra)
97 uint32_t* pc = (uint32_t*) ra;
99 /* get first instruction word after jump */
101 uint32_t mcode = pc[1];
103 /* check if we have 2 instructions (addis, addi) */
105 if ((mcode >> 16) == 0x3dab) {
106 /* get displacement of first instruction (addis) */
108 offset = (int32_t) (mcode << 16);
110 /* get displacement of second instruction (addi) */
114 /* check for addi instruction */
116 assert((mcode >> 16) == 0x39ad);
118 offset += (int16_t) (mcode & 0x0000ffff);
121 /* check for addi instruction */
123 assert((mcode >> 16) == 0x39ab);
125 /* get offset of first instruction (addi) */
127 offset = (int16_t) (mcode & 0x0000ffff);
130 /* calculate PV via RA + offset */
132 void* pv = (void*) (((uintptr_t) ra) + offset);
138 /* md_cacheflush ***************************************************************
140 Calls the system's function to flush the instruction and data
143 *******************************************************************************/
145 inline static void md_cacheflush(void *addr, int nbytes)
147 asm_cacheflush(addr, nbytes);
151 /* md_icacheflush **************************************************************
153 Calls the system's function to flush the instruction cache.
155 *******************************************************************************/
157 inline static void md_icacheflush(void *addr, int nbytes)
159 asm_cacheflush(addr, nbytes);
163 /* md_dcacheflush **************************************************************
165 Calls the system's function to flush the data cache.
167 *******************************************************************************/
169 inline static void md_dcacheflush(void *addr, int nbytes)
171 asm_cacheflush(addr, nbytes);
174 #endif /* _VM_JIT_POWERPC_MD_H */
178 * These are local overrides for various environment variables in Emacs.
179 * Please do not remove this and leave it at the end of the file, where
180 * Emacs will automagically detect them.
181 * ---------------------------------------------------------------------
184 * indent-tabs-mode: t
188 * vim:noexpandtab:sw=4:ts=4: