Commit e163bca720425289b812e5e2c049e6139608c2ea
1 parent
8c6939c0
weird arm double format support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@219 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
31 additions
and
3 deletions
exec-i386.h
| @@ -243,11 +243,14 @@ void raise_interrupt(int intno, int is_int, int error_code, | @@ -243,11 +243,14 @@ void raise_interrupt(int intno, int is_int, int error_code, | ||
| 243 | unsigned int next_eip); | 243 | unsigned int next_eip); |
| 244 | void raise_exception_err(int exception_index, int error_code); | 244 | void raise_exception_err(int exception_index, int error_code); |
| 245 | void raise_exception(int exception_index); | 245 | void raise_exception(int exception_index); |
| 246 | +void helper_divl_EAX_T0(uint32_t eip); | ||
| 247 | +void helper_idivl_EAX_T0(uint32_t eip); | ||
| 248 | +void helper_cmpxchg8b(void); | ||
| 246 | void helper_cpuid(void); | 249 | void helper_cpuid(void); |
| 250 | +void helper_rdtsc(void); | ||
| 247 | void helper_lsl(void); | 251 | void helper_lsl(void); |
| 248 | void helper_lar(void); | 252 | void helper_lar(void); |
| 249 | 253 | ||
| 250 | - | ||
| 251 | #ifdef USE_X86LDOUBLE | 254 | #ifdef USE_X86LDOUBLE |
| 252 | /* use long double functions */ | 255 | /* use long double functions */ |
| 253 | #define lrint lrintl | 256 | #define lrint lrintl |
| @@ -287,6 +290,13 @@ extern CPU86_LDouble rint(CPU86_LDouble x); | @@ -287,6 +290,13 @@ extern CPU86_LDouble rint(CPU86_LDouble x); | ||
| 287 | 290 | ||
| 288 | #define MAXTAN 9223372036854775808.0 | 291 | #define MAXTAN 9223372036854775808.0 |
| 289 | 292 | ||
| 293 | +#ifdef __arm__ | ||
| 294 | +/* we have no way to do correct rounding - a FPU emulator is needed */ | ||
| 295 | +#define FE_DOWNWARD FE_TONEAREST | ||
| 296 | +#define FE_UPWARD FE_TONEAREST | ||
| 297 | +#define FE_TOWARDZERO FE_TONEAREST | ||
| 298 | +#endif | ||
| 299 | + | ||
| 290 | #ifdef USE_X86LDOUBLE | 300 | #ifdef USE_X86LDOUBLE |
| 291 | 301 | ||
| 292 | /* only for x86 */ | 302 | /* only for x86 */ |
| @@ -308,9 +318,10 @@ typedef union { | @@ -308,9 +318,10 @@ typedef union { | ||
| 308 | 318 | ||
| 309 | #else | 319 | #else |
| 310 | 320 | ||
| 321 | +/* NOTE: arm is horrible as double 32 bit words are stored in big endian ! */ | ||
| 311 | typedef union { | 322 | typedef union { |
| 312 | double d; | 323 | double d; |
| 313 | -#ifndef WORDS_BIGENDIAN | 324 | +#if !defined(WORDS_BIGENDIAN) && !defined(__arm__) |
| 314 | struct { | 325 | struct { |
| 315 | uint32_t lower; | 326 | uint32_t lower; |
| 316 | int32_t upper; | 327 | int32_t upper; |
| @@ -321,7 +332,9 @@ typedef union { | @@ -321,7 +332,9 @@ typedef union { | ||
| 321 | uint32_t lower; | 332 | uint32_t lower; |
| 322 | } l; | 333 | } l; |
| 323 | #endif | 334 | #endif |
| 335 | +#ifndef __arm__ | ||
| 324 | int64_t ll; | 336 | int64_t ll; |
| 337 | +#endif | ||
| 325 | } CPU86_LDoubleU; | 338 | } CPU86_LDoubleU; |
| 326 | 339 | ||
| 327 | /* the following deal with IEEE double-precision numbers */ | 340 | /* the following deal with IEEE double-precision numbers */ |
| @@ -329,7 +342,11 @@ typedef union { | @@ -329,7 +342,11 @@ typedef union { | ||
| 329 | #define EXPBIAS 1023 | 342 | #define EXPBIAS 1023 |
| 330 | #define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) | 343 | #define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) |
| 331 | #define SIGND(fp) ((fp.l.upper) & 0x80000000) | 344 | #define SIGND(fp) ((fp.l.upper) & 0x80000000) |
| 345 | +#ifdef __arm__ | ||
| 346 | +#define MANTD(fp) (fp.l.lower | ((uint64_t)(fp.l.upper & ((1 << 20) - 1)) << 32)) | ||
| 347 | +#else | ||
| 332 | #define MANTD(fp) (fp.ll & ((1LL << 52) - 1)) | 348 | #define MANTD(fp) (fp.ll & ((1LL << 52) - 1)) |
| 349 | +#endif | ||
| 333 | #define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7ff << 20)) | (EXPBIAS << 20) | 350 | #define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7ff << 20)) | (EXPBIAS << 20) |
| 334 | #endif | 351 | #endif |
| 335 | 352 | ||
| @@ -350,12 +367,20 @@ static inline CPU86_LDouble helper_fldt(uint8_t *ptr) | @@ -350,12 +367,20 @@ static inline CPU86_LDouble helper_fldt(uint8_t *ptr) | ||
| 350 | { | 367 | { |
| 351 | CPU86_LDoubleU temp; | 368 | CPU86_LDoubleU temp; |
| 352 | int upper, e; | 369 | int upper, e; |
| 370 | + uint64_t ll; | ||
| 371 | + | ||
| 353 | /* mantissa */ | 372 | /* mantissa */ |
| 354 | upper = lduw(ptr + 8); | 373 | upper = lduw(ptr + 8); |
| 355 | /* XXX: handle overflow ? */ | 374 | /* XXX: handle overflow ? */ |
| 356 | e = (upper & 0x7fff) - 16383 + EXPBIAS; /* exponent */ | 375 | e = (upper & 0x7fff) - 16383 + EXPBIAS; /* exponent */ |
| 357 | e |= (upper >> 4) & 0x800; /* sign */ | 376 | e |= (upper >> 4) & 0x800; /* sign */ |
| 358 | - temp.ll = ((ldq(ptr) >> 11) & ((1LL << 52) - 1)) | ((uint64_t)e << 52); | 377 | + ll = (ldq(ptr) >> 11) & ((1LL << 52) - 1); |
| 378 | +#ifdef __arm__ | ||
| 379 | + temp.l.upper = (e << 20) | (ll >> 32); | ||
| 380 | + temp.l.lower = ll; | ||
| 381 | +#else | ||
| 382 | + temp.ll = ll | ((uint64_t)e << 52); | ||
| 383 | +#endif | ||
| 359 | return temp.d; | 384 | return temp.d; |
| 360 | } | 385 | } |
| 361 | 386 | ||
| @@ -363,6 +388,7 @@ static inline void helper_fstt(CPU86_LDouble f, uint8_t *ptr) | @@ -363,6 +388,7 @@ static inline void helper_fstt(CPU86_LDouble f, uint8_t *ptr) | ||
| 363 | { | 388 | { |
| 364 | CPU86_LDoubleU temp; | 389 | CPU86_LDoubleU temp; |
| 365 | int e; | 390 | int e; |
| 391 | + | ||
| 366 | temp.d = f; | 392 | temp.d = f; |
| 367 | /* mantissa */ | 393 | /* mantissa */ |
| 368 | stq(ptr, (MANTD(temp) << 11) | (1LL << 63)); | 394 | stq(ptr, (MANTD(temp) << 11) | (1LL << 63)); |
| @@ -373,6 +399,8 @@ static inline void helper_fstt(CPU86_LDouble f, uint8_t *ptr) | @@ -373,6 +399,8 @@ static inline void helper_fstt(CPU86_LDouble f, uint8_t *ptr) | ||
| 373 | } | 399 | } |
| 374 | #endif | 400 | #endif |
| 375 | 401 | ||
| 402 | +const CPU86_LDouble f15rk[7]; | ||
| 403 | + | ||
| 376 | void helper_fldt_ST0_A0(void); | 404 | void helper_fldt_ST0_A0(void); |
| 377 | void helper_fstt_ST0_A0(void); | 405 | void helper_fstt_ST0_A0(void); |
| 378 | void helper_fbld_ST0_A0(void); | 406 | void helper_fbld_ST0_A0(void); |