root / dyngen-exec.h @ 4136f33c
History | View | Annotate | Download (5.4 kB)
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
|
17 |
* License along with this library; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 |
*/
|
20 |
#if !defined(__DYNGEN_EXEC_H__)
|
21 |
#define __DYNGEN_EXEC_H__
|
22 |
|
23 |
typedef unsigned char uint8_t; |
24 |
typedef unsigned short uint16_t; |
25 |
typedef unsigned int uint32_t; |
26 |
typedef unsigned long long uint64_t; |
27 |
|
28 |
typedef signed char int8_t; |
29 |
typedef signed short int16_t; |
30 |
typedef signed int int32_t; |
31 |
typedef signed long long int64_t; |
32 |
|
33 |
#define INT8_MIN (-128) |
34 |
#define INT16_MIN (-32767-1) |
35 |
#define INT32_MIN (-2147483647-1) |
36 |
#define INT64_MIN (-(int64_t)(9223372036854775807)-1) |
37 |
#define INT8_MAX (127) |
38 |
#define INT16_MAX (32767) |
39 |
#define INT32_MAX (2147483647) |
40 |
#define INT64_MAX ((int64_t)(9223372036854775807)) |
41 |
#define UINT8_MAX (255) |
42 |
#define UINT16_MAX (65535) |
43 |
#define UINT32_MAX (4294967295U) |
44 |
#define UINT64_MAX ((uint64_t)(18446744073709551615)) |
45 |
|
46 |
#define bswap32(x) \
|
47 |
({ \ |
48 |
uint32_t __x = (x); \ |
49 |
((uint32_t)( \ |
50 |
(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ |
51 |
(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ |
52 |
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ |
53 |
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ |
54 |
}) |
55 |
|
56 |
typedef struct FILE FILE; |
57 |
extern int fprintf(FILE *, const char *, ...); |
58 |
extern int printf(const char *, ...); |
59 |
#define NULL 0 |
60 |
#include <fenv.h> |
61 |
|
62 |
#ifdef __i386__
|
63 |
#define AREG0 "ebp" |
64 |
#define AREG1 "ebx" |
65 |
#define AREG2 "esi" |
66 |
#define AREG3 "edi" |
67 |
#endif
|
68 |
#ifdef __powerpc__
|
69 |
#define AREG0 "r27" |
70 |
#define AREG1 "r24" |
71 |
#define AREG2 "r25" |
72 |
#define AREG3 "r26" |
73 |
/* XXX: suppress this hack */
|
74 |
#if defined(CONFIG_USER_ONLY)
|
75 |
#define AREG4 "r16" |
76 |
#define AREG5 "r17" |
77 |
#define AREG6 "r18" |
78 |
#define AREG7 "r19" |
79 |
#define AREG8 "r20" |
80 |
#define AREG9 "r21" |
81 |
#define AREG10 "r22" |
82 |
#define AREG11 "r23" |
83 |
#endif
|
84 |
#define USE_INT_TO_FLOAT_HELPERS
|
85 |
#define BUGGY_GCC_DIV64
|
86 |
#endif
|
87 |
#ifdef __arm__
|
88 |
#define AREG0 "r7" |
89 |
#define AREG1 "r4" |
90 |
#define AREG2 "r5" |
91 |
#define AREG3 "r6" |
92 |
#endif
|
93 |
#ifdef __mips__
|
94 |
#define AREG0 "s3" |
95 |
#define AREG1 "s0" |
96 |
#define AREG2 "s1" |
97 |
#define AREG3 "s2" |
98 |
#endif
|
99 |
#ifdef __sparc__
|
100 |
#define AREG0 "g6" |
101 |
#define AREG1 "g1" |
102 |
#define AREG2 "g2" |
103 |
#define AREG3 "g3" |
104 |
#define AREG4 "l0" |
105 |
#define AREG5 "l1" |
106 |
#define AREG6 "l2" |
107 |
#define AREG7 "l3" |
108 |
#define AREG8 "l4" |
109 |
#define AREG9 "l5" |
110 |
#define AREG10 "l6" |
111 |
#define AREG11 "l7" |
112 |
#define USE_FP_CONVERT
|
113 |
#endif
|
114 |
#ifdef __s390__
|
115 |
#define AREG0 "r10" |
116 |
#define AREG1 "r7" |
117 |
#define AREG2 "r8" |
118 |
#define AREG3 "r9" |
119 |
#endif
|
120 |
#ifdef __alpha__
|
121 |
/* Note $15 is the frame pointer, so anything in op-i386.c that would
|
122 |
require a frame pointer, like alloca, would probably loose. */
|
123 |
#define AREG0 "$15" |
124 |
#define AREG1 "$9" |
125 |
#define AREG2 "$10" |
126 |
#define AREG3 "$11" |
127 |
#define AREG4 "$12" |
128 |
#define AREG5 "$13" |
129 |
#define AREG6 "$14" |
130 |
#endif
|
131 |
#ifdef __mc68000
|
132 |
#define AREG0 "%a5" |
133 |
#define AREG1 "%a4" |
134 |
#define AREG2 "%d7" |
135 |
#define AREG3 "%d6" |
136 |
#define AREG4 "%d5" |
137 |
#endif
|
138 |
#ifdef __ia64__
|
139 |
#define AREG0 "r27" |
140 |
#define AREG1 "r24" |
141 |
#define AREG2 "r25" |
142 |
#define AREG3 "r26" |
143 |
#endif
|
144 |
|
145 |
/* force GCC to generate only one epilog at the end of the function */
|
146 |
#define FORCE_RET() asm volatile (""); |
147 |
|
148 |
#ifndef OPPROTO
|
149 |
#define OPPROTO
|
150 |
#endif
|
151 |
|
152 |
#define xglue(x, y) x ## y |
153 |
#define glue(x, y) xglue(x, y)
|
154 |
#define stringify(s) tostring(s)
|
155 |
#define tostring(s) #s |
156 |
|
157 |
#ifdef __alpha__
|
158 |
/* the symbols are considered non exported so a br immediate is generated */
|
159 |
#define __hidden __attribute__((visibility("hidden"))) |
160 |
#else
|
161 |
#define __hidden
|
162 |
#endif
|
163 |
|
164 |
#ifdef __alpha__
|
165 |
/* Suggested by Richard Henderson. This will result in code like
|
166 |
ldah $0,__op_param1($29) !gprelhigh
|
167 |
lda $0,__op_param1($0) !gprellow
|
168 |
We can then conveniently change $29 to $31 and adapt the offsets to
|
169 |
emit the appropriate constant. */
|
170 |
extern int __op_param1 __hidden; |
171 |
extern int __op_param2 __hidden; |
172 |
extern int __op_param3 __hidden; |
173 |
#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) |
174 |
#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) |
175 |
#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) |
176 |
#else
|
177 |
extern int __op_param1, __op_param2, __op_param3; |
178 |
#define PARAM1 ((long)(&__op_param1)) |
179 |
#define PARAM2 ((long)(&__op_param2)) |
180 |
#define PARAM3 ((long)(&__op_param3)) |
181 |
#endif
|
182 |
|
183 |
extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3; |
184 |
|
185 |
#ifdef __i386__
|
186 |
#define EXIT_TB() asm volatile ("ret") |
187 |
#endif
|
188 |
#ifdef __powerpc__
|
189 |
#define EXIT_TB() asm volatile ("blr") |
190 |
#endif
|
191 |
#ifdef __s390__
|
192 |
#define EXIT_TB() asm volatile ("br %r14") |
193 |
#endif
|
194 |
#ifdef __alpha__
|
195 |
#define EXIT_TB() asm volatile ("ret") |
196 |
#endif
|
197 |
#ifdef __ia64__
|
198 |
#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;") |
199 |
#endif
|
200 |
#ifdef __sparc__
|
201 |
#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \ |
202 |
"nop")
|
203 |
#endif
|
204 |
#ifdef __arm__
|
205 |
#define EXIT_TB() asm volatile ("b exec_loop") |
206 |
#endif
|
207 |
#ifdef __mc68000
|
208 |
#define EXIT_TB() asm volatile ("rts") |
209 |
#endif
|
210 |
|
211 |
#endif /* !defined(__DYNGEN_EXEC_H__) */ |