VirtualBox

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

最後變更 在這個檔案從109是 1,由 vboxsync 提交於 55 年 前

import

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

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