VirtualBox

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

Last change on this file since 35740 was 33656, checked in by vboxsync, 14 years ago

*: rebrand Sun (L)GPL disclaimers

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

© 2023 Oracle
ContactPrivacy policyTerms of Use