blob: db00fbae04e20eec0c9bdd84700d5eff336dd2cc [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001/*
2 * dyngen defines for micro operation code
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
David 'Digit' Turner2910f182010-05-10 18:48:35 -070017 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080018 */
19#if !defined(__DYNGEN_EXEC_H__)
20#define __DYNGEN_EXEC_H__
21
David 'Digit' Turner45c3be02011-05-09 14:52:14 +020022#include "qemu-common.h"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080023
24#ifdef __OpenBSD__
25#include <sys/types.h>
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080026#endif
27
28/* XXX: This may be wrong for 64-bit ILP32 hosts. */
29typedef void * host_reg_t;
30
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080031#if defined(__i386__)
32#define AREG0 "ebp"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080033#elif defined(__x86_64__)
34#define AREG0 "r14"
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070035#elif defined(_ARCH_PPC)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080036#define AREG0 "r27"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080037#elif defined(__arm__)
38#define AREG0 "r7"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080039#elif defined(__hppa__)
40#define AREG0 "r17"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080041#elif defined(__mips__)
David 'Digit' Turner52858642011-06-03 13:41:05 +020042#define AREG0 "s0"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080043#elif defined(__sparc__)
David 'Digit' Turner2c538c82010-05-10 16:48:20 -070044#ifdef CONFIG_SOLARIS
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080045#define AREG0 "g2"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080046#else
47#ifdef __sparc_v9__
48#define AREG0 "g5"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080049#else
50#define AREG0 "g6"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080051#endif
52#endif
53#elif defined(__s390__)
54#define AREG0 "r10"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080055#elif defined(__alpha__)
56/* Note $15 is the frame pointer, so anything in op-i386.c that would
57 require a frame pointer, like alloca, would probably loose. */
58#define AREG0 "$15"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080059#elif defined(__mc68000)
60#define AREG0 "%a5"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080061#elif defined(__ia64__)
62#define AREG0 "r7"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080063#else
64#error unsupported CPU
65#endif
66
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080067#define xglue(x, y) x ## y
68#define glue(x, y) xglue(x, y)
69#define stringify(s) tostring(s)
70#define tostring(s) #s
71
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080072/* The return address may point to the start of the next instruction.
73 Subtracting one gets us the call instruction itself. */
David 'Digit' Turner2910f182010-05-10 18:48:35 -070074#if defined(__s390__) && !defined(__s390x__)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080075# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
76#elif defined(__arm__)
77/* Thumb return addresses have the low bit set, so we need to subtract two.
78 This is still safe in ARM mode because instructions are 4 bytes. */
79# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
80#else
81# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
82#endif
83
84#endif /* !defined(__DYNGEN_EXEC_H__) */