Commit 1f1af9fd7f3fc83a3f933122f772d3a3f8663369
1 parent
858693c6
added cpu_get_fp80() and cpu_set_fp80()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@687 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
62 additions
and
2 deletions
target-i386/cpu.h
... | ... | @@ -408,6 +408,10 @@ static inline void cpu_x86_set_cpl(CPUX86State *s, int cpl) |
408 | 408 | #endif |
409 | 409 | } |
410 | 410 | |
411 | +/* used for debug or cpu save/restore */ | |
412 | +void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f); | |
413 | +CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper); | |
414 | + | |
411 | 415 | /* the following helpers are only usable in user mode simulation as |
412 | 416 | they can trigger unexpected exceptions */ |
413 | 417 | void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector); | ... | ... |
target-i386/helper.c
... | ... | @@ -2005,8 +2005,6 @@ void helper_fstt_ST0_A0(void) |
2005 | 2005 | |
2006 | 2006 | /* BCD ops */ |
2007 | 2007 | |
2008 | -#define MUL10(iv) ( iv + iv + (iv << 3) ) | |
2009 | - | |
2010 | 2008 | void helper_fbld_ST0_A0(void) |
2011 | 2009 | { |
2012 | 2010 | CPU86_LDouble tmp; |
... | ... | @@ -2431,6 +2429,64 @@ void helper_frstor(uint8_t *ptr, int data32) |
2431 | 2429 | } |
2432 | 2430 | } |
2433 | 2431 | |
2432 | +/* XXX: merge with helper_fstt ? */ | |
2433 | + | |
2434 | +#ifndef USE_X86LDOUBLE | |
2435 | + | |
2436 | +void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f) | |
2437 | +{ | |
2438 | + CPU86_LDoubleU temp; | |
2439 | + int e; | |
2440 | + | |
2441 | + temp.d = f; | |
2442 | + /* mantissa */ | |
2443 | + *pmant = (MANTD(temp) << 11) | (1LL << 63); | |
2444 | + /* exponent + sign */ | |
2445 | + e = EXPD(temp) - EXPBIAS + 16383; | |
2446 | + e |= SIGND(temp) >> 16; | |
2447 | + *pexp = e; | |
2448 | +} | |
2449 | + | |
2450 | +CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper) | |
2451 | +{ | |
2452 | + CPU86_LDoubleU temp; | |
2453 | + int e; | |
2454 | + uint64_t ll; | |
2455 | + | |
2456 | + /* XXX: handle overflow ? */ | |
2457 | + e = (upper & 0x7fff) - 16383 + EXPBIAS; /* exponent */ | |
2458 | + e |= (upper >> 4) & 0x800; /* sign */ | |
2459 | + ll = (mant >> 11) & ((1LL << 52) - 1); | |
2460 | +#ifdef __arm__ | |
2461 | + temp.l.upper = (e << 20) | (ll >> 32); | |
2462 | + temp.l.lower = ll; | |
2463 | +#else | |
2464 | + temp.ll = ll | ((uint64_t)e << 52); | |
2465 | +#endif | |
2466 | + return temp.d; | |
2467 | +} | |
2468 | + | |
2469 | +#else | |
2470 | + | |
2471 | +void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f) | |
2472 | +{ | |
2473 | + CPU86_LDoubleU temp; | |
2474 | + | |
2475 | + temp.d = f; | |
2476 | + *pmant = temp.l.lower; | |
2477 | + *pexp = temp.l.upper; | |
2478 | +} | |
2479 | + | |
2480 | +CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper) | |
2481 | +{ | |
2482 | + CPU86_LDoubleU temp; | |
2483 | + | |
2484 | + temp.l.upper = upper; | |
2485 | + temp.l.lower = mant; | |
2486 | + return temp.d; | |
2487 | +} | |
2488 | +#endif | |
2489 | + | |
2434 | 2490 | #if !defined(CONFIG_USER_ONLY) |
2435 | 2491 | |
2436 | 2492 | #define MMUSUFFIX _mmu | ... | ... |