The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 1 | /* |
| 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' Turner | 2910f18 | 2010-05-10 18:48:35 -0700 | [diff] [blame] | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 18 | */ |
| 19 | #if !defined(__DYNGEN_EXEC_H__) |
| 20 | #define __DYNGEN_EXEC_H__ |
| 21 | |
David 'Digit' Turner | 45c3be0 | 2011-05-09 14:52:14 +0200 | [diff] [blame] | 22 | #include "qemu-common.h" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 23 | |
| 24 | #ifdef __OpenBSD__ |
| 25 | #include <sys/types.h> |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 26 | #endif |
| 27 | |
| 28 | /* XXX: This may be wrong for 64-bit ILP32 hosts. */ |
| 29 | typedef void * host_reg_t; |
| 30 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 31 | #if defined(__i386__) |
| 32 | #define AREG0 "ebp" |
| 33 | #define AREG1 "ebx" |
| 34 | #define AREG2 "esi" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 35 | #elif defined(__x86_64__) |
| 36 | #define AREG0 "r14" |
| 37 | #define AREG1 "r15" |
| 38 | #define AREG2 "r12" |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 39 | #elif defined(_ARCH_PPC) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 40 | #define AREG0 "r27" |
| 41 | #define AREG1 "r24" |
| 42 | #define AREG2 "r25" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 43 | #elif defined(__arm__) |
| 44 | #define AREG0 "r7" |
| 45 | #define AREG1 "r4" |
| 46 | #define AREG2 "r5" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 47 | #elif defined(__hppa__) |
| 48 | #define AREG0 "r17" |
| 49 | #define AREG1 "r14" |
| 50 | #define AREG2 "r15" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 51 | #elif defined(__mips__) |
| 52 | #define AREG0 "fp" |
| 53 | #define AREG1 "s0" |
| 54 | #define AREG2 "s1" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 55 | #elif defined(__sparc__) |
David 'Digit' Turner | 2c538c8 | 2010-05-10 16:48:20 -0700 | [diff] [blame] | 56 | #ifdef CONFIG_SOLARIS |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 57 | #define AREG0 "g2" |
| 58 | #define AREG1 "g3" |
| 59 | #define AREG2 "g4" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 60 | #else |
| 61 | #ifdef __sparc_v9__ |
| 62 | #define AREG0 "g5" |
| 63 | #define AREG1 "g6" |
| 64 | #define AREG2 "g7" |
| 65 | #else |
| 66 | #define AREG0 "g6" |
| 67 | #define AREG1 "g1" |
| 68 | #define AREG2 "g2" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 69 | #endif |
| 70 | #endif |
| 71 | #elif defined(__s390__) |
| 72 | #define AREG0 "r10" |
| 73 | #define AREG1 "r7" |
| 74 | #define AREG2 "r8" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 75 | #elif defined(__alpha__) |
| 76 | /* Note $15 is the frame pointer, so anything in op-i386.c that would |
| 77 | require a frame pointer, like alloca, would probably loose. */ |
| 78 | #define AREG0 "$15" |
| 79 | #define AREG1 "$9" |
| 80 | #define AREG2 "$10" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 81 | #elif defined(__mc68000) |
| 82 | #define AREG0 "%a5" |
| 83 | #define AREG1 "%a4" |
| 84 | #define AREG2 "%d7" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 85 | #elif defined(__ia64__) |
| 86 | #define AREG0 "r7" |
| 87 | #define AREG1 "r4" |
| 88 | #define AREG2 "r5" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 89 | #else |
| 90 | #error unsupported CPU |
| 91 | #endif |
| 92 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 93 | #define xglue(x, y) x ## y |
| 94 | #define glue(x, y) xglue(x, y) |
| 95 | #define stringify(s) tostring(s) |
| 96 | #define tostring(s) #s |
| 97 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 98 | /* The return address may point to the start of the next instruction. |
| 99 | Subtracting one gets us the call instruction itself. */ |
David 'Digit' Turner | 2910f18 | 2010-05-10 18:48:35 -0700 | [diff] [blame] | 100 | #if defined(__s390__) && !defined(__s390x__) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 101 | # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1)) |
| 102 | #elif defined(__arm__) |
| 103 | /* Thumb return addresses have the low bit set, so we need to subtract two. |
| 104 | This is still safe in ARM mode because instructions are 4 bytes. */ |
| 105 | # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2)) |
| 106 | #else |
| 107 | # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1)) |
| 108 | #endif |
| 109 | |
| 110 | #endif /* !defined(__DYNGEN_EXEC_H__) */ |