Statistics
| Branch: | Revision:

root / dyngen-exec.h @ 9f4facbc

History | View | Annotate | Download (2.2 kB)

1 79638566 bellard
/*
2 79638566 bellard
 *  dyngen defines for micro operation code
3 79638566 bellard
 *
4 79638566 bellard
 *  Copyright (c) 2003 Fabrice Bellard
5 79638566 bellard
 *
6 79638566 bellard
 * This library is free software; you can redistribute it and/or
7 79638566 bellard
 * modify it under the terms of the GNU Lesser General Public
8 79638566 bellard
 * License as published by the Free Software Foundation; either
9 79638566 bellard
 * version 2 of the License, or (at your option) any later version.
10 79638566 bellard
 *
11 79638566 bellard
 * This library is distributed in the hope that it will be useful,
12 79638566 bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 79638566 bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 79638566 bellard
 * Lesser General Public License for more details.
15 79638566 bellard
 *
16 79638566 bellard
 * You should have received a copy of the GNU Lesser General Public
17 8167ee88 Blue Swirl
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 79638566 bellard
 */
19 67867308 bellard
#if !defined(__DYNGEN_EXEC_H__)
20 67867308 bellard
#define __DYNGEN_EXEC_H__
21 67867308 bellard
22 522777bb ths
#if defined(__i386__)
23 79638566 bellard
#define AREG0 "ebp"
24 522777bb ths
#elif defined(__x86_64__)
25 43024c6a ths
#define AREG0 "r14"
26 e58ffeb3 malc
#elif defined(_ARCH_PPC)
27 79638566 bellard
#define AREG0 "r27"
28 522777bb ths
#elif defined(__arm__)
29 79638566 bellard
#define AREG0 "r7"
30 f54b3f92 aurel32
#elif defined(__hppa__)
31 f54b3f92 aurel32
#define AREG0 "r17"
32 522777bb ths
#elif defined(__mips__)
33 60bf84cf Stefan Weil
#define AREG0 "s0"
34 522777bb ths
#elif defined(__sparc__)
35 dfe5fff3 Juan Quintela
#ifdef CONFIG_SOLARIS
36 fdbb4691 bellard
#define AREG0 "g2"
37 fdbb4691 bellard
#else
38 74ccb34e bellard
#ifdef __sparc_v9__
39 e97b640d blueswir1
#define AREG0 "g5"
40 74ccb34e bellard
#else
41 79638566 bellard
#define AREG0 "g6"
42 fdbb4691 bellard
#endif
43 74ccb34e bellard
#endif
44 522777bb ths
#elif defined(__s390__)
45 79638566 bellard
#define AREG0 "r10"
46 522777bb ths
#elif defined(__alpha__)
47 79638566 bellard
/* Note $15 is the frame pointer, so anything in op-i386.c that would
48 79638566 bellard
   require a frame pointer, like alloca, would probably loose.  */
49 79638566 bellard
#define AREG0 "$15"
50 522777bb ths
#elif defined(__mc68000)
51 38e584a0 bellard
#define AREG0 "%a5"
52 522777bb ths
#elif defined(__ia64__)
53 b8076a74 bellard
#define AREG0 "r7"
54 522777bb ths
#else
55 522777bb ths
#error unsupported CPU
56 79638566 bellard
#endif
57 79638566 bellard
58 3e457172 Blue Swirl
register CPUState *env asm(AREG0);
59 3e457172 Blue Swirl
60 9b7b85d2 pbrook
/* The return address may point to the start of the next instruction.
61 9b7b85d2 pbrook
   Subtracting one gets us the call instruction itself.  */
62 2827822e Alexander Graf
#if defined(__s390__) && !defined(__s390x__)
63 9b7b85d2 pbrook
# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
64 9b7b85d2 pbrook
#elif defined(__arm__)
65 9b7b85d2 pbrook
/* Thumb return addresses have the low bit set, so we need to subtract two.
66 9b7b85d2 pbrook
   This is still safe in ARM mode because instructions are 4 bytes.  */
67 9b7b85d2 pbrook
# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
68 9b7b85d2 pbrook
#else
69 9b7b85d2 pbrook
# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
70 9b7b85d2 pbrook
#endif
71 9b7b85d2 pbrook
72 67867308 bellard
#endif /* !defined(__DYNGEN_EXEC_H__) */