VirtualBox

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

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
File size: 6.6 KB
Line 
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/* NOTE: standard headers should be used with special care at this
24 point because host CPU registers are used as global variables. Some
25 host headers do not allow that. */
26#include <stddef.h>
27
28/* There are some conflicts with the uClibc headers. I'm _very_ amazed
29 that we don't get the same conflicts when compiling against glibc ... */
30#if !defined(__L4ENV__) && !defined(__MINGW32__) /* VBOX: mingw 3.4.x got into trouble here. */
31
32typedef unsigned char uint8_t;
33typedef unsigned short uint16_t;
34typedef unsigned int uint32_t;
35/* XXX may be done for all 64 bits targets ? */
36#if defined (__x86_64__)
37typedef unsigned long uint64_t;
38#else
39typedef unsigned long long uint64_t;
40#endif
41
42typedef signed char int8_t;
43typedef signed short int16_t;
44typedef signed int int32_t;
45#if defined (__x86_64__)
46typedef signed long int64_t;
47#else
48typedef signed long long int64_t;
49#endif
50
51#define INT8_MIN (-128)
52#define INT16_MIN (-32767-1)
53#define INT32_MIN (-2147483647-1)
54#define INT64_MIN (-(int64_t)(9223372036854775807)-1)
55#define INT8_MAX (127)
56#define INT16_MAX (32767)
57#define INT32_MAX (2147483647)
58#define INT64_MAX ((int64_t)(9223372036854775807))
59#define UINT8_MAX (255)
60#define UINT16_MAX (65535)
61#define UINT32_MAX (4294967295U)
62#define UINT64_MAX ((uint64_t)(18446744073709551615))
63
64#else /* __L4ENV__ */
65
66#include <stdint.h>
67
68#endif /* __L4ENV__ */
69
70typedef struct FILE FILE;
71extern int fprintf(FILE *, const char *, ...);
72extern int printf(const char *, ...);
73#undef NULL
74#define NULL 0
75#if defined(_BSD) && !defined(__APPLE__)
76#include <ieeefp.h>
77
78#define FE_TONEAREST FP_RN
79#define FE_DOWNWARD FP_RM
80#define FE_UPWARD FP_RP
81#define FE_TOWARDZERO FP_RZ
82#define fesetround(x) fpsetround(x)
83#else
84#include <fenv.h>
85#endif
86
87#ifdef __i386__
88#define AREG0 "ebp"
89#define AREG1 "ebx"
90#define AREG2 "esi"
91#define AREG3 "edi"
92#endif
93#ifdef __x86_64__
94#define AREG0 "rbp"
95#define AREG1 "rbx"
96#define AREG2 "r12"
97#define AREG3 "r13"
98#define AREG4 "r14"
99#define AREG5 "r15"
100#endif
101#ifdef __powerpc__
102#define AREG0 "r27"
103#define AREG1 "r24"
104#define AREG2 "r25"
105#define AREG3 "r26"
106/* XXX: suppress this hack */
107#if defined(CONFIG_USER_ONLY)
108#define AREG4 "r16"
109#define AREG5 "r17"
110#define AREG6 "r18"
111#define AREG7 "r19"
112#define AREG8 "r20"
113#define AREG9 "r21"
114#define AREG10 "r22"
115#define AREG11 "r23"
116#endif
117#define USE_INT_TO_FLOAT_HELPERS
118#define BUGGY_GCC_DIV64
119#endif
120#ifdef __arm__
121#define AREG0 "r7"
122#define AREG1 "r4"
123#define AREG2 "r5"
124#define AREG3 "r6"
125#endif
126#ifdef __mips__
127#define AREG0 "s3"
128#define AREG1 "s0"
129#define AREG2 "s1"
130#define AREG3 "s2"
131#endif
132#ifdef __sparc__
133#define AREG0 "g6"
134#define AREG1 "g1"
135#define AREG2 "g2"
136#define AREG3 "g3"
137#define AREG4 "l0"
138#define AREG5 "l1"
139#define AREG6 "l2"
140#define AREG7 "l3"
141#define AREG8 "l4"
142#define AREG9 "l5"
143#define AREG10 "l6"
144#define AREG11 "l7"
145#define USE_FP_CONVERT
146#endif
147#ifdef __s390__
148#define AREG0 "r10"
149#define AREG1 "r7"
150#define AREG2 "r8"
151#define AREG3 "r9"
152#endif
153#ifdef __alpha__
154/* Note $15 is the frame pointer, so anything in op-i386.c that would
155 require a frame pointer, like alloca, would probably loose. */
156#define AREG0 "$15"
157#define AREG1 "$9"
158#define AREG2 "$10"
159#define AREG3 "$11"
160#define AREG4 "$12"
161#define AREG5 "$13"
162#define AREG6 "$14"
163#endif
164#ifdef __mc68000
165#define AREG0 "%a5"
166#define AREG1 "%a4"
167#define AREG2 "%d7"
168#define AREG3 "%d6"
169#define AREG4 "%d5"
170#endif
171#ifdef __ia64__
172#define AREG0 "r27"
173#define AREG1 "r24"
174#define AREG2 "r25"
175#define AREG3 "r26"
176#endif
177
178/* force GCC to generate only one epilog at the end of the function */
179#define FORCE_RET() asm volatile ("");
180
181#ifndef OPPROTO
182#define OPPROTO
183#endif
184
185#define xglue(x, y) x ## y
186#define glue(x, y) xglue(x, y)
187#define stringify(s) tostring(s)
188#define tostring(s) #s
189
190#ifdef __alpha__
191/* the symbols are considered non exported so a br immediate is generated */
192#define __hidden __attribute__((visibility("hidden")))
193#else
194#define __hidden
195#endif
196
197#if defined(__alpha__)
198/* Suggested by Richard Henderson. This will result in code like
199 ldah $0,__op_param1($29) !gprelhigh
200 lda $0,__op_param1($0) !gprellow
201 We can then conveniently change $29 to $31 and adapt the offsets to
202 emit the appropriate constant. */
203extern int __op_param1 __hidden;
204extern int __op_param2 __hidden;
205extern int __op_param3 __hidden;
206#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
207#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
208#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
209#else
210#if defined(__APPLE__)
211static int __op_param1, __op_param2, __op_param3;
212#else
213extern int __op_param1, __op_param2, __op_param3;
214#endif
215#define PARAM1 ((long)(&__op_param1))
216#define PARAM2 ((long)(&__op_param2))
217#define PARAM3 ((long)(&__op_param3))
218#endif /* !defined(__alpha__) */
219
220extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
221
222#if defined(_WIN32) || defined(__APPLE__) || defined(__OS2__)
223#define ASM_NAME(x) "_" #x
224#else
225#define ASM_NAME(x) #x
226#endif
227
228#ifdef __i386__
229#define EXIT_TB() asm volatile ("ret")
230#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
231#endif
232#ifdef __x86_64__
233#define EXIT_TB() asm volatile ("ret")
234#endif
235#ifdef __powerpc__
236#define EXIT_TB() asm volatile ("blr")
237#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
238#endif
239#ifdef __s390__
240#define EXIT_TB() asm volatile ("br %r14")
241#endif
242#ifdef __alpha__
243#define EXIT_TB() asm volatile ("ret")
244#endif
245#ifdef __ia64__
246#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
247#endif
248#ifdef __sparc__
249#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \
250 "nop")
251#endif
252#ifdef __arm__
253#define EXIT_TB() asm volatile ("b exec_loop")
254#endif
255#ifdef __mc68000
256#define EXIT_TB() asm volatile ("rts")
257#endif
258
259#endif /* !defined(__DYNGEN_EXEC_H__) */
Note: See TracBrowser for help on using the repository browser.

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