139 |
#include "cpu.h" |
#include "cpu.h" |
140 |
#include "exec-all.h" |
#include "exec-all.h" |
141 |
|
|
|
/* XXX: add a generic FPU library */ |
|
|
|
|
|
static inline double float32_to_float64(float a) |
|
|
{ |
|
|
return a; |
|
|
} |
|
|
|
|
|
static inline float float64_to_float32(double a) |
|
|
{ |
|
|
return a; |
|
|
} |
|
|
|
|
|
#if defined(__powerpc__) |
|
|
/* better to call an helper on ppc */ |
|
|
float int32_to_float32(int32_t a); |
|
|
double int32_to_float64(int32_t a); |
|
|
#else |
|
|
static inline float int32_to_float32(int32_t a) |
|
|
{ |
|
|
return (float)a; |
|
|
} |
|
|
|
|
|
static inline double int32_to_float64(int32_t a) |
|
|
{ |
|
|
return (double)a; |
|
|
} |
|
|
#endif |
|
|
|
|
|
static inline float int64_to_float32(int64_t a) |
|
|
{ |
|
|
return (float)a; |
|
|
} |
|
|
|
|
|
static inline double int64_to_float64(int64_t a) |
|
|
{ |
|
|
return (double)a; |
|
|
} |
|
|
|
|
142 |
typedef struct CCTable { |
typedef struct CCTable { |
143 |
int (*compute_all)(void); /* return all the flags */ |
int (*compute_all)(void); /* return all the flags */ |
144 |
int (*compute_c)(void); /* return the C flag */ |
int (*compute_c)(void); /* return the C flag */ |
320 |
|
|
321 |
#ifdef USE_X86LDOUBLE |
#ifdef USE_X86LDOUBLE |
322 |
/* use long double functions */ |
/* use long double functions */ |
323 |
#define lrint lrintl |
#define floatx_to_int32 floatx80_to_int32 |
324 |
#define llrint llrintl |
#define floatx_to_int64 floatx80_to_int64 |
325 |
#define fabs fabsl |
#define floatx_abs floatx80_abs |
326 |
|
#define floatx_chs floatx80_chs |
327 |
|
#define floatx_round_to_int floatx80_round_to_int |
328 |
#define sin sinl |
#define sin sinl |
329 |
#define cos cosl |
#define cos cosl |
330 |
#define sqrt sqrtl |
#define sqrt sqrtl |
334 |
#define atan2 atan2l |
#define atan2 atan2l |
335 |
#define floor floorl |
#define floor floorl |
336 |
#define ceil ceill |
#define ceil ceill |
|
#define rint rintl |
|
|
#endif |
|
|
|
|
|
#if !defined(_BSD) |
|
|
extern int lrint(CPU86_LDouble x); |
|
|
extern int64_t llrint(CPU86_LDouble x); |
|
337 |
#else |
#else |
338 |
#define lrint(d) ((int)rint(d)) |
#define floatx_to_int32 float64_to_int32 |
339 |
#define llrint(d) ((int)rint(d)) |
#define floatx_to_int64 float64_to_int64 |
340 |
|
#define floatx_abs float64_abs |
341 |
|
#define floatx_chs float64_chs |
342 |
|
#define floatx_round_to_int float64_round_to_int |
343 |
#endif |
#endif |
344 |
extern CPU86_LDouble fabs(CPU86_LDouble x); |
|
345 |
extern CPU86_LDouble sin(CPU86_LDouble x); |
extern CPU86_LDouble sin(CPU86_LDouble x); |
346 |
extern CPU86_LDouble cos(CPU86_LDouble x); |
extern CPU86_LDouble cos(CPU86_LDouble x); |
347 |
extern CPU86_LDouble sqrt(CPU86_LDouble x); |
extern CPU86_LDouble sqrt(CPU86_LDouble x); |
351 |
extern CPU86_LDouble atan2(CPU86_LDouble, CPU86_LDouble); |
extern CPU86_LDouble atan2(CPU86_LDouble, CPU86_LDouble); |
352 |
extern CPU86_LDouble floor(CPU86_LDouble x); |
extern CPU86_LDouble floor(CPU86_LDouble x); |
353 |
extern CPU86_LDouble ceil(CPU86_LDouble x); |
extern CPU86_LDouble ceil(CPU86_LDouble x); |
|
extern CPU86_LDouble rint(CPU86_LDouble x); |
|
354 |
|
|
355 |
#define RC_MASK 0xc00 |
#define RC_MASK 0xc00 |
356 |
#define RC_NEAR 0x000 |
#define RC_NEAR 0x000 |
360 |
|
|
361 |
#define MAXTAN 9223372036854775808.0 |
#define MAXTAN 9223372036854775808.0 |
362 |
|
|
|
#ifdef __arm__ |
|
|
/* we have no way to do correct rounding - a FPU emulator is needed */ |
|
|
#define FE_DOWNWARD FE_TONEAREST |
|
|
#define FE_UPWARD FE_TONEAREST |
|
|
#define FE_TOWARDZERO FE_TONEAREST |
|
|
#endif |
|
|
|
|
363 |
#ifdef USE_X86LDOUBLE |
#ifdef USE_X86LDOUBLE |
364 |
|
|
365 |
/* only for x86 */ |
/* only for x86 */ |
549 |
float approx_rcp(float a); |
float approx_rcp(float a); |
550 |
double helper_sqrt(double a); |
double helper_sqrt(double a); |
551 |
int fpu_isnan(double a); |
int fpu_isnan(double a); |
552 |
|
void update_fp_status(void); |
553 |
|
|
554 |
extern const uint8_t parity_table[256]; |
extern const uint8_t parity_table[256]; |
555 |
extern const uint8_t rclw_table[32]; |
extern const uint8_t rclw_table[32]; |