VirtualBox

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

Last change on this file since 30862 was 26499, checked in by vboxsync, 15 years ago

recompier: whitespace cleanup. (Clean up whitespace on the foreign code before trying to merge in new changes again.)

  • Property svn:eol-style set to native
File size: 7.8 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
21/*
22 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29#if !defined(__DYNGEN_EXEC_H__)
30#define __DYNGEN_EXEC_H__
31
32#ifndef VBOX
33/* prevent Solaris from trying to typedef FILE in gcc's
34 include/floatingpoint.h which will conflict with the
35 definition down below */
36#ifdef __sun__
37#define _FILEDEFED
38#endif
39#endif /* !VBOX */
40
41/* NOTE: standard headers should be used with special care at this
42 point because host CPU registers are used as global variables. Some
43 host headers do not allow that. */
44#include <stddef.h>
45
46#ifndef VBOX
47
48typedef unsigned char uint8_t;
49typedef unsigned short uint16_t;
50typedef unsigned int uint32_t;
51/* Linux/Sparc64 defines uint64_t */
52#if !(defined (__sparc_v9__) && defined(__linux__))
53/* XXX may be done for all 64 bits targets ? */
54#if defined (__x86_64__) || defined(__ia64)
55typedef unsigned long uint64_t;
56#else
57typedef unsigned long long uint64_t;
58#endif
59#endif
60
61/* if Solaris/__sun__, don't typedef int8_t, as it will be typedef'd
62 prior to this and will cause an error in compliation, conflicting
63 with /usr/include/sys/int_types.h, line 75 */
64#ifndef __sun__
65typedef signed char int8_t;
66#endif
67typedef signed short int16_t;
68typedef signed int int32_t;
69// Linux/Sparc64 defines int64_t
70#if !(defined (__sparc_v9__) && defined(__linux__))
71#if defined (__x86_64__) || defined(__ia64)
72typedef signed long int64_t;
73#else
74typedef signed long long int64_t;
75#endif
76#endif
77
78/* XXX: This may be wrong for 64-bit ILP32 hosts. */
79typedef void * host_reg_t;
80
81#define INT8_MIN (-128)
82#define INT16_MIN (-32767-1)
83#define INT32_MIN (-2147483647-1)
84#define INT64_MIN (-(int64_t)(9223372036854775807)-1)
85#define INT8_MAX (127)
86#define INT16_MAX (32767)
87#define INT32_MAX (2147483647)
88#define INT64_MAX ((int64_t)(9223372036854775807))
89#define UINT8_MAX (255)
90#define UINT16_MAX (65535)
91#define UINT32_MAX (4294967295U)
92#define UINT64_MAX ((uint64_t)(18446744073709551615))
93
94#ifdef _BSD
95typedef struct __sFILE FILE;
96#else
97typedef struct FILE FILE;
98#endif
99extern int fprintf(FILE *, const char *, ...);
100extern int fputs(const char *, FILE *);
101extern int printf(const char *, ...);
102#undef NULL
103#define NULL 0
104
105#else /* VBOX */
106
107/* XXX: This may be wrong for 64-bit ILP32 hosts. */
108typedef void * host_reg_t;
109
110#include <iprt/stdint.h>
111#include <stdio.h>
112
113#endif /* VBOX */
114
115#ifdef __i386__
116#ifndef VBOX
117#define AREG0 "ebp"
118#define AREG1 "ebx"
119#define AREG2 "esi"
120#define AREG3 "edi"
121#else
122#define AREG0 "esi"
123#define AREG1 "edi"
124#endif
125#endif
126#ifdef __x86_64__
127#if defined(VBOX)
128/* Must be in sync with TCG register notion, see tcg-target.h */
129#endif
130#define AREG0 "r14"
131#define AREG1 "r15"
132#define AREG2 "r12"
133#define AREG3 "r13"
134#endif
135#ifdef __powerpc__
136#define AREG0 "r27"
137#define AREG1 "r24"
138#define AREG2 "r25"
139#define AREG3 "r26"
140/* XXX: suppress this hack */
141#if defined(CONFIG_USER_ONLY)
142#define AREG4 "r16"
143#define AREG5 "r17"
144#define AREG6 "r18"
145#define AREG7 "r19"
146#define AREG8 "r20"
147#define AREG9 "r21"
148#define AREG10 "r22"
149#define AREG11 "r23"
150#endif
151#define USE_INT_TO_FLOAT_HELPERS
152#define BUGGY_GCC_DIV64
153#endif
154#ifdef __arm__
155#define AREG0 "r7"
156#define AREG1 "r4"
157#define AREG2 "r5"
158#define AREG3 "r6"
159#endif
160#ifdef __mips__
161#define AREG0 "s3"
162#define AREG1 "s0"
163#define AREG2 "s1"
164#define AREG3 "s2"
165#endif
166#ifdef __sparc__
167#ifdef HOST_SOLARIS
168#define AREG0 "g2"
169#define AREG1 "g3"
170#define AREG2 "g4"
171#define AREG3 "g5"
172#define AREG4 "g6"
173#else
174#ifdef __sparc_v9__
175#define AREG0 "g1"
176#define AREG1 "g4"
177#define AREG2 "g5"
178#define AREG3 "g7"
179#else
180#define AREG0 "g6"
181#define AREG1 "g1"
182#define AREG2 "g2"
183#define AREG3 "g3"
184#define AREG4 "l0"
185#define AREG5 "l1"
186#define AREG6 "l2"
187#define AREG7 "l3"
188#define AREG8 "l4"
189#define AREG9 "l5"
190#define AREG10 "l6"
191#define AREG11 "l7"
192#endif
193#endif
194#define USE_FP_CONVERT
195#endif
196#ifdef __s390__
197#define AREG0 "r10"
198#define AREG1 "r7"
199#define AREG2 "r8"
200#define AREG3 "r9"
201#endif
202#ifdef __alpha__
203/* Note $15 is the frame pointer, so anything in op-i386.c that would
204 require a frame pointer, like alloca, would probably loose. */
205#define AREG0 "$15"
206#define AREG1 "$9"
207#define AREG2 "$10"
208#define AREG3 "$11"
209#define AREG4 "$12"
210#define AREG5 "$13"
211#define AREG6 "$14"
212#endif
213#ifdef __mc68000
214#define AREG0 "%a5"
215#define AREG1 "%a4"
216#define AREG2 "%d7"
217#define AREG3 "%d6"
218#define AREG4 "%d5"
219#endif
220#ifdef __ia64__
221#define AREG0 "r7"
222#define AREG1 "r4"
223#define AREG2 "r5"
224#define AREG3 "r6"
225#endif
226
227#ifndef VBOX
228/* force GCC to generate only one epilog at the end of the function */
229#define FORCE_RET() __asm__ __volatile__("" : : : "memory");
230#endif
231
232#ifndef OPPROTO
233#define OPPROTO
234#endif
235
236#define xglue(x, y) x ## y
237#define glue(x, y) xglue(x, y)
238#define stringify(s) tostring(s)
239#define tostring(s) #s
240
241#if defined(__alpha__) || defined(__s390__)
242/* the symbols are considered non exported so a br immediate is generated */
243#define __hidden __attribute__((visibility("hidden")))
244#else
245#define __hidden
246#endif
247
248#if defined(__alpha__)
249/* Suggested by Richard Henderson. This will result in code like
250 ldah $0,__op_param1($29) !gprelhigh
251 lda $0,__op_param1($0) !gprellow
252 We can then conveniently change $29 to $31 and adapt the offsets to
253 emit the appropriate constant. */
254extern int __op_param1 __hidden;
255extern int __op_param2 __hidden;
256extern int __op_param3 __hidden;
257#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
258#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
259#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
260#else
261#if defined(__APPLE__)
262static int __op_param1, __op_param2, __op_param3;
263#else
264extern int __op_param1, __op_param2, __op_param3;
265#endif
266#define PARAM1 ((long)(&__op_param1))
267#define PARAM2 ((long)(&__op_param2))
268#define PARAM3 ((long)(&__op_param3))
269#endif /* !defined(__alpha__) */
270
271extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
272
273#if defined(_WIN32) || defined(__APPLE__) || defined(__OS2__)
274#define ASM_NAME(x) "_" #x
275#else
276#define ASM_NAME(x) #x
277#endif
278
279#ifdef VBOX
280#define GETPC() ASMReturnAddress()
281#elif defined(__s390__)
282/* The return address may point to the start of the next instruction.
283 Subtracting one gets us the call instruction itself. */
284# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
285#elif defined(__arm__)
286/* Thumb return addresses have the low bit set, so we need to subtract two.
287 This is still safe in ARM mode because instructions are 4 bytes. */
288# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
289#else
290# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
291#endif
292#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