Statistics
| Branch: | Revision:

root / dyngen-exec.h @ 6c9bf893

History | View | Annotate | Download (5.4 kB)

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
#if !defined(__DYNGEN_EXEC_H__)
21
#define __DYNGEN_EXEC_H__
22

    
23
#include <stddef.h>
24

    
25
typedef unsigned char uint8_t;
26
typedef unsigned short uint16_t;
27
typedef unsigned int uint32_t;
28
typedef unsigned long long uint64_t;
29

    
30
typedef signed char int8_t;
31
typedef signed short int16_t;
32
typedef signed int int32_t;
33
typedef signed long long int64_t;
34

    
35
#define INT8_MIN                (-128)
36
#define INT16_MIN                (-32767-1)
37
#define INT32_MIN                (-2147483647-1)
38
#define INT64_MIN                (-(int64_t)(9223372036854775807)-1)
39
#define INT8_MAX                (127)
40
#define INT16_MAX                (32767)
41
#define INT32_MAX                (2147483647)
42
#define INT64_MAX                ((int64_t)(9223372036854775807))
43
#define UINT8_MAX                (255)
44
#define UINT16_MAX                (65535)
45
#define UINT32_MAX                (4294967295U)
46
#define UINT64_MAX                ((uint64_t)(18446744073709551615))
47

    
48
#define bswap32(x) \
49
({ \
50
        uint32_t __x = (x); \
51
        ((uint32_t)( \
52
                (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
53
                (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
54
                (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
55
                (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
56
})
57

    
58
typedef struct FILE FILE;
59
extern int fprintf(FILE *, const char *, ...);
60
extern int printf(const char *, ...);
61
#undef NULL
62
#define NULL 0
63
#include <fenv.h>
64

    
65
#ifdef __i386__
66
#define AREG0 "ebp"
67
#define AREG1 "ebx"
68
#define AREG2 "esi"
69
#define AREG3 "edi"
70
#endif
71
#ifdef __powerpc__
72
#define AREG0 "r27"
73
#define AREG1 "r24"
74
#define AREG2 "r25"
75
#define AREG3 "r26"
76
/* XXX: suppress this hack */
77
#if defined(CONFIG_USER_ONLY)
78
#define AREG4 "r16"
79
#define AREG5 "r17"
80
#define AREG6 "r18"
81
#define AREG7 "r19"
82
#define AREG8 "r20"
83
#define AREG9 "r21"
84
#define AREG10 "r22"
85
#define AREG11 "r23"
86
#endif
87
#define USE_INT_TO_FLOAT_HELPERS
88
#define BUGGY_GCC_DIV64
89
#endif
90
#ifdef __arm__
91
#define AREG0 "r7"
92
#define AREG1 "r4"
93
#define AREG2 "r5"
94
#define AREG3 "r6"
95
#endif
96
#ifdef __mips__
97
#define AREG0 "s3"
98
#define AREG1 "s0"
99
#define AREG2 "s1"
100
#define AREG3 "s2"
101
#endif
102
#ifdef __sparc__
103
#define AREG0 "g6"
104
#define AREG1 "g1"
105
#define AREG2 "g2"
106
#define AREG3 "g3"
107
#define AREG4 "l0"
108
#define AREG5 "l1"
109
#define AREG6 "l2"
110
#define AREG7 "l3"
111
#define AREG8 "l4"
112
#define AREG9 "l5"
113
#define AREG10 "l6"
114
#define AREG11 "l7"
115
#define USE_FP_CONVERT
116
#endif
117
#ifdef __s390__
118
#define AREG0 "r10"
119
#define AREG1 "r7"
120
#define AREG2 "r8"
121
#define AREG3 "r9"
122
#endif
123
#ifdef __alpha__
124
/* Note $15 is the frame pointer, so anything in op-i386.c that would
125
   require a frame pointer, like alloca, would probably loose.  */
126
#define AREG0 "$15"
127
#define AREG1 "$9"
128
#define AREG2 "$10"
129
#define AREG3 "$11"
130
#define AREG4 "$12"
131
#define AREG5 "$13"
132
#define AREG6 "$14"
133
#endif
134
#ifdef __mc68000
135
#define AREG0 "%a5"
136
#define AREG1 "%a4"
137
#define AREG2 "%d7"
138
#define AREG3 "%d6"
139
#define AREG4 "%d5"
140
#endif
141
#ifdef __ia64__
142
#define AREG0 "r27"
143
#define AREG1 "r24"
144
#define AREG2 "r25"
145
#define AREG3 "r26"
146
#endif
147

    
148
/* force GCC to generate only one epilog at the end of the function */
149
#define FORCE_RET() asm volatile ("");
150

    
151
#ifndef OPPROTO
152
#define OPPROTO
153
#endif
154

    
155
#define xglue(x, y) x ## y
156
#define glue(x, y) xglue(x, y)
157
#define stringify(s)        tostring(s)
158
#define tostring(s)        #s
159

    
160
#ifdef __alpha__
161
/* the symbols are considered non exported so a br immediate is generated */
162
#define __hidden __attribute__((visibility("hidden")))
163
#else
164
#define __hidden 
165
#endif
166

    
167
#ifdef __alpha__
168
/* Suggested by Richard Henderson. This will result in code like
169
        ldah $0,__op_param1($29)        !gprelhigh
170
        lda $0,__op_param1($0)          !gprellow
171
   We can then conveniently change $29 to $31 and adapt the offsets to
172
   emit the appropriate constant.  */
173
extern int __op_param1 __hidden;
174
extern int __op_param2 __hidden;
175
extern int __op_param3 __hidden;
176
#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
177
#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
178
#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
179
#else
180
extern int __op_param1, __op_param2, __op_param3;
181
#define PARAM1 ((long)(&__op_param1))
182
#define PARAM2 ((long)(&__op_param2))
183
#define PARAM3 ((long)(&__op_param3))
184
#endif
185

    
186
extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
187

    
188
#ifdef __i386__
189
#define EXIT_TB() asm volatile ("ret")
190
#endif
191
#ifdef __powerpc__
192
#define EXIT_TB() asm volatile ("blr")
193
#endif
194
#ifdef __s390__
195
#define EXIT_TB() asm volatile ("br %r14")
196
#endif
197
#ifdef __alpha__
198
#define EXIT_TB() asm volatile ("ret")
199
#endif
200
#ifdef __ia64__
201
#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
202
#endif
203
#ifdef __sparc__
204
#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \
205
                                "nop")
206
#endif
207
#ifdef __arm__
208
#define EXIT_TB() asm volatile ("b exec_loop")
209
#endif
210
#ifdef __mc68000
211
#define EXIT_TB() asm volatile ("rts")
212
#endif
213

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