Statistics
| Branch: | Revision:

root / dyngen-exec.h @ a63b5829

History | View | Annotate | Download (3 kB)

1 79638566 bellard
/*
2 79638566 bellard
 *  dyngen defines for micro operation code
3 79638566 bellard
 *
4 79638566 bellard
 *  Copyright (c) 2003 Fabrice Bellard
5 79638566 bellard
 *
6 79638566 bellard
 * This library is free software; you can redistribute it and/or
7 79638566 bellard
 * modify it under the terms of the GNU Lesser General Public
8 79638566 bellard
 * License as published by the Free Software Foundation; either
9 79638566 bellard
 * version 2 of the License, or (at your option) any later version.
10 79638566 bellard
 *
11 79638566 bellard
 * This library is distributed in the hope that it will be useful,
12 79638566 bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 79638566 bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 79638566 bellard
 * Lesser General Public License for more details.
15 79638566 bellard
 *
16 79638566 bellard
 * You should have received a copy of the GNU Lesser General Public
17 8167ee88 Blue Swirl
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 79638566 bellard
 */
19 67867308 bellard
#if !defined(__DYNGEN_EXEC_H__)
20 67867308 bellard
#define __DYNGEN_EXEC_H__
21 67867308 bellard
22 ec530c81 bellard
/* prevent Solaris from trying to typedef FILE in gcc's
23 ec530c81 bellard
   include/floatingpoint.h which will conflict with the
24 ec530c81 bellard
   definition down below */
25 ec530c81 bellard
#ifdef __sun__
26 ec530c81 bellard
#define _FILEDEFED
27 ec530c81 bellard
#endif
28 ec530c81 bellard
29 1e6cae95 bellard
/* NOTE: standard headers should be used with special care at this
30 1e6cae95 bellard
   point because host CPU registers are used as global variables. Some
31 1e6cae95 bellard
   host headers do not allow that. */
32 513b500f bellard
#include <stddef.h>
33 b7df4bcc aurel32
#include <stdint.h>
34 513b500f bellard
35 128ab2ff blueswir1
#ifdef __OpenBSD__
36 128ab2ff blueswir1
#include <sys/types.h>
37 128ab2ff blueswir1
#endif
38 79638566 bellard
39 1057eaa7 pbrook
/* XXX: This may be wrong for 64-bit ILP32 hosts.  */
40 c227f099 Anthony Liguori
typedef void * host_reg_t;
41 1057eaa7 pbrook
42 71e72a19 Juan Quintela
#ifdef CONFIG_BSD
43 cce1075c ths
typedef struct __sFILE FILE;
44 cce1075c ths
#else
45 79638566 bellard
typedef struct FILE FILE;
46 cce1075c ths
#endif
47 79638566 bellard
extern int fprintf(FILE *, const char *, ...);
48 24c7b0e3 ths
extern int fputs(const char *, FILE *);
49 79638566 bellard
extern int printf(const char *, ...);
50 79638566 bellard
51 522777bb ths
#if defined(__i386__)
52 79638566 bellard
#define AREG0 "ebp"
53 522777bb ths
#elif defined(__x86_64__)
54 43024c6a ths
#define AREG0 "r14"
55 e58ffeb3 malc
#elif defined(_ARCH_PPC)
56 79638566 bellard
#define AREG0 "r27"
57 522777bb ths
#elif defined(__arm__)
58 79638566 bellard
#define AREG0 "r7"
59 f54b3f92 aurel32
#elif defined(__hppa__)
60 f54b3f92 aurel32
#define AREG0 "r17"
61 522777bb ths
#elif defined(__mips__)
62 c4b89d18 ths
#define AREG0 "fp"
63 522777bb ths
#elif defined(__sparc__)
64 dfe5fff3 Juan Quintela
#ifdef CONFIG_SOLARIS
65 fdbb4691 bellard
#define AREG0 "g2"
66 fdbb4691 bellard
#else
67 74ccb34e bellard
#ifdef __sparc_v9__
68 e97b640d blueswir1
#define AREG0 "g5"
69 74ccb34e bellard
#else
70 79638566 bellard
#define AREG0 "g6"
71 fdbb4691 bellard
#endif
72 74ccb34e bellard
#endif
73 522777bb ths
#elif defined(__s390__)
74 79638566 bellard
#define AREG0 "r10"
75 522777bb ths
#elif defined(__alpha__)
76 79638566 bellard
/* Note $15 is the frame pointer, so anything in op-i386.c that would
77 79638566 bellard
   require a frame pointer, like alloca, would probably loose.  */
78 79638566 bellard
#define AREG0 "$15"
79 522777bb ths
#elif defined(__mc68000)
80 38e584a0 bellard
#define AREG0 "%a5"
81 522777bb ths
#elif defined(__ia64__)
82 b8076a74 bellard
#define AREG0 "r7"
83 522777bb ths
#else
84 522777bb ths
#error unsupported CPU
85 79638566 bellard
#endif
86 79638566 bellard
87 79638566 bellard
#define xglue(x, y) x ## y
88 79638566 bellard
#define glue(x, y) xglue(x, y)
89 9621339d bellard
#define stringify(s)        tostring(s)
90 9621339d bellard
#define tostring(s)        #s
91 79638566 bellard
92 9b7b85d2 pbrook
/* The return address may point to the start of the next instruction.
93 9b7b85d2 pbrook
   Subtracting one gets us the call instruction itself.  */
94 2827822e Alexander Graf
#if defined(__s390__) && !defined(__s390x__)
95 9b7b85d2 pbrook
# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
96 9b7b85d2 pbrook
#elif defined(__arm__)
97 9b7b85d2 pbrook
/* Thumb return addresses have the low bit set, so we need to subtract two.
98 9b7b85d2 pbrook
   This is still safe in ARM mode because instructions are 4 bytes.  */
99 9b7b85d2 pbrook
# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
100 9b7b85d2 pbrook
#else
101 9b7b85d2 pbrook
# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
102 9b7b85d2 pbrook
#endif
103 9b7b85d2 pbrook
104 67867308 bellard
#endif /* !defined(__DYNGEN_EXEC_H__) */