root / dyngen-exec.h @ 16415335
History | View | Annotate | Download (3.5 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 | 513b500f | bellard | |
35 | 128ab2ff | blueswir1 | #ifdef __OpenBSD__
|
36 | 128ab2ff | blueswir1 | #include <sys/types.h> |
37 | 128ab2ff | blueswir1 | #endif
|
38 | 79638566 | bellard | |
39 | 1057eaa7 | pbrook | /* XXX: This may be wrong for 64-bit ILP32 hosts. */
|
40 | 1057eaa7 | pbrook | typedef void * host_reg_t; |
41 | 1057eaa7 | pbrook | |
42 | 179a2c19 | blueswir1 | #ifdef HOST_BSD
|
43 | cce1075c | ths | typedef struct __sFILE FILE; |
44 | cce1075c | ths | #else
|
45 | 79638566 | bellard | typedef struct FILE FILE; |
46 | cce1075c | ths | #endif
|
47 | 79638566 | bellard | extern int fprintf(FILE *, const char *, ...); |
48 | 24c7b0e3 | ths | extern int fputs(const char *, FILE *); |
49 | 79638566 | bellard | extern int printf(const char *, ...); |
50 | 513b500f | bellard | #undef NULL |
51 | 79638566 | bellard | #define NULL 0 |
52 | 79638566 | bellard | |
53 | 522777bb | ths | #if defined(__i386__)
|
54 | 79638566 | bellard | #define AREG0 "ebp" |
55 | 79638566 | bellard | #define AREG1 "ebx" |
56 | 79638566 | bellard | #define AREG2 "esi" |
57 | 522777bb | ths | #elif defined(__x86_64__)
|
58 | 43024c6a | ths | #define AREG0 "r14" |
59 | 43024c6a | ths | #define AREG1 "r15" |
60 | bc51c5c9 | bellard | #define AREG2 "r12" |
61 | e58ffeb3 | malc | #elif defined(_ARCH_PPC)
|
62 | 79638566 | bellard | #define AREG0 "r27" |
63 | 79638566 | bellard | #define AREG1 "r24" |
64 | 79638566 | bellard | #define AREG2 "r25" |
65 | 522777bb | ths | #elif defined(__arm__)
|
66 | 79638566 | bellard | #define AREG0 "r7" |
67 | 79638566 | bellard | #define AREG1 "r4" |
68 | 79638566 | bellard | #define AREG2 "r5" |
69 | f54b3f92 | aurel32 | #elif defined(__hppa__)
|
70 | f54b3f92 | aurel32 | #define AREG0 "r17" |
71 | f54b3f92 | aurel32 | #define AREG1 "r14" |
72 | f54b3f92 | aurel32 | #define AREG2 "r15" |
73 | 522777bb | ths | #elif defined(__mips__)
|
74 | c4b89d18 | ths | #define AREG0 "fp" |
75 | 79638566 | bellard | #define AREG1 "s0" |
76 | 79638566 | bellard | #define AREG2 "s1" |
77 | 522777bb | ths | #elif defined(__sparc__)
|
78 | fdbb4691 | bellard | #ifdef HOST_SOLARIS
|
79 | fdbb4691 | bellard | #define AREG0 "g2" |
80 | fdbb4691 | bellard | #define AREG1 "g3" |
81 | fdbb4691 | bellard | #define AREG2 "g4" |
82 | fdbb4691 | bellard | #else
|
83 | 74ccb34e | bellard | #ifdef __sparc_v9__
|
84 | e97b640d | blueswir1 | #define AREG0 "g5" |
85 | e97b640d | blueswir1 | #define AREG1 "g6" |
86 | e97b640d | blueswir1 | #define AREG2 "g7" |
87 | 74ccb34e | bellard | #else
|
88 | 79638566 | bellard | #define AREG0 "g6" |
89 | 79638566 | bellard | #define AREG1 "g1" |
90 | 79638566 | bellard | #define AREG2 "g2" |
91 | fdbb4691 | bellard | #endif
|
92 | 74ccb34e | bellard | #endif
|
93 | 522777bb | ths | #elif defined(__s390__)
|
94 | 79638566 | bellard | #define AREG0 "r10" |
95 | 79638566 | bellard | #define AREG1 "r7" |
96 | 79638566 | bellard | #define AREG2 "r8" |
97 | 522777bb | ths | #elif defined(__alpha__)
|
98 | 79638566 | bellard | /* Note $15 is the frame pointer, so anything in op-i386.c that would
|
99 | 79638566 | bellard | require a frame pointer, like alloca, would probably loose. */
|
100 | 79638566 | bellard | #define AREG0 "$15" |
101 | 79638566 | bellard | #define AREG1 "$9" |
102 | 79638566 | bellard | #define AREG2 "$10" |
103 | 522777bb | ths | #elif defined(__mc68000)
|
104 | 38e584a0 | bellard | #define AREG0 "%a5" |
105 | 38e584a0 | bellard | #define AREG1 "%a4" |
106 | 38e584a0 | bellard | #define AREG2 "%d7" |
107 | 522777bb | ths | #elif defined(__ia64__)
|
108 | b8076a74 | bellard | #define AREG0 "r7" |
109 | b8076a74 | bellard | #define AREG1 "r4" |
110 | b8076a74 | bellard | #define AREG2 "r5" |
111 | 522777bb | ths | #else
|
112 | 522777bb | ths | #error unsupported CPU
|
113 | 79638566 | bellard | #endif
|
114 | 79638566 | bellard | |
115 | 79638566 | bellard | #define xglue(x, y) x ## y |
116 | 79638566 | bellard | #define glue(x, y) xglue(x, y)
|
117 | 9621339d | bellard | #define stringify(s) tostring(s)
|
118 | 9621339d | bellard | #define tostring(s) #s |
119 | 79638566 | bellard | |
120 | 9b7b85d2 | pbrook | /* The return address may point to the start of the next instruction.
|
121 | 9b7b85d2 | pbrook | Subtracting one gets us the call instruction itself. */
|
122 | 9b7b85d2 | pbrook | #if defined(__s390__)
|
123 | 9b7b85d2 | pbrook | # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1)) |
124 | 9b7b85d2 | pbrook | #elif defined(__arm__)
|
125 | 9b7b85d2 | pbrook | /* Thumb return addresses have the low bit set, so we need to subtract two.
|
126 | 9b7b85d2 | pbrook | This is still safe in ARM mode because instructions are 4 bytes. */
|
127 | 9b7b85d2 | pbrook | # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2)) |
128 | 9b7b85d2 | pbrook | #else
|
129 | 9b7b85d2 | pbrook | # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1)) |
130 | 9b7b85d2 | pbrook | #endif
|
131 | 9b7b85d2 | pbrook | |
132 | 67867308 | bellard | #endif /* !defined(__DYNGEN_EXEC_H__) */ |