dyngen-exec.h 3.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 *  dyngen defines for micro operation code
 *
 *  Copyright (c) 2003 Fabrice Bellard
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 */
19 20 21
#if !defined(__DYNGEN_EXEC_H__)
#define __DYNGEN_EXEC_H__

B
bellard 已提交
22 23 24 25 26 27 28
/* prevent Solaris from trying to typedef FILE in gcc's
   include/floatingpoint.h which will conflict with the
   definition down below */
#ifdef __sun__
#define _FILEDEFED
#endif

B
comment  
bellard 已提交
29 30 31
/* NOTE: standard headers should be used with special care at this
   point because host CPU registers are used as global variables. Some
   host headers do not allow that. */
B
bellard 已提交
32
#include <stddef.h>
33
#include <stdint.h>
P
Paul Brook 已提交
34
#include <stdbool.h>
B
bellard 已提交
35

36 37 38
#ifdef __OpenBSD__
#include <sys/types.h>
#endif
39

P
pbrook 已提交
40
/* XXX: This may be wrong for 64-bit ILP32 hosts.  */
A
Anthony Liguori 已提交
41
typedef void * host_reg_t;
P
pbrook 已提交
42

J
Juan Quintela 已提交
43
#ifdef CONFIG_BSD
T
ths 已提交
44 45
typedef struct __sFILE FILE;
#else
46
typedef struct FILE FILE;
T
ths 已提交
47
#endif
48
extern int fprintf(FILE *, const char *, ...);
T
ths 已提交
49
extern int fputs(const char *, FILE *);
50 51
extern int printf(const char *, ...);

52
#if defined(__i386__)
53
#define AREG0 "ebp"
54
#elif defined(__x86_64__)
55
#define AREG0 "r14"
M
malc 已提交
56
#elif defined(_ARCH_PPC)
57
#define AREG0 "r27"
58
#elif defined(__arm__)
59
#define AREG0 "r7"
A
aurel32 已提交
60 61
#elif defined(__hppa__)
#define AREG0 "r17"
62
#elif defined(__mips__)
63
#define AREG0 "s0"
64
#elif defined(__sparc__)
65
#ifdef CONFIG_SOLARIS
B
bellard 已提交
66 67
#define AREG0 "g2"
#else
B
bellard 已提交
68
#ifdef __sparc_v9__
69
#define AREG0 "g5"
B
bellard 已提交
70
#else
71
#define AREG0 "g6"
B
bellard 已提交
72
#endif
B
bellard 已提交
73
#endif
74
#elif defined(__s390__)
75
#define AREG0 "r10"
76
#elif defined(__alpha__)
77 78 79
/* Note $15 is the frame pointer, so anything in op-i386.c that would
   require a frame pointer, like alloca, would probably loose.  */
#define AREG0 "$15"
80
#elif defined(__mc68000)
B
bellard 已提交
81
#define AREG0 "%a5"
82
#elif defined(__ia64__)
B
bellard 已提交
83
#define AREG0 "r7"
84 85
#else
#error unsupported CPU
86 87 88 89
#endif

#define xglue(x, y) x ## y
#define glue(x, y) xglue(x, y)
B
bellard 已提交
90 91
#define stringify(s)	tostring(s)
#define tostring(s)	#s
92

P
pbrook 已提交
93 94
/* The return address may point to the start of the next instruction.
   Subtracting one gets us the call instruction itself.  */
A
Alexander Graf 已提交
95
#if defined(__s390__) && !defined(__s390x__)
P
pbrook 已提交
96 97 98 99 100 101 102 103 104
# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
#elif defined(__arm__)
/* Thumb return addresses have the low bit set, so we need to subtract two.
   This is still safe in ARM mode because instructions are 4 bytes.  */
# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
#else
# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
#endif

105
#endif /* !defined(__DYNGEN_EXEC_H__) */