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