1 /* src/vm/jit/alpha/md.h - machine dependent Alpha 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_ALPHA_MD_H
27 #define _VM_JIT_ALPHA_MD_H
34 #include "vm/jit/alpha/codegen.h"
36 #include "vm/global.h"
39 #include "vm/jit/asmpart.h"
40 #include "vm/jit/codegen-common.hpp"
43 /* global variables ***********************************************************/
45 extern bool has_ext_instr_set;
48 /* inline functions ***********************************************************/
51 * Returns the size (in bytes) of the current stackframe, specified by
52 * the passed codeinfo structure.
54 inline static int32_t md_stacktrace_get_framesize(codeinfo* code)
56 // Check for the asm_vm_call_method special case.
60 // On Alpha we use 8-byte stackslots.
61 return code->stackframesize * 8;
65 /* md_stacktrace_get_returnaddress *********************************************
67 Returns the return address of the current stackframe, specified by
68 the passed stack pointer and the stack frame size.
70 *******************************************************************************/
72 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
76 /* On Alpha the return address is located on the top of the
79 ra = *((void **) (((uintptr_t) sp) + stackframesize - SIZEOF_VOID_P));
85 /* md_codegen_get_pv_from_pc ***************************************************
90 277afffe ldah pv,-2(ra)
91 237ba61c lda pv,-23012(pv)
93 *******************************************************************************/
95 inline static void *md_codegen_get_pv_from_pc(void *ra)
103 pc = (uint32_t *) ra;
105 /* Get first instruction word after jump. */
109 /* Get opcode and displacement. */
111 opcode = M_MEM_GET_Opcode(mcode);
112 disp = M_MEM_GET_Memory_disp(mcode);
114 /* Check for short or long load (2 instructions). */
117 case 0x08: /* LDA: TODO use define */
118 assert((mcode >> 16) == 0x237a);
120 pv = ((uint8_t *) pc) + disp;
123 case 0x09: /* LDAH: TODO use define */
124 pv = ((uint8_t *) pc) + (disp << 16);
126 /* Get displacement of second instruction (LDA). */
130 assert((mcode >> 16) == 0x237b);
132 disp = M_MEM_GET_Memory_disp(mcode);
134 pv = ((uint8_t *) pv) + disp;
138 vm_abort_disassemble(pc, 2, "md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
146 /* md_cacheflush ***************************************************************
148 Calls the system's function to flush the instruction and data
151 *******************************************************************************/
153 inline static void md_cacheflush(void *addr, int nbytes)
155 asm_cacheflush(addr, nbytes);
159 /* md_icacheflush **************************************************************
161 Calls the system's function to flush the instruction cache.
163 *******************************************************************************/
165 inline static void md_icacheflush(void *addr, int nbytes)
167 asm_cacheflush(addr, nbytes);
171 /* md_dcacheflush **************************************************************
173 Calls the system's function to flush the data cache.
175 *******************************************************************************/
177 inline static void md_dcacheflush(void *addr, int nbytes)
182 #endif /* _VM_JIT_ALPHA_MD_H */
186 * These are local overrides for various environment variables in Emacs.
187 * Please do not remove this and leave it at the end of the file, where
188 * Emacs will automagically detect them.
189 * ---------------------------------------------------------------------
192 * indent-tabs-mode: t