VirtualBox

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

最後變更 在這個檔案從1816是 644,由 vboxsync 提交於 18 年 前

Merged in current upstream changes.

  • 屬性 svn:eol-style 設為 native
檔案大小: 7.5 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#define AREG0 "rbp"
107#define AREG1 "rbx"
108#define AREG2 "r12"
109#define AREG3 "r13"
110//#define AREG4 "r14"
111//#define AREG5 "r15"
112#endif
113#ifdef __powerpc__
114#define AREG0 "r27"
115#define AREG1 "r24"
116#define AREG2 "r25"
117#define AREG3 "r26"
118/* XXX: suppress this hack */
119#if defined(CONFIG_USER_ONLY)
120#define AREG4 "r16"
121#define AREG5 "r17"
122#define AREG6 "r18"
123#define AREG7 "r19"
124#define AREG8 "r20"
125#define AREG9 "r21"
126#define AREG10 "r22"
127#define AREG11 "r23"
128#endif
129#define USE_INT_TO_FLOAT_HELPERS
130#define BUGGY_GCC_DIV64
131#endif
132#ifdef __arm__
133#define AREG0 "r7"
134#define AREG1 "r4"
135#define AREG2 "r5"
136#define AREG3 "r6"
137#endif
138#ifdef __mips__
139#define AREG0 "s3"
140#define AREG1 "s0"
141#define AREG2 "s1"
142#define AREG3 "s2"
143#endif
144#ifdef __sparc__
145#ifdef HOST_SOLARIS
146#define AREG0 "g2"
147#define AREG1 "g3"
148#define AREG2 "g4"
149#define AREG3 "g5"
150#define AREG4 "g6"
151#else
152#ifdef __sparc_v9__
153#define AREG0 "g1"
154#define AREG1 "g4"
155#define AREG2 "g5"
156#define AREG3 "g7"
157#else
158#define AREG0 "g6"
159#define AREG1 "g1"
160#define AREG2 "g2"
161#define AREG3 "g3"
162#define AREG4 "l0"
163#define AREG5 "l1"
164#define AREG6 "l2"
165#define AREG7 "l3"
166#define AREG8 "l4"
167#define AREG9 "l5"
168#define AREG10 "l6"
169#define AREG11 "l7"
170#endif
171#endif
172#define USE_FP_CONVERT
173#endif
174#ifdef __s390__
175#define AREG0 "r10"
176#define AREG1 "r7"
177#define AREG2 "r8"
178#define AREG3 "r9"
179#endif
180#ifdef __alpha__
181/* Note $15 is the frame pointer, so anything in op-i386.c that would
182 require a frame pointer, like alloca, would probably loose. */
183#define AREG0 "$15"
184#define AREG1 "$9"
185#define AREG2 "$10"
186#define AREG3 "$11"
187#define AREG4 "$12"
188#define AREG5 "$13"
189#define AREG6 "$14"
190#endif
191#ifdef __mc68000
192#define AREG0 "%a5"
193#define AREG1 "%a4"
194#define AREG2 "%d7"
195#define AREG3 "%d6"
196#define AREG4 "%d5"
197#endif
198#ifdef __ia64__
199#define AREG0 "r7"
200#define AREG1 "r4"
201#define AREG2 "r5"
202#define AREG3 "r6"
203#endif
204
205/* force GCC to generate only one epilog at the end of the function */
206#define FORCE_RET() __asm__ __volatile__("" : : : "memory");
207
208#ifndef OPPROTO
209#define OPPROTO
210#endif
211
212#define xglue(x, y) x ## y
213#define glue(x, y) xglue(x, y)
214#define stringify(s) tostring(s)
215#define tostring(s) #s
216
217#ifdef __alpha__
218/* the symbols are considered non exported so a br immediate is generated */
219#define __hidden __attribute__((visibility("hidden")))
220#else
221#define __hidden
222#endif
223
224#if defined(__alpha__)
225/* Suggested by Richard Henderson. This will result in code like
226 ldah $0,__op_param1($29) !gprelhigh
227 lda $0,__op_param1($0) !gprellow
228 We can then conveniently change $29 to $31 and adapt the offsets to
229 emit the appropriate constant. */
230extern int __op_param1 __hidden;
231extern int __op_param2 __hidden;
232extern int __op_param3 __hidden;
233#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
234#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
235#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
236#else
237#if defined(__APPLE__)
238static int __op_param1, __op_param2, __op_param3;
239#else
240extern int __op_param1, __op_param2, __op_param3;
241#endif
242#define PARAM1 ((long)(&__op_param1))
243#define PARAM2 ((long)(&__op_param2))
244#define PARAM3 ((long)(&__op_param3))
245#endif /* !defined(__alpha__) */
246
247extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
248
249#if defined(_WIN32) || defined(__APPLE__) || defined(__OS2__)
250#define ASM_NAME(x) "_" #x
251#else
252#define ASM_NAME(x) #x
253#endif
254
255#ifdef __i386__
256#define EXIT_TB() asm volatile ("ret")
257#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
258#endif
259#ifdef __x86_64__
260#define EXIT_TB() asm volatile ("ret")
261#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
262#endif
263#ifdef __powerpc__
264#define EXIT_TB() asm volatile ("blr")
265#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
266#endif
267#ifdef __s390__
268#define EXIT_TB() asm volatile ("br %r14")
269#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
270#endif
271#ifdef __alpha__
272#define EXIT_TB() asm volatile ("ret")
273#endif
274#ifdef __ia64__
275#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
276#define GOTO_LABEL_PARAM(n) asm volatile ("br.sptk.many " \
277 ASM_NAME(__op_gen_label) #n)
278#endif
279#ifdef __sparc__
280#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0; nop")
281#define GOTO_LABEL_PARAM(n) asm volatile ("ba " ASM_NAME(__op_gen_label) #n ";nop")
282#endif
283#ifdef __arm__
284#define EXIT_TB() asm volatile ("b exec_loop")
285#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
286#endif
287#ifdef __mc68000
288#define EXIT_TB() asm volatile ("rts")
289#endif
290
291#endif /* !defined(__DYNGEN_EXEC_H__) */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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