2 * dyngen defines for micro operation code
4 * Copyright (c) 2003 Fabrice Bellard
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
20 #if !defined(__DYNGEN_EXEC_H__)
21 #define __DYNGEN_EXEC_H__
23 /* prevent Solaris from trying to typedef FILE in gcc's
24 include/floatingpoint.h which will conflict with the
25 definition down below */
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. */
37 #include <sys/types.h>
40 /* XXX: This may be wrong for 64-bit ILP32 hosts. */
41 typedef void * host_reg_t
;
44 typedef struct __sFILE
FILE;
46 typedef struct FILE FILE;
48 extern int fprintf(FILE *, const char *, ...);
49 extern int fputs(const char *, FILE *);
50 extern int printf(const char *, ...);
58 #elif defined(__x86_64__)
62 #elif defined(_ARCH_PPC)
66 #elif defined(__arm__)
70 #elif defined(__hppa__)
74 #elif defined(__mips__)
78 #elif defined(__sparc__)
94 #elif defined(__s390__)
98 #elif defined(__alpha__)
99 /* Note $15 is the frame pointer, so anything in op-i386.c that would
100 require a frame pointer, like alloca, would probably loose. */
104 #elif defined(__mc68000)
108 #elif defined(__ia64__)
113 #error unsupported CPU
116 #define xglue(x, y) x ## y
117 #define glue(x, y) xglue(x, y)
118 #define stringify(s) tostring(s)
119 #define tostring(s) #s
121 /* The return address may point to the start of the next instruction.
122 Subtracting one gets us the call instruction itself. */
123 #if defined(__s390__)
124 # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
125 #elif defined(__arm__)
126 /* Thumb return addresses have the low bit set, so we need to subtract two.
127 This is still safe in ARM mode because instructions are 4 bytes. */
128 # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
130 # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
133 #endif /* !defined(__DYNGEN_EXEC_H__) */