190 |
#endif |
#endif |
191 |
|
|
192 |
#ifdef __alpha__ |
#ifdef __alpha__ |
193 |
|
/* the symbols are considered non exported so a br immediate is generated */ |
194 |
|
#define __hidden __attribute__((visibility("hidden"))) |
195 |
|
#else |
196 |
|
#define __hidden |
197 |
|
#endif |
198 |
|
|
199 |
|
#ifdef __alpha__ |
200 |
/* Suggested by Richard Henderson. This will result in code like |
/* Suggested by Richard Henderson. This will result in code like |
201 |
ldah $0,__op_param1($29) !gprelhigh |
ldah $0,__op_param1($29) !gprelhigh |
202 |
lda $0,__op_param1($0) !gprellow |
lda $0,__op_param1($0) !gprellow |
203 |
We can then conveniently change $29 to $31 and adapt the offsets to |
We can then conveniently change $29 to $31 and adapt the offsets to |
204 |
emit the appropriate constant. */ |
emit the appropriate constant. */ |
205 |
extern int __op_param1 __attribute__((visibility("hidden"))); |
extern int __op_param1 __hidden; |
206 |
extern int __op_param2 __attribute__((visibility("hidden"))); |
extern int __op_param2 __hidden; |
207 |
extern int __op_param3 __attribute__((visibility("hidden"))); |
extern int __op_param3 __hidden; |
208 |
#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) |
#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) |
209 |
#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) |
#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) |
210 |
#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) |
#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) |
227 |
extern CCTable cc_table[]; |
extern CCTable cc_table[]; |
228 |
|
|
229 |
void load_seg(int seg_reg, int selector, unsigned cur_eip); |
void load_seg(int seg_reg, int selector, unsigned cur_eip); |
230 |
void cpu_lock(void); |
void __hidden cpu_lock(void); |
231 |
void cpu_unlock(void); |
void __hidden cpu_unlock(void); |
232 |
void raise_interrupt(int intno, int is_int, int error_code, |
void raise_interrupt(int intno, int is_int, int error_code, |
233 |
unsigned int next_eip); |
unsigned int next_eip); |
234 |
void raise_exception_err(int exception_index, int error_code); |
void raise_exception_err(int exception_index, int error_code); |
235 |
void raise_exception(int exception_index); |
void raise_exception(int exception_index); |
236 |
void cpu_loop_exit(void); |
void __hidden cpu_loop_exit(void); |
237 |
void helper_fsave(uint8_t *ptr, int data32); |
void helper_fsave(uint8_t *ptr, int data32); |
238 |
void helper_frstor(uint8_t *ptr, int data32); |
void helper_frstor(uint8_t *ptr, int data32); |
239 |
|
|
240 |
void OPPROTO op_movl_eflags_T0(void); |
void OPPROTO op_movl_eflags_T0(void); |
241 |
void OPPROTO op_movl_T0_eflags(void); |
void OPPROTO op_movl_T0_eflags(void); |
242 |
|
void raise_interrupt(int intno, int is_int, int error_code, |
243 |
|
unsigned int next_eip); |
244 |
|
void raise_exception_err(int exception_index, int error_code); |
245 |
|
void raise_exception(int exception_index); |
246 |
|
void helper_cpuid(void); |
247 |
|
void helper_lsl(void); |
248 |
|
void helper_lar(void); |
249 |
|
|
250 |
|
|
251 |
|
#ifdef USE_X86LDOUBLE |
252 |
|
/* use long double functions */ |
253 |
|
#define lrint lrintl |
254 |
|
#define llrint llrintl |
255 |
|
#define fabs fabsl |
256 |
|
#define sin sinl |
257 |
|
#define cos cosl |
258 |
|
#define sqrt sqrtl |
259 |
|
#define pow powl |
260 |
|
#define log logl |
261 |
|
#define tan tanl |
262 |
|
#define atan2 atan2l |
263 |
|
#define floor floorl |
264 |
|
#define ceil ceill |
265 |
|
#define rint rintl |
266 |
|
#endif |
267 |
|
|
268 |
|
extern int lrint(CPU86_LDouble x); |
269 |
|
extern int64_t llrint(CPU86_LDouble x); |
270 |
|
extern CPU86_LDouble fabs(CPU86_LDouble x); |
271 |
|
extern CPU86_LDouble sin(CPU86_LDouble x); |
272 |
|
extern CPU86_LDouble cos(CPU86_LDouble x); |
273 |
|
extern CPU86_LDouble sqrt(CPU86_LDouble x); |
274 |
|
extern CPU86_LDouble pow(CPU86_LDouble, CPU86_LDouble); |
275 |
|
extern CPU86_LDouble log(CPU86_LDouble x); |
276 |
|
extern CPU86_LDouble tan(CPU86_LDouble x); |
277 |
|
extern CPU86_LDouble atan2(CPU86_LDouble, CPU86_LDouble); |
278 |
|
extern CPU86_LDouble floor(CPU86_LDouble x); |
279 |
|
extern CPU86_LDouble ceil(CPU86_LDouble x); |
280 |
|
extern CPU86_LDouble rint(CPU86_LDouble x); |
281 |
|
|
282 |
|
#define RC_MASK 0xc00 |
283 |
|
#define RC_NEAR 0x000 |
284 |
|
#define RC_DOWN 0x400 |
285 |
|
#define RC_UP 0x800 |
286 |
|
#define RC_CHOP 0xc00 |
287 |
|
|
288 |
|
#define MAXTAN 9223372036854775808.0 |
289 |
|
|
290 |
|
#ifdef USE_X86LDOUBLE |
291 |
|
|
292 |
|
/* only for x86 */ |
293 |
|
typedef union { |
294 |
|
long double d; |
295 |
|
struct { |
296 |
|
unsigned long long lower; |
297 |
|
unsigned short upper; |
298 |
|
} l; |
299 |
|
} CPU86_LDoubleU; |
300 |
|
|
301 |
|
/* the following deal with x86 long double-precision numbers */ |
302 |
|
#define MAXEXPD 0x7fff |
303 |
|
#define EXPBIAS 16383 |
304 |
|
#define EXPD(fp) (fp.l.upper & 0x7fff) |
305 |
|
#define SIGND(fp) ((fp.l.upper) & 0x8000) |
306 |
|
#define MANTD(fp) (fp.l.lower) |
307 |
|
#define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7fff)) | EXPBIAS |
308 |
|
|
309 |
|
#else |
310 |
|
|
311 |
|
typedef union { |
312 |
|
double d; |
313 |
|
#ifndef WORDS_BIGENDIAN |
314 |
|
struct { |
315 |
|
uint32_t lower; |
316 |
|
int32_t upper; |
317 |
|
} l; |
318 |
|
#else |
319 |
|
struct { |
320 |
|
int32_t upper; |
321 |
|
uint32_t lower; |
322 |
|
} l; |
323 |
|
#endif |
324 |
|
int64_t ll; |
325 |
|
} CPU86_LDoubleU; |
326 |
|
|
327 |
|
/* the following deal with IEEE double-precision numbers */ |
328 |
|
#define MAXEXPD 0x7ff |
329 |
|
#define EXPBIAS 1023 |
330 |
|
#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) |
331 |
|
#define SIGND(fp) ((fp.l.upper) & 0x80000000) |
332 |
|
#define MANTD(fp) (fp.ll & ((1LL << 52) - 1)) |
333 |
|
#define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7ff << 20)) | (EXPBIAS << 20) |
334 |
|
#endif |
335 |
|
|
336 |
|
static inline void fpush(void) |
337 |
|
{ |
338 |
|
env->fpstt = (env->fpstt - 1) & 7; |
339 |
|
env->fptags[env->fpstt] = 0; /* validate stack entry */ |
340 |
|
} |
341 |
|
|
342 |
|
static inline void fpop(void) |
343 |
|
{ |
344 |
|
env->fptags[env->fpstt] = 1; /* invvalidate stack entry */ |
345 |
|
env->fpstt = (env->fpstt + 1) & 7; |
346 |
|
} |
347 |
|
|
348 |
|
#ifndef USE_X86LDOUBLE |
349 |
|
static inline CPU86_LDouble helper_fldt(uint8_t *ptr) |
350 |
|
{ |
351 |
|
CPU86_LDoubleU temp; |
352 |
|
int upper, e; |
353 |
|
/* mantissa */ |
354 |
|
upper = lduw(ptr + 8); |
355 |
|
/* XXX: handle overflow ? */ |
356 |
|
e = (upper & 0x7fff) - 16383 + EXPBIAS; /* exponent */ |
357 |
|
e |= (upper >> 4) & 0x800; /* sign */ |
358 |
|
temp.ll = ((ldq(ptr) >> 11) & ((1LL << 52) - 1)) | ((uint64_t)e << 52); |
359 |
|
return temp.d; |
360 |
|
} |
361 |
|
|
362 |
|
static inline void helper_fstt(CPU86_LDouble f, uint8_t *ptr) |
363 |
|
{ |
364 |
|
CPU86_LDoubleU temp; |
365 |
|
int e; |
366 |
|
temp.d = f; |
367 |
|
/* mantissa */ |
368 |
|
stq(ptr, (MANTD(temp) << 11) | (1LL << 63)); |
369 |
|
/* exponent + sign */ |
370 |
|
e = EXPD(temp) - EXPBIAS + 16383; |
371 |
|
e |= SIGND(temp) >> 16; |
372 |
|
stw(ptr + 8, e); |
373 |
|
} |
374 |
|
#endif |
375 |
|
|
376 |
|
void helper_fldt_ST0_A0(void); |
377 |
|
void helper_fstt_ST0_A0(void); |
378 |
|
void helper_fbld_ST0_A0(void); |
379 |
|
void helper_fbst_ST0_A0(void); |
380 |
|
void helper_f2xm1(void); |
381 |
|
void helper_fyl2x(void); |
382 |
|
void helper_fptan(void); |
383 |
|
void helper_fpatan(void); |
384 |
|
void helper_fxtract(void); |
385 |
|
void helper_fprem1(void); |
386 |
|
void helper_fprem(void); |
387 |
|
void helper_fyl2xp1(void); |
388 |
|
void helper_fsqrt(void); |
389 |
|
void helper_fsincos(void); |
390 |
|
void helper_frndint(void); |
391 |
|
void helper_fscale(void); |
392 |
|
void helper_fsin(void); |
393 |
|
void helper_fcos(void); |
394 |
|
void helper_fxam_ST0(void); |
395 |
|
void helper_fstenv(uint8_t *ptr, int data32); |
396 |
|
void helper_fldenv(uint8_t *ptr, int data32); |
397 |
|
void helper_fsave(uint8_t *ptr, int data32); |
398 |
|
void helper_frstor(uint8_t *ptr, int data32); |
399 |
|
|