root / dyngen-exec.h @ 2c50e26e
History | View | Annotate | Download (3 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 | ec530c81 | bellard | /* prevent Solaris from trying to typedef FILE in gcc's
|
23 | ec530c81 | bellard | include/floatingpoint.h which will conflict with the
|
24 | ec530c81 | bellard | definition down below */
|
25 | ec530c81 | bellard | #ifdef __sun__
|
26 | ec530c81 | bellard | #define _FILEDEFED
|
27 | ec530c81 | bellard | #endif
|
28 | ec530c81 | bellard | |
29 | 1e6cae95 | bellard | /* NOTE: standard headers should be used with special care at this
|
30 | 1e6cae95 | bellard | point because host CPU registers are used as global variables. Some
|
31 | 1e6cae95 | bellard | host headers do not allow that. */
|
32 | 513b500f | bellard | #include <stddef.h> |
33 | b7df4bcc | aurel32 | #include <stdint.h> |
34 | 11165820 | Paul Brook | #include <stdbool.h> |
35 | 513b500f | bellard | |
36 | 128ab2ff | blueswir1 | #ifdef __OpenBSD__
|
37 | 128ab2ff | blueswir1 | #include <sys/types.h> |
38 | 128ab2ff | blueswir1 | #endif
|
39 | 79638566 | bellard | |
40 | 1057eaa7 | pbrook | /* XXX: This may be wrong for 64-bit ILP32 hosts. */
|
41 | c227f099 | Anthony Liguori | typedef void * host_reg_t; |
42 | 1057eaa7 | pbrook | |
43 | 71e72a19 | Juan Quintela | #ifdef CONFIG_BSD
|
44 | cce1075c | ths | typedef struct __sFILE FILE; |
45 | cce1075c | ths | #else
|
46 | 79638566 | bellard | typedef struct FILE FILE; |
47 | cce1075c | ths | #endif
|
48 | 79638566 | bellard | extern int fprintf(FILE *, const char *, ...); |
49 | 24c7b0e3 | ths | extern int fputs(const char *, FILE *); |
50 | 79638566 | bellard | extern int printf(const char *, ...); |
51 | 79638566 | bellard | |
52 | 522777bb | ths | #if defined(__i386__)
|
53 | 79638566 | bellard | #define AREG0 "ebp" |
54 | 522777bb | ths | #elif defined(__x86_64__)
|
55 | 43024c6a | ths | #define AREG0 "r14" |
56 | e58ffeb3 | malc | #elif defined(_ARCH_PPC)
|
57 | 79638566 | bellard | #define AREG0 "r27" |
58 | 522777bb | ths | #elif defined(__arm__)
|
59 | 79638566 | bellard | #define AREG0 "r7" |
60 | f54b3f92 | aurel32 | #elif defined(__hppa__)
|
61 | f54b3f92 | aurel32 | #define AREG0 "r17" |
62 | 522777bb | ths | #elif defined(__mips__)
|
63 | 60bf84cf | Stefan Weil | #define AREG0 "s0" |
64 | 522777bb | ths | #elif defined(__sparc__)
|
65 | dfe5fff3 | Juan Quintela | #ifdef CONFIG_SOLARIS
|
66 | fdbb4691 | bellard | #define AREG0 "g2" |
67 | fdbb4691 | bellard | #else
|
68 | 74ccb34e | bellard | #ifdef __sparc_v9__
|
69 | e97b640d | blueswir1 | #define AREG0 "g5" |
70 | 74ccb34e | bellard | #else
|
71 | 79638566 | bellard | #define AREG0 "g6" |
72 | fdbb4691 | bellard | #endif
|
73 | 74ccb34e | bellard | #endif
|
74 | 522777bb | ths | #elif defined(__s390__)
|
75 | 79638566 | bellard | #define AREG0 "r10" |
76 | 522777bb | ths | #elif defined(__alpha__)
|
77 | 79638566 | bellard | /* Note $15 is the frame pointer, so anything in op-i386.c that would
|
78 | 79638566 | bellard | require a frame pointer, like alloca, would probably loose. */
|
79 | 79638566 | bellard | #define AREG0 "$15" |
80 | 522777bb | ths | #elif defined(__mc68000)
|
81 | 38e584a0 | bellard | #define AREG0 "%a5" |
82 | 522777bb | ths | #elif defined(__ia64__)
|
83 | b8076a74 | bellard | #define AREG0 "r7" |
84 | 522777bb | ths | #else
|
85 | 522777bb | ths | #error unsupported CPU
|
86 | 79638566 | bellard | #endif
|
87 | 79638566 | bellard | |
88 | 79638566 | bellard | #define xglue(x, y) x ## y |
89 | 79638566 | bellard | #define glue(x, y) xglue(x, y)
|
90 | 9621339d | bellard | #define stringify(s) tostring(s)
|
91 | 9621339d | bellard | #define tostring(s) #s |
92 | 79638566 | bellard | |
93 | 9b7b85d2 | pbrook | /* The return address may point to the start of the next instruction.
|
94 | 9b7b85d2 | pbrook | Subtracting one gets us the call instruction itself. */
|
95 | 2827822e | Alexander Graf | #if defined(__s390__) && !defined(__s390x__)
|
96 | 9b7b85d2 | pbrook | # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1)) |
97 | 9b7b85d2 | pbrook | #elif defined(__arm__)
|
98 | 9b7b85d2 | pbrook | /* Thumb return addresses have the low bit set, so we need to subtract two.
|
99 | 9b7b85d2 | pbrook | This is still safe in ARM mode because instructions are 4 bytes. */
|
100 | 9b7b85d2 | pbrook | # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2)) |
101 | 9b7b85d2 | pbrook | #else
|
102 | 9b7b85d2 | pbrook | # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1)) |
103 | 9b7b85d2 | pbrook | #endif
|
104 | 9b7b85d2 | pbrook | |
105 | 67867308 | bellard | #endif /* !defined(__DYNGEN_EXEC_H__) */ |