bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [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 |
Blue Swirl | 8167ee8 | 2009-07-16 20:47:01 +0000 | [diff] [blame] | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 18 | */ |
bellard | 6786730 | 2003-11-23 17:05:30 +0000 | [diff] [blame] | 19 | #if !defined(__DYNGEN_EXEC_H__) |
| 20 | #define __DYNGEN_EXEC_H__ |
| 21 | |
Stefan Weil | 47b01cf | 2010-10-13 20:54:26 +0200 | [diff] [blame] | 22 | #include "qemu-common.h" |
bellard | 513b500 | 2004-01-04 17:44:08 +0000 | [diff] [blame] | 23 | |
blueswir1 | 128ab2f | 2008-08-15 18:33:42 +0000 | [diff] [blame] | 24 | #ifdef __OpenBSD__ |
| 25 | #include <sys/types.h> |
blueswir1 | 128ab2f | 2008-08-15 18:33:42 +0000 | [diff] [blame] | 26 | #endif |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 27 | |
pbrook | 1057eaa | 2007-02-04 13:37:44 +0000 | [diff] [blame] | 28 | /* XXX: This may be wrong for 64-bit ILP32 hosts. */ |
Anthony Liguori | c227f09 | 2009-10-01 16:12:16 -0500 | [diff] [blame] | 29 | typedef void * host_reg_t; |
pbrook | 1057eaa | 2007-02-04 13:37:44 +0000 | [diff] [blame] | 30 | |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 31 | #if defined(__i386__) |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 32 | #define AREG0 "ebp" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 33 | #elif defined(__x86_64__) |
ths | 43024c6 | 2007-02-10 18:21:04 +0000 | [diff] [blame] | 34 | #define AREG0 "r14" |
malc | e58ffeb | 2009-01-14 18:39:49 +0000 | [diff] [blame] | 35 | #elif defined(_ARCH_PPC) |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 36 | #define AREG0 "r27" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 37 | #elif defined(__arm__) |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 38 | #define AREG0 "r7" |
aurel32 | f54b3f9 | 2008-04-12 20:14:54 +0000 | [diff] [blame] | 39 | #elif defined(__hppa__) |
| 40 | #define AREG0 "r17" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 41 | #elif defined(__mips__) |
Stefan Weil | 60bf84c | 2010-04-09 17:28:40 +0200 | [diff] [blame] | 42 | #define AREG0 "s0" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 43 | #elif defined(__sparc__) |
Juan Quintela | dfe5fff | 2009-07-27 16:12:40 +0200 | [diff] [blame] | 44 | #ifdef CONFIG_SOLARIS |
bellard | fdbb469 | 2006-06-14 17:32:25 +0000 | [diff] [blame] | 45 | #define AREG0 "g2" |
bellard | fdbb469 | 2006-06-14 17:32:25 +0000 | [diff] [blame] | 46 | #else |
bellard | 74ccb34 | 2006-07-18 21:23:34 +0000 | [diff] [blame] | 47 | #ifdef __sparc_v9__ |
blueswir1 | e97b640 | 2008-07-26 17:19:35 +0000 | [diff] [blame] | 48 | #define AREG0 "g5" |
bellard | 74ccb34 | 2006-07-18 21:23:34 +0000 | [diff] [blame] | 49 | #else |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 50 | #define AREG0 "g6" |
bellard | fdbb469 | 2006-06-14 17:32:25 +0000 | [diff] [blame] | 51 | #endif |
bellard | 74ccb34 | 2006-07-18 21:23:34 +0000 | [diff] [blame] | 52 | #endif |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 53 | #elif defined(__s390__) |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 54 | #define AREG0 "r10" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 55 | #elif defined(__alpha__) |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 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" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 59 | #elif defined(__mc68000) |
bellard | 38e584a | 2003-08-10 22:14:22 +0000 | [diff] [blame] | 60 | #define AREG0 "%a5" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 61 | #elif defined(__ia64__) |
bellard | b8076a7 | 2005-04-07 22:20:31 +0000 | [diff] [blame] | 62 | #define AREG0 "r7" |
ths | 522777b | 2007-05-08 23:30:44 +0000 | [diff] [blame] | 63 | #else |
| 64 | #error unsupported CPU |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 65 | #endif |
| 66 | |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 67 | #define xglue(x, y) x ## y |
| 68 | #define glue(x, y) xglue(x, y) |
bellard | 9621339 | 2003-07-11 15:17:41 +0000 | [diff] [blame] | 69 | #define stringify(s) tostring(s) |
| 70 | #define tostring(s) #s |
bellard | 7963856 | 2003-06-15 19:46:57 +0000 | [diff] [blame] | 71 | |
pbrook | 9b7b85d | 2008-05-25 00:36:06 +0000 | [diff] [blame] | 72 | /* The return address may point to the start of the next instruction. |
| 73 | Subtracting one gets us the call instruction itself. */ |
Alexander Graf | 2827822 | 2009-12-05 12:44:23 +0100 | [diff] [blame] | 74 | #if defined(__s390__) && !defined(__s390x__) |
pbrook | 9b7b85d | 2008-05-25 00:36:06 +0000 | [diff] [blame] | 75 | # 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 | |
bellard | 6786730 | 2003-11-23 17:05:30 +0000 | [diff] [blame] | 84 | #endif /* !defined(__DYNGEN_EXEC_H__) */ |