VirtualBox

source: vbox/trunk/src/recompiler/dyngen-exec.h@ 8721

最後變更 在這個檔案從8721是 5372,由 vboxsync 提交於 17 年 前

Avoid using rbp for any global register variable as it seems to cause trouble for gcc 3.4.3 on solaris.

  • 屬性 svn:eol-style 設為 native
檔案大小: 7.8 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/* prevent Solaris from trying to typedef FILE in gcc's
24 include/floatingpoint.h which will conflict with the
25 definition down below */
26#ifdef __sun__
27#define _FILEDEFED
28#endif
29
30/* NOTE: standard headers should be used with special care at this
31 point because host CPU registers are used as global variables. Some
32 host headers do not allow that. */
33#include <stddef.h>
34
35#ifndef VBOX
36
37typedef unsigned char uint8_t;
38typedef unsigned short uint16_t;
39typedef unsigned int uint32_t;
40// Linux/Sparc64 defines uint64_t
41#if !(defined (__sparc_v9__) && defined(__linux__))
42/* XXX may be done for all 64 bits targets ? */
43#if defined (__x86_64__) || defined(__ia64)
44typedef unsigned long uint64_t;
45#else
46typedef unsigned long long uint64_t;
47#endif
48#endif
49
50/* if Solaris/__sun__, don't typedef int8_t, as it will be typedef'd
51 prior to this and will cause an error in compliation, conflicting
52 with /usr/include/sys/int_types.h, line 75 */
53#ifndef __sun__
54typedef signed char int8_t;
55#endif
56typedef signed short int16_t;
57typedef signed int int32_t;
58// Linux/Sparc64 defines int64_t
59#if !(defined (__sparc_v9__) && defined(__linux__))
60#if defined (__x86_64__) || defined(__ia64)
61typedef signed long int64_t;
62#else
63typedef signed long long int64_t;
64#endif
65#endif
66
67/* XXX: This may be wrong for 64-bit ILP32 hosts. */
68typedef void * host_reg_t;
69
70#define INT8_MIN (-128)
71#define INT16_MIN (-32767-1)
72#define INT32_MIN (-2147483647-1)
73#define INT64_MIN (-(int64_t)(9223372036854775807)-1)
74#define INT8_MAX (127)
75#define INT16_MAX (32767)
76#define INT32_MAX (2147483647)
77#define INT64_MAX ((int64_t)(9223372036854775807))
78#define UINT8_MAX (255)
79#define UINT16_MAX (65535)
80#define UINT32_MAX (4294967295U)
81#define UINT64_MAX ((uint64_t)(18446744073709551615))
82
83typedef struct FILE FILE;
84extern int fprintf(FILE *, const char *, ...);
85extern int printf(const char *, ...);
86#undef NULL
87#define NULL 0
88
89#else /* VBOX */
90
91/* XXX: This may be wrong for 64-bit ILP32 hosts. */
92typedef void * host_reg_t;
93
94#include <iprt/stdint.h>
95#include <stdio.h>
96
97#endif /* VBOX */
98
99#ifdef __i386__
100#define AREG0 "ebp"
101#define AREG1 "ebx"
102#define AREG2 "esi"
103#define AREG3 "edi"
104#endif
105#ifdef __x86_64__
106#ifdef VBOX
107/* gcc 3.4.3 on 64-bit Solaris screws up when using rbp, it
108 seems so at least. (Setting AREG4 to "r15" causes compiler
109 error btw, so don't try it.) */
110# define AREG0 "rbx"
111# define AREG1 "r12"
112# define AREG2 "r13"
113# define AREG3 "r14"
114#else
115#define AREG0 "rbp"
116#define AREG1 "rbx"
117#define AREG2 "r12"
118#define AREG3 "r13"
119#endif
120//#define AREG4 "r14"
121//#define AREG5 "r15"
122#endif
123#ifdef __powerpc__
124#define AREG0 "r27"
125#define AREG1 "r24"
126#define AREG2 "r25"
127#define AREG3 "r26"
128/* XXX: suppress this hack */
129#if defined(CONFIG_USER_ONLY)
130#define AREG4 "r16"
131#define AREG5 "r17"
132#define AREG6 "r18"
133#define AREG7 "r19"
134#define AREG8 "r20"
135#define AREG9 "r21"
136#define AREG10 "r22"
137#define AREG11 "r23"
138#endif
139#define USE_INT_TO_FLOAT_HELPERS
140#define BUGGY_GCC_DIV64
141#endif
142#ifdef __arm__
143#define AREG0 "r7"
144#define AREG1 "r4"
145#define AREG2 "r5"
146#define AREG3 "r6"
147#endif
148#ifdef __mips__
149#define AREG0 "s3"
150#define AREG1 "s0"
151#define AREG2 "s1"
152#define AREG3 "s2"
153#endif
154#ifdef __sparc__
155#ifdef HOST_SOLARIS
156#define AREG0 "g2"
157#define AREG1 "g3"
158#define AREG2 "g4"
159#define AREG3 "g5"
160#define AREG4 "g6"
161#else
162#ifdef __sparc_v9__
163#define AREG0 "g1"
164#define AREG1 "g4"
165#define AREG2 "g5"
166#define AREG3 "g7"
167#else
168#define AREG0 "g6"
169#define AREG1 "g1"
170#define AREG2 "g2"
171#define AREG3 "g3"
172#define AREG4 "l0"
173#define AREG5 "l1"
174#define AREG6 "l2"
175#define AREG7 "l3"
176#define AREG8 "l4"
177#define AREG9 "l5"
178#define AREG10 "l6"
179#define AREG11 "l7"
180#endif
181#endif
182#define USE_FP_CONVERT
183#endif
184#ifdef __s390__
185#define AREG0 "r10"
186#define AREG1 "r7"
187#define AREG2 "r8"
188#define AREG3 "r9"
189#endif
190#ifdef __alpha__
191/* Note $15 is the frame pointer, so anything in op-i386.c that would
192 require a frame pointer, like alloca, would probably loose. */
193#define AREG0 "$15"
194#define AREG1 "$9"
195#define AREG2 "$10"
196#define AREG3 "$11"
197#define AREG4 "$12"
198#define AREG5 "$13"
199#define AREG6 "$14"
200#endif
201#ifdef __mc68000
202#define AREG0 "%a5"
203#define AREG1 "%a4"
204#define AREG2 "%d7"
205#define AREG3 "%d6"
206#define AREG4 "%d5"
207#endif
208#ifdef __ia64__
209#define AREG0 "r7"
210#define AREG1 "r4"
211#define AREG2 "r5"
212#define AREG3 "r6"
213#endif
214
215/* force GCC to generate only one epilog at the end of the function */
216#define FORCE_RET() __asm__ __volatile__("" : : : "memory");
217
218#ifndef OPPROTO
219#define OPPROTO
220#endif
221
222#define xglue(x, y) x ## y
223#define glue(x, y) xglue(x, y)
224#define stringify(s) tostring(s)
225#define tostring(s) #s
226
227#ifdef __alpha__
228/* the symbols are considered non exported so a br immediate is generated */
229#define __hidden __attribute__((visibility("hidden")))
230#else
231#define __hidden
232#endif
233
234#if defined(__alpha__)
235/* Suggested by Richard Henderson. This will result in code like
236 ldah $0,__op_param1($29) !gprelhigh
237 lda $0,__op_param1($0) !gprellow
238 We can then conveniently change $29 to $31 and adapt the offsets to
239 emit the appropriate constant. */
240extern int __op_param1 __hidden;
241extern int __op_param2 __hidden;
242extern int __op_param3 __hidden;
243#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
244#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
245#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
246#else
247#if defined(__APPLE__)
248static int __op_param1, __op_param2, __op_param3;
249#else
250extern int __op_param1, __op_param2, __op_param3;
251#endif
252#define PARAM1 ((long)(&__op_param1))
253#define PARAM2 ((long)(&__op_param2))
254#define PARAM3 ((long)(&__op_param3))
255#endif /* !defined(__alpha__) */
256
257extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
258
259#if defined(_WIN32) || defined(__APPLE__) || defined(__OS2__)
260#define ASM_NAME(x) "_" #x
261#else
262#define ASM_NAME(x) #x
263#endif
264
265#ifdef __i386__
266#define EXIT_TB() asm volatile ("ret")
267#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
268#endif
269#ifdef __x86_64__
270#define EXIT_TB() asm volatile ("ret")
271#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
272#endif
273#ifdef __powerpc__
274#define EXIT_TB() asm volatile ("blr")
275#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
276#endif
277#ifdef __s390__
278#define EXIT_TB() asm volatile ("br %r14")
279#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
280#endif
281#ifdef __alpha__
282#define EXIT_TB() asm volatile ("ret")
283#endif
284#ifdef __ia64__
285#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
286#define GOTO_LABEL_PARAM(n) asm volatile ("br.sptk.many " \
287 ASM_NAME(__op_gen_label) #n)
288#endif
289#ifdef __sparc__
290#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0; nop")
291#define GOTO_LABEL_PARAM(n) asm volatile ("ba " ASM_NAME(__op_gen_label) #n ";nop")
292#endif
293#ifdef __arm__
294#define EXIT_TB() asm volatile ("b exec_loop")
295#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
296#endif
297#ifdef __mc68000
298#define EXIT_TB() asm volatile ("rts")
299#endif
300
301#endif /* !defined(__DYNGEN_EXEC_H__) */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette