1 /* src/vm/jit/powerpc64/md.h - machine dependent PowerPC 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_POWERPC64_MD_H
29 #define _VM_JIT_POWERPC64_MD_H
36 #include "vm/jit/powerpc64/codegen.h"
38 #include "vm/global.h"
41 #include "vm/jit/asmpart.h"
42 #include "vm/jit/jit.h"
45 /* md_stacktrace_get_returnaddress *********************************************
47 Returns the return address of the current stackframe, specified by
48 the passed stack pointer and the stack frame size.
50 *******************************************************************************/
52 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
56 /* On PowerPC64 the return address is located in the linkage
59 ra = *((void **) (((uintptr_t) sp) + stackframesize + LA_LR_OFFSET));
65 /* md_codegen_get_pv_from_pc ***************************************************
70 39cbffe0 addi r14,r11,-32
75 3dcbffff addis r14,r11,-1
76 39ce68b0 addi r14,r13,26800
78 *******************************************************************************/
80 inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
86 /* get first instruction word after jump */
88 mcode = *((u4 *) (ra + 1 * 4));
90 /* check if we have 2 instructions (addis, addi) */
92 if ((mcode >> 16) == 0x3dcb) {
93 /* get displacement of first instruction (addis) */
95 offset = (s4) (mcode << 16);
97 /* get displacement of second instruction (addi) */
99 mcode = *((u4 *) (ra + 2 * 4));
101 /* check for addi instruction */
103 assert((mcode >> 16) == 0x39ce);
105 offset += (s2) (mcode & 0x0000ffff);
107 else if ((mcode >> 16) == 0x39cb) {
108 /* get offset of first instruction (addi) */
110 offset = (s2) (mcode & 0x0000ffff);
113 vm_abort("md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
115 /* keep compiler happy */
120 /* calculate PV via RA + offset */
128 /* md_cacheflush ***************************************************************
130 Calls the system's function to flush the instruction and data
133 *******************************************************************************/
135 inline static void md_cacheflush(void *addr, int nbytes)
137 asm_cacheflush(addr, nbytes);
141 /* md_icacheflush **************************************************************
143 Calls the system's function to flush the instruction cache.
145 *******************************************************************************/
147 inline static void md_icacheflush(void *addr, int nbytes)
149 asm_cacheflush(addr, nbytes);
153 /* md_dcacheflush **************************************************************
155 Calls the system's function to flush the data cache.
157 *******************************************************************************/
159 inline static void md_dcacheflush(void *addr, int nbytes)
161 asm_cacheflush(addr, nbytes);
164 #endif /* _VM_JIT_POWERPC64_MD_H */
168 * These are local overrides for various environment variables in Emacs.
169 * Please do not remove this and leave it at the end of the file, where
170 * Emacs will automagically detect them.
171 * ---------------------------------------------------------------------
174 * indent-tabs-mode: t
178 * vim:noexpandtab:sw=4:ts=4: