Commit 3d0d14f9 authored by Ingo Molnar's avatar Ingo Molnar

x86: lindent arch/i386/math-emu

lindent these files:
                                       errors   lines of code   errors/KLOC
 arch/x86/math-emu/                      2236            9424         237.2
 arch/x86/math-emu/                       128            8706          14.7

no other changes. No code changed:

   text    data     bss     dec     hex filename
   5589802  612739 3833856 10036397         9924ad vmlinux.before
   5589802  612739 3833856 10036397         9924ad vmlinux.after

the intent of this patch is to ease the automated tracking of kernel
code quality - it's just much easier for us to maintain it if every file
in arch/x86 is supposed to be clean.

NOTE: it is a known problem of lindent that it causes some style damage
of its own, but it's a safe tool (well, except for the gcc array range
initializers extension), so we did the bulk of the changes via lindent,
and did the manual fixups in a followup patch.

the resulting math-emu code has been tested by Thomas Gleixner on a real
386 DX CPU as well, and it works fine.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent a4ec1eff
This diff is collapsed.
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#ifndef _EXCEPTION_H_ #ifndef _EXCEPTION_H_
#define _EXCEPTION_H_ #define _EXCEPTION_H_
#ifdef __ASSEMBLY__ #ifdef __ASSEMBLY__
#define Const_(x) $##x #define Const_(x) $##x
#else #else
...@@ -20,8 +19,8 @@ ...@@ -20,8 +19,8 @@
#include "fpu_emu.h" #include "fpu_emu.h"
#endif /* SW_C1 */ #endif /* SW_C1 */
#define FPU_BUSY Const_(0x8000) /* FPU busy bit (8087 compatibility) */ #define FPU_BUSY Const_(0x8000) /* FPU busy bit (8087 compatibility) */
#define EX_ErrorSummary Const_(0x0080) /* Error summary status */ #define EX_ErrorSummary Const_(0x0080) /* Error summary status */
/* Special exceptions: */ /* Special exceptions: */
#define EX_INTERNAL Const_(0x8000) /* Internal error in wm-FPU-emu */ #define EX_INTERNAL Const_(0x8000) /* Internal error in wm-FPU-emu */
#define EX_StackOver Const_(0x0041|SW_C1) /* stack overflow */ #define EX_StackOver Const_(0x0041|SW_C1) /* stack overflow */
...@@ -34,11 +33,9 @@ ...@@ -34,11 +33,9 @@
#define EX_Denormal Const_(0x0002) /* denormalized operand */ #define EX_Denormal Const_(0x0002) /* denormalized operand */
#define EX_Invalid Const_(0x0001) /* invalid operation */ #define EX_Invalid Const_(0x0001) /* invalid operation */
#define PRECISION_LOST_UP Const_((EX_Precision | SW_C1)) #define PRECISION_LOST_UP Const_((EX_Precision | SW_C1))
#define PRECISION_LOST_DOWN Const_(EX_Precision) #define PRECISION_LOST_DOWN Const_(EX_Precision)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#ifdef DEBUG #ifdef DEBUG
...@@ -48,6 +45,6 @@ ...@@ -48,6 +45,6 @@
#define EXCEPTION(x) FPU_exception(x) #define EXCEPTION(x) FPU_exception(x)
#endif #endif
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* _EXCEPTION_H_ */ #endif /* _EXCEPTION_H_ */
...@@ -15,160 +15,138 @@ ...@@ -15,160 +15,138 @@
#include "control_w.h" #include "control_w.h"
#include "status_w.h" #include "status_w.h"
void fadd__(void) void fadd__(void)
{ {
/* fadd st,st(i) */ /* fadd st,st(i) */
int i = FPU_rm; int i = FPU_rm;
clear_C1(); clear_C1();
FPU_add(&st(i), FPU_gettagi(i), 0, control_word); FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
} }
void fmul__(void) void fmul__(void)
{ {
/* fmul st,st(i) */ /* fmul st,st(i) */
int i = FPU_rm; int i = FPU_rm;
clear_C1(); clear_C1();
FPU_mul(&st(i), FPU_gettagi(i), 0, control_word); FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
} }
void fsub__(void) void fsub__(void)
{ {
/* fsub st,st(i) */ /* fsub st,st(i) */
clear_C1(); clear_C1();
FPU_sub(0, FPU_rm, control_word); FPU_sub(0, FPU_rm, control_word);
} }
void fsubr_(void) void fsubr_(void)
{ {
/* fsubr st,st(i) */ /* fsubr st,st(i) */
clear_C1(); clear_C1();
FPU_sub(REV, FPU_rm, control_word); FPU_sub(REV, FPU_rm, control_word);
} }
void fdiv__(void) void fdiv__(void)
{ {
/* fdiv st,st(i) */ /* fdiv st,st(i) */
clear_C1(); clear_C1();
FPU_div(0, FPU_rm, control_word); FPU_div(0, FPU_rm, control_word);
} }
void fdivr_(void) void fdivr_(void)
{ {
/* fdivr st,st(i) */ /* fdivr st,st(i) */
clear_C1(); clear_C1();
FPU_div(REV, FPU_rm, control_word); FPU_div(REV, FPU_rm, control_word);
} }
void fadd_i(void) void fadd_i(void)
{ {
/* fadd st(i),st */ /* fadd st(i),st */
int i = FPU_rm; int i = FPU_rm;
clear_C1(); clear_C1();
FPU_add(&st(i), FPU_gettagi(i), i, control_word); FPU_add(&st(i), FPU_gettagi(i), i, control_word);
} }
void fmul_i(void) void fmul_i(void)
{ {
/* fmul st(i),st */ /* fmul st(i),st */
clear_C1(); clear_C1();
FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word); FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
} }
void fsubri(void) void fsubri(void)
{ {
/* fsubr st(i),st */ /* fsubr st(i),st */
clear_C1(); clear_C1();
FPU_sub(DEST_RM, FPU_rm, control_word); FPU_sub(DEST_RM, FPU_rm, control_word);
} }
void fsub_i(void) void fsub_i(void)
{ {
/* fsub st(i),st */ /* fsub st(i),st */
clear_C1(); clear_C1();
FPU_sub(REV|DEST_RM, FPU_rm, control_word); FPU_sub(REV | DEST_RM, FPU_rm, control_word);
} }
void fdivri(void) void fdivri(void)
{ {
/* fdivr st(i),st */ /* fdivr st(i),st */
clear_C1(); clear_C1();
FPU_div(DEST_RM, FPU_rm, control_word); FPU_div(DEST_RM, FPU_rm, control_word);
} }
void fdiv_i(void) void fdiv_i(void)
{ {
/* fdiv st(i),st */ /* fdiv st(i),st */
clear_C1(); clear_C1();
FPU_div(REV|DEST_RM, FPU_rm, control_word); FPU_div(REV | DEST_RM, FPU_rm, control_word);
} }
void faddp_(void) void faddp_(void)
{ {
/* faddp st(i),st */ /* faddp st(i),st */
int i = FPU_rm; int i = FPU_rm;
clear_C1(); clear_C1();
if ( FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0 ) if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0)
FPU_pop(); FPU_pop();
} }
void fmulp_(void) void fmulp_(void)
{ {
/* fmulp st(i),st */ /* fmulp st(i),st */
clear_C1(); clear_C1();
if ( FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0 ) if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
FPU_pop(); FPU_pop();
} }
void fsubrp(void) void fsubrp(void)
{ {
/* fsubrp st(i),st */ /* fsubrp st(i),st */
clear_C1(); clear_C1();
if ( FPU_sub(DEST_RM, FPU_rm, control_word) >= 0 ) if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
FPU_pop(); FPU_pop();
} }
void fsubp_(void) void fsubp_(void)
{ {
/* fsubp st(i),st */ /* fsubp st(i),st */
clear_C1(); clear_C1();
if ( FPU_sub(REV|DEST_RM, FPU_rm, control_word) >= 0 ) if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
FPU_pop(); FPU_pop();
} }
void fdivrp(void) void fdivrp(void)
{ {
/* fdivrp st(i),st */ /* fdivrp st(i),st */
clear_C1(); clear_C1();
if ( FPU_div(DEST_RM, FPU_rm, control_word) >= 0 ) if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
FPU_pop(); FPU_pop();
} }
void fdivp_(void) void fdivp_(void)
{ {
/* fdivp st(i),st */ /* fdivp st(i),st */
clear_C1(); clear_C1();
if ( FPU_div(REV|DEST_RM, FPU_rm, control_word) >= 0 ) if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
FPU_pop(); FPU_pop();
} }
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#define EXCEPTION FPU_exception #define EXCEPTION FPU_exception
#define PARAM1 8(%ebp) #define PARAM1 8(%ebp)
#define PARAM2 12(%ebp) #define PARAM2 12(%ebp)
#define PARAM3 16(%ebp) #define PARAM3 16(%ebp)
......
...@@ -16,34 +16,34 @@ ...@@ -16,34 +16,34 @@
#include "status_w.h" #include "status_w.h"
#include "control_w.h" #include "control_w.h"
static void fnop(void) static void fnop(void)
{ {
} }
static void fclex(void) static void fclex(void)
{ {
partial_status &= ~(SW_Backward|SW_Summary|SW_Stack_Fault|SW_Precision| partial_status &=
SW_Underflow|SW_Overflow|SW_Zero_Div|SW_Denorm_Op| ~(SW_Backward | SW_Summary | SW_Stack_Fault | SW_Precision |
SW_Invalid); SW_Underflow | SW_Overflow | SW_Zero_Div | SW_Denorm_Op |
no_ip_update = 1; SW_Invalid);
no_ip_update = 1;
} }
/* Needs to be externally visible */ /* Needs to be externally visible */
void finit(void) void finit(void)
{ {
control_word = 0x037f; control_word = 0x037f;
partial_status = 0; partial_status = 0;
top = 0; /* We don't keep top in the status word internally. */ top = 0; /* We don't keep top in the status word internally. */
fpu_tag_word = 0xffff; fpu_tag_word = 0xffff;
/* The behaviour is different from that detailed in /* The behaviour is different from that detailed in
Section 15.1.6 of the Intel manual */ Section 15.1.6 of the Intel manual */
operand_address.offset = 0; operand_address.offset = 0;
operand_address.selector = 0; operand_address.selector = 0;
instruction_address.offset = 0; instruction_address.offset = 0;
instruction_address.selector = 0; instruction_address.selector = 0;
instruction_address.opcode = 0; instruction_address.opcode = 0;
no_ip_update = 1; no_ip_update = 1;
} }
/* /*
...@@ -54,151 +54,134 @@ void finit(void) ...@@ -54,151 +54,134 @@ void finit(void)
#define fsetpm fnop #define fsetpm fnop
static FUNC const finit_table[] = { static FUNC const finit_table[] = {
feni, fdisi, fclex, finit, feni, fdisi, fclex, finit,
fsetpm, FPU_illegal, FPU_illegal, FPU_illegal fsetpm, FPU_illegal, FPU_illegal, FPU_illegal
}; };
void finit_(void) void finit_(void)
{ {
(finit_table[FPU_rm])(); (finit_table[FPU_rm]) ();
} }
static void fstsw_ax(void) static void fstsw_ax(void)
{ {
*(short *) &FPU_EAX = status_word(); *(short *)&FPU_EAX = status_word();
no_ip_update = 1; no_ip_update = 1;
} }
static FUNC const fstsw_table[] = { static FUNC const fstsw_table[] = {
fstsw_ax, FPU_illegal, FPU_illegal, FPU_illegal, fstsw_ax, FPU_illegal, FPU_illegal, FPU_illegal,
FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal
}; };
void fstsw_(void) void fstsw_(void)
{ {
(fstsw_table[FPU_rm])(); (fstsw_table[FPU_rm]) ();
} }
static FUNC const fp_nop_table[] = { static FUNC const fp_nop_table[] = {
fnop, FPU_illegal, FPU_illegal, FPU_illegal, fnop, FPU_illegal, FPU_illegal, FPU_illegal,
FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal
}; };
void fp_nop(void) void fp_nop(void)
{ {
(fp_nop_table[FPU_rm])(); (fp_nop_table[FPU_rm]) ();
} }
void fld_i_(void) void fld_i_(void)
{ {
FPU_REG *st_new_ptr; FPU_REG *st_new_ptr;
int i; int i;
u_char tag; u_char tag;
if ( STACK_OVERFLOW ) if (STACK_OVERFLOW) {
{ FPU_stack_overflow(); return; } FPU_stack_overflow();
return;
/* fld st(i) */
i = FPU_rm;
if ( NOT_EMPTY(i) )
{
reg_copy(&st(i), st_new_ptr);
tag = FPU_gettagi(i);
push();
FPU_settag0(tag);
}
else
{
if ( control_word & CW_Invalid )
{
/* The masked response */
FPU_stack_underflow();
} }
else
EXCEPTION(EX_StackUnder);
}
} /* fld st(i) */
i = FPU_rm;
if (NOT_EMPTY(i)) {
reg_copy(&st(i), st_new_ptr);
tag = FPU_gettagi(i);
push();
FPU_settag0(tag);
} else {
if (control_word & CW_Invalid) {
/* The masked response */
FPU_stack_underflow();
} else
EXCEPTION(EX_StackUnder);
}
}
void fxch_i(void) void fxch_i(void)
{ {
/* fxch st(i) */ /* fxch st(i) */
FPU_REG t; FPU_REG t;
int i = FPU_rm; int i = FPU_rm;
FPU_REG *st0_ptr = &st(0), *sti_ptr = &st(i); FPU_REG *st0_ptr = &st(0), *sti_ptr = &st(i);
long tag_word = fpu_tag_word; long tag_word = fpu_tag_word;
int regnr = top & 7, regnri = ((regnr + i) & 7); int regnr = top & 7, regnri = ((regnr + i) & 7);
u_char st0_tag = (tag_word >> (regnr*2)) & 3; u_char st0_tag = (tag_word >> (regnr * 2)) & 3;
u_char sti_tag = (tag_word >> (regnri*2)) & 3; u_char sti_tag = (tag_word >> (regnri * 2)) & 3;
if ( st0_tag == TAG_Empty ) if (st0_tag == TAG_Empty) {
{ if (sti_tag == TAG_Empty) {
if ( sti_tag == TAG_Empty ) FPU_stack_underflow();
{ FPU_stack_underflow_i(i);
FPU_stack_underflow(); return;
FPU_stack_underflow_i(i); }
return; if (control_word & CW_Invalid) {
/* Masked response */
FPU_copy_to_reg0(sti_ptr, sti_tag);
}
FPU_stack_underflow_i(i);
return;
} }
if ( control_word & CW_Invalid ) if (sti_tag == TAG_Empty) {
{ if (control_word & CW_Invalid) {
/* Masked response */ /* Masked response */
FPU_copy_to_reg0(sti_ptr, sti_tag); FPU_copy_to_regi(st0_ptr, st0_tag, i);
}
FPU_stack_underflow();
return;
} }
FPU_stack_underflow_i(i); clear_C1();
return;
}
if ( sti_tag == TAG_Empty )
{
if ( control_word & CW_Invalid )
{
/* Masked response */
FPU_copy_to_regi(st0_ptr, st0_tag, i);
}
FPU_stack_underflow();
return;
}
clear_C1();
reg_copy(st0_ptr, &t);
reg_copy(sti_ptr, st0_ptr);
reg_copy(&t, sti_ptr);
tag_word &= ~(3 << (regnr*2)) & ~(3 << (regnri*2));
tag_word |= (sti_tag << (regnr*2)) | (st0_tag << (regnri*2));
fpu_tag_word = tag_word;
}
reg_copy(st0_ptr, &t);
reg_copy(sti_ptr, st0_ptr);
reg_copy(&t, sti_ptr);
tag_word &= ~(3 << (regnr * 2)) & ~(3 << (regnri * 2));
tag_word |= (sti_tag << (regnr * 2)) | (st0_tag << (regnri * 2));
fpu_tag_word = tag_word;
}
void ffree_(void) void ffree_(void)
{ {
/* ffree st(i) */ /* ffree st(i) */
FPU_settagi(FPU_rm, TAG_Empty); FPU_settagi(FPU_rm, TAG_Empty);
} }
void ffreep(void) void ffreep(void)
{ {
/* ffree st(i) + pop - unofficial code */ /* ffree st(i) + pop - unofficial code */
FPU_settagi(FPU_rm, TAG_Empty); FPU_settagi(FPU_rm, TAG_Empty);
FPU_pop(); FPU_pop();
} }
void fst_i_(void) void fst_i_(void)
{ {
/* fst st(i) */ /* fst st(i) */
FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm); FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm);
} }
void fstp_i(void) void fstp_i(void)
{ {
/* fstp st(i) */ /* fstp st(i) */
FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm); FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm);
FPU_pop(); FPU_pop();
} }
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
| | | |
+---------------------------------------------------------------------------*/ +---------------------------------------------------------------------------*/
#ifndef _FPU_EMU_H_ #ifndef _FPU_EMU_H_
#define _FPU_EMU_H_ #define _FPU_EMU_H_
...@@ -28,15 +27,15 @@ ...@@ -28,15 +27,15 @@
#endif #endif
#define EXP_BIAS Const(0) #define EXP_BIAS Const(0)
#define EXP_OVER Const(0x4000) /* smallest invalid large exponent */ #define EXP_OVER Const(0x4000) /* smallest invalid large exponent */
#define EXP_UNDER Const(-0x3fff) /* largest invalid small exponent */ #define EXP_UNDER Const(-0x3fff) /* largest invalid small exponent */
#define EXP_WAY_UNDER Const(-0x6000) /* Below the smallest denormal, but #define EXP_WAY_UNDER Const(-0x6000) /* Below the smallest denormal, but
still a 16 bit nr. */ still a 16 bit nr. */
#define EXP_Infinity EXP_OVER #define EXP_Infinity EXP_OVER
#define EXP_NaN EXP_OVER #define EXP_NaN EXP_OVER
#define EXTENDED_Ebias Const(0x3fff) #define EXTENDED_Ebias Const(0x3fff)
#define EXTENDED_Emin (-0x3ffe) /* smallest valid exponent */ #define EXTENDED_Emin (-0x3ffe) /* smallest valid exponent */
#define SIGN_POS Const(0) #define SIGN_POS Const(0)
#define SIGN_NEG Const(0x80) #define SIGN_NEG Const(0x80)
...@@ -44,10 +43,9 @@ ...@@ -44,10 +43,9 @@
#define SIGN_Positive Const(0) #define SIGN_Positive Const(0)
#define SIGN_Negative Const(0x8000) #define SIGN_Negative Const(0x8000)
/* Keep the order TAG_Valid, TAG_Zero, TW_Denormal */ /* Keep the order TAG_Valid, TAG_Zero, TW_Denormal */
/* The following fold to 2 (Special) in the Tag Word */ /* The following fold to 2 (Special) in the Tag Word */
#define TW_Denormal Const(4) /* De-normal */ #define TW_Denormal Const(4) /* De-normal */
#define TW_Infinity Const(5) /* + or - infinity */ #define TW_Infinity Const(5) /* + or - infinity */
#define TW_NaN Const(6) /* Not a Number */ #define TW_NaN Const(6) /* Not a Number */
#define TW_Unsupported Const(7) /* Not supported by an 80486 */ #define TW_Unsupported Const(7) /* Not supported by an 80486 */
...@@ -67,14 +65,13 @@ ...@@ -67,14 +65,13 @@
#define DEST_RM 0x20 #define DEST_RM 0x20
#define LOADED 0x40 #define LOADED 0x40
#define FPU_Exception Const(0x80000000) /* Added to tag returns. */ #define FPU_Exception Const(0x80000000) /* Added to tag returns. */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include "fpu_system.h" #include "fpu_system.h"
#include <asm/sigcontext.h> /* for struct _fpstate */ #include <asm/sigcontext.h> /* for struct _fpstate */
#include <asm/math_emu.h> #include <asm/math_emu.h>
#include <linux/linkage.h> #include <linux/linkage.h>
...@@ -112,30 +109,33 @@ extern u_char emulating; ...@@ -112,30 +109,33 @@ extern u_char emulating;
#define PREFIX_DEFAULT 7 #define PREFIX_DEFAULT 7
struct address { struct address {
unsigned int offset; unsigned int offset;
unsigned int selector:16; unsigned int selector:16;
unsigned int opcode:11; unsigned int opcode:11;
unsigned int empty:5; unsigned int empty:5;
}; };
struct fpu__reg { struct fpu__reg {
unsigned sigl; unsigned sigl;
unsigned sigh; unsigned sigh;
short exp; short exp;
}; };
typedef void (*FUNC)(void); typedef void (*FUNC) (void);
typedef struct fpu__reg FPU_REG; typedef struct fpu__reg FPU_REG;
typedef void (*FUNC_ST0)(FPU_REG *st0_ptr, u_char st0_tag); typedef void (*FUNC_ST0) (FPU_REG * st0_ptr, u_char st0_tag);
typedef struct { u_char address_size, operand_size, segment; } typedef struct {
overrides; u_char address_size, operand_size, segment;
} overrides;
/* This structure is 32 bits: */ /* This structure is 32 bits: */
typedef struct { overrides override; typedef struct {
u_char default_mode; } fpu_addr_modes; overrides override;
u_char default_mode;
} fpu_addr_modes;
/* PROTECTED has a restricted meaning in the emulator; it is used /* PROTECTED has a restricted meaning in the emulator; it is used
to signal that the emulator needs to do special things to ensure to signal that the emulator needs to do special things to ensure
that protection is respected in a segmented model. */ that protection is respected in a segmented model. */
#define PROTECTED 4 #define PROTECTED 4
#define SIXTEEN 1 /* We rely upon this being 1 (true) */ #define SIXTEEN 1 /* We rely upon this being 1 (true) */
#define VM86 SIXTEEN #define VM86 SIXTEEN
#define PM16 (SIXTEEN | PROTECTED) #define PM16 (SIXTEEN | PROTECTED)
#define SEG32 PROTECTED #define SEG32 PROTECTED
...@@ -166,10 +166,10 @@ extern u_char const data_sizes_16[32]; ...@@ -166,10 +166,10 @@ extern u_char const data_sizes_16[32];
#define signpositive(a) ( (signbyte(a) & 0x80) == 0 ) #define signpositive(a) ( (signbyte(a) & 0x80) == 0 )
#define signnegative(a) (signbyte(a) & 0x80) #define signnegative(a) (signbyte(a) & 0x80)
static inline void reg_copy(FPU_REG const *x, FPU_REG *y) static inline void reg_copy(FPU_REG const *x, FPU_REG * y)
{ {
*(short *)&(y->exp) = *(const short *)&(x->exp); *(short *)&(y->exp) = *(const short *)&(x->exp);
*(long long *)&(y->sigl) = *(const long long *)&(x->sigl); *(long long *)&(y->sigl) = *(const long long *)&(x->sigl);
} }
#define exponent(x) (((*(short *)&((x)->exp)) & 0x7fff) - EXTENDED_Ebias) #define exponent(x) (((*(short *)&((x)->exp)) & 0x7fff) - EXTENDED_Ebias)
...@@ -184,29 +184,28 @@ static inline void reg_copy(FPU_REG const *x, FPU_REG *y) ...@@ -184,29 +184,28 @@ static inline void reg_copy(FPU_REG const *x, FPU_REG *y)
#define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] ) #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
/*----- Prototypes for functions written in assembler -----*/ /*----- Prototypes for functions written in assembler -----*/
/* extern void reg_move(FPU_REG *a, FPU_REG *b); */ /* extern void reg_move(FPU_REG *a, FPU_REG *b); */
asmlinkage int FPU_normalize(FPU_REG *x); asmlinkage int FPU_normalize(FPU_REG * x);
asmlinkage int FPU_normalize_nuo(FPU_REG *x); asmlinkage int FPU_normalize_nuo(FPU_REG * x);
asmlinkage int FPU_u_sub(FPU_REG const *arg1, FPU_REG const *arg2, asmlinkage int FPU_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
FPU_REG *answ, unsigned int control_w, u_char sign, FPU_REG * answ, unsigned int control_w, u_char sign,
int expa, int expb); int expa, int expb);
asmlinkage int FPU_u_mul(FPU_REG const *arg1, FPU_REG const *arg2, asmlinkage int FPU_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
FPU_REG *answ, unsigned int control_w, u_char sign, FPU_REG * answ, unsigned int control_w, u_char sign,
int expon); int expon);
asmlinkage int FPU_u_div(FPU_REG const *arg1, FPU_REG const *arg2, asmlinkage int FPU_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
FPU_REG *answ, unsigned int control_w, u_char sign); FPU_REG * answ, unsigned int control_w, u_char sign);
asmlinkage int FPU_u_add(FPU_REG const *arg1, FPU_REG const *arg2, asmlinkage int FPU_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
FPU_REG *answ, unsigned int control_w, u_char sign, FPU_REG * answ, unsigned int control_w, u_char sign,
int expa, int expb); int expa, int expb);
asmlinkage int wm_sqrt(FPU_REG *n, int dummy1, int dummy2, asmlinkage int wm_sqrt(FPU_REG * n, int dummy1, int dummy2,
unsigned int control_w, u_char sign); unsigned int control_w, u_char sign);
asmlinkage unsigned FPU_shrx(void *l, unsigned x); asmlinkage unsigned FPU_shrx(void *l, unsigned x);
asmlinkage unsigned FPU_shrxs(void *v, unsigned x); asmlinkage unsigned FPU_shrxs(void *v, unsigned x);
asmlinkage unsigned long FPU_div_small(unsigned long long *x, unsigned long y); asmlinkage unsigned long FPU_div_small(unsigned long long *x, unsigned long y);
asmlinkage int FPU_round(FPU_REG *arg, unsigned int extent, int dummy, asmlinkage int FPU_round(FPU_REG * arg, unsigned int extent, int dummy,
unsigned int control_w, u_char sign); unsigned int control_w, u_char sign);
#ifndef MAKING_PROTO #ifndef MAKING_PROTO
......
This diff is collapsed.
...@@ -16,128 +16,115 @@ ...@@ -16,128 +16,115 @@
#include "status_w.h" #include "status_w.h"
#include "reg_constant.h" #include "reg_constant.h"
static void fchs(FPU_REG * st0_ptr, u_char st0tag)
static void fchs(FPU_REG *st0_ptr, u_char st0tag)
{ {
if ( st0tag ^ TAG_Empty ) if (st0tag ^ TAG_Empty) {
{ signbyte(st0_ptr) ^= SIGN_NEG;
signbyte(st0_ptr) ^= SIGN_NEG; clear_C1();
clear_C1(); } else
} FPU_stack_underflow();
else
FPU_stack_underflow();
} }
static void fabs(FPU_REG * st0_ptr, u_char st0tag)
static void fabs(FPU_REG *st0_ptr, u_char st0tag)
{ {
if ( st0tag ^ TAG_Empty ) if (st0tag ^ TAG_Empty) {
{ setpositive(st0_ptr);
setpositive(st0_ptr); clear_C1();
clear_C1(); } else
} FPU_stack_underflow();
else
FPU_stack_underflow();
} }
static void ftst_(FPU_REG * st0_ptr, u_char st0tag)
static void ftst_(FPU_REG *st0_ptr, u_char st0tag)
{ {
switch (st0tag) switch (st0tag) {
{ case TAG_Zero:
case TAG_Zero:
setcc(SW_C3);
break;
case TAG_Valid:
if (getsign(st0_ptr) == SIGN_POS)
setcc(0);
else
setcc(SW_C0);
break;
case TAG_Special:
switch ( FPU_Special(st0_ptr) )
{
case TW_Denormal:
if (getsign(st0_ptr) == SIGN_POS)
setcc(0);
else
setcc(SW_C0);
if ( denormal_operand() < 0 )
{
#ifdef PECULIAR_486
/* This is weird! */
if (getsign(st0_ptr) == SIGN_POS)
setcc(SW_C3); setcc(SW_C3);
break;
case TAG_Valid:
if (getsign(st0_ptr) == SIGN_POS)
setcc(0);
else
setcc(SW_C0);
break;
case TAG_Special:
switch (FPU_Special(st0_ptr)) {
case TW_Denormal:
if (getsign(st0_ptr) == SIGN_POS)
setcc(0);
else
setcc(SW_C0);
if (denormal_operand() < 0) {
#ifdef PECULIAR_486
/* This is weird! */
if (getsign(st0_ptr) == SIGN_POS)
setcc(SW_C3);
#endif /* PECULIAR_486 */ #endif /* PECULIAR_486 */
return; return;
} }
break; break;
case TW_NaN: case TW_NaN:
setcc(SW_C0|SW_C2|SW_C3); /* Operand is not comparable */ setcc(SW_C0 | SW_C2 | SW_C3); /* Operand is not comparable */
EXCEPTION(EX_Invalid); EXCEPTION(EX_Invalid);
break; break;
case TW_Infinity: case TW_Infinity:
if (getsign(st0_ptr) == SIGN_POS) if (getsign(st0_ptr) == SIGN_POS)
setcc(0); setcc(0);
else else
setcc(SW_C0); setcc(SW_C0);
break; break;
default: default:
setcc(SW_C0|SW_C2|SW_C3); /* Operand is not comparable */ setcc(SW_C0 | SW_C2 | SW_C3); /* Operand is not comparable */
EXCEPTION(EX_INTERNAL|0x14); EXCEPTION(EX_INTERNAL | 0x14);
break; break;
}
break;
case TAG_Empty:
setcc(SW_C0 | SW_C2 | SW_C3);
EXCEPTION(EX_StackUnder);
break;
} }
break;
case TAG_Empty:
setcc(SW_C0|SW_C2|SW_C3);
EXCEPTION(EX_StackUnder);
break;
}
} }
static void fxam(FPU_REG * st0_ptr, u_char st0tag)
static void fxam(FPU_REG *st0_ptr, u_char st0tag)
{ {
int c = 0; int c = 0;
switch (st0tag) switch (st0tag) {
{ case TAG_Empty:
case TAG_Empty: c = SW_C3 | SW_C0;
c = SW_C3|SW_C0; break;
break; case TAG_Zero:
case TAG_Zero: c = SW_C3;
c = SW_C3; break;
break; case TAG_Valid:
case TAG_Valid: c = SW_C2;
c = SW_C2; break;
break; case TAG_Special:
case TAG_Special: switch (FPU_Special(st0_ptr)) {
switch ( FPU_Special(st0_ptr) ) case TW_Denormal:
{ c = SW_C2 | SW_C3; /* Denormal */
case TW_Denormal: break;
c = SW_C2|SW_C3; /* Denormal */ case TW_NaN:
break; /* We also use NaN for unsupported types. */
case TW_NaN: if ((st0_ptr->sigh & 0x80000000)
/* We also use NaN for unsupported types. */ && (exponent(st0_ptr) == EXP_OVER))
if ( (st0_ptr->sigh & 0x80000000) && (exponent(st0_ptr) == EXP_OVER) ) c = SW_C0;
c = SW_C0; break;
break; case TW_Infinity:
case TW_Infinity: c = SW_C2 | SW_C0;
c = SW_C2|SW_C0; break;
break; }
} }
} if (getsign(st0_ptr) == SIGN_NEG)
if ( getsign(st0_ptr) == SIGN_NEG ) c |= SW_C1;
c |= SW_C1; setcc(c);
setcc(c);
} }
static FUNC_ST0 const fp_etc_table[] = { static FUNC_ST0 const fp_etc_table[] = {
fchs, fabs, (FUNC_ST0)FPU_illegal, (FUNC_ST0)FPU_illegal, fchs, fabs, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal,
ftst_, fxam, (FUNC_ST0)FPU_illegal, (FUNC_ST0)FPU_illegal ftst_, fxam, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal
}; };
void FPU_etc(void) void FPU_etc(void)
{ {
(fp_etc_table[FPU_rm])(&st(0), FPU_gettag0()); (fp_etc_table[FPU_rm]) (&st(0), FPU_gettag0());
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
extern void FPU_illegal(void); extern void FPU_illegal(void);
extern void FPU_printall(void); extern void FPU_printall(void);
asmlinkage void FPU_exception(int n); asmlinkage void FPU_exception(int n);
extern int real_1op_NaN(FPU_REG *a); extern int real_1op_NaN(FPU_REG * a);
extern int real_2op_NaN(FPU_REG const *b, u_char tagb, int deststnr, extern int real_2op_NaN(FPU_REG const *b, u_char tagb, int deststnr,
FPU_REG const *defaultNaN); FPU_REG const *defaultNaN);
asmlinkage int arith_invalid(int deststnr); asmlinkage int arith_invalid(int deststnr);
...@@ -14,8 +14,8 @@ extern int set_precision_flag(int flags); ...@@ -14,8 +14,8 @@ extern int set_precision_flag(int flags);
asmlinkage void set_precision_flag_up(void); asmlinkage void set_precision_flag_up(void);
asmlinkage void set_precision_flag_down(void); asmlinkage void set_precision_flag_down(void);
asmlinkage int denormal_operand(void); asmlinkage int denormal_operand(void);
asmlinkage int arith_overflow(FPU_REG *dest); asmlinkage int arith_overflow(FPU_REG * dest);
asmlinkage int arith_underflow(FPU_REG *dest); asmlinkage int arith_underflow(FPU_REG * dest);
extern void FPU_stack_overflow(void); extern void FPU_stack_overflow(void);
extern void FPU_stack_underflow(void); extern void FPU_stack_underflow(void);
extern void FPU_stack_underflow_i(int i); extern void FPU_stack_underflow_i(int i);
...@@ -66,7 +66,7 @@ extern int FPU_Special(FPU_REG const *ptr); ...@@ -66,7 +66,7 @@ extern int FPU_Special(FPU_REG const *ptr);
extern int isNaN(FPU_REG const *ptr); extern int isNaN(FPU_REG const *ptr);
extern void FPU_pop(void); extern void FPU_pop(void);
extern int FPU_empty_i(int stnr); extern int FPU_empty_i(int stnr);
extern int FPU_stackoverflow(FPU_REG **st_new_ptr); extern int FPU_stackoverflow(FPU_REG ** st_new_ptr);
extern void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr); extern void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr);
extern void FPU_copy_to_reg1(FPU_REG const *r, u_char tag); extern void FPU_copy_to_reg1(FPU_REG const *r, u_char tag);
extern void FPU_copy_to_reg0(FPU_REG const *r, u_char tag); extern void FPU_copy_to_reg0(FPU_REG const *r, u_char tag);
...@@ -75,26 +75,28 @@ extern void FPU_triga(void); ...@@ -75,26 +75,28 @@ extern void FPU_triga(void);
extern void FPU_trigb(void); extern void FPU_trigb(void);
/* get_address.c */ /* get_address.c */
extern void __user *FPU_get_address(u_char FPU_modrm, unsigned long *fpu_eip, extern void __user *FPU_get_address(u_char FPU_modrm, unsigned long *fpu_eip,
struct address *addr, fpu_addr_modes addr_modes); struct address *addr,
fpu_addr_modes addr_modes);
extern void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip, extern void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
struct address *addr, fpu_addr_modes addr_modes); struct address *addr,
fpu_addr_modes addr_modes);
/* load_store.c */ /* load_store.c */
extern int FPU_load_store(u_char type, fpu_addr_modes addr_modes, extern int FPU_load_store(u_char type, fpu_addr_modes addr_modes,
void __user *data_address); void __user * data_address);
/* poly_2xm1.c */ /* poly_2xm1.c */
extern int poly_2xm1(u_char sign, FPU_REG *arg, FPU_REG *result); extern int poly_2xm1(u_char sign, FPU_REG * arg, FPU_REG * result);
/* poly_atan.c */ /* poly_atan.c */
extern void poly_atan(FPU_REG *st0_ptr, u_char st0_tag, FPU_REG *st1_ptr, extern void poly_atan(FPU_REG * st0_ptr, u_char st0_tag, FPU_REG * st1_ptr,
u_char st1_tag); u_char st1_tag);
/* poly_l2.c */ /* poly_l2.c */
extern void poly_l2(FPU_REG *st0_ptr, FPU_REG *st1_ptr, u_char st1_sign); extern void poly_l2(FPU_REG * st0_ptr, FPU_REG * st1_ptr, u_char st1_sign);
extern int poly_l2p1(u_char s0, u_char s1, FPU_REG *r0, FPU_REG *r1, extern int poly_l2p1(u_char s0, u_char s1, FPU_REG * r0, FPU_REG * r1,
FPU_REG *d); FPU_REG * d);
/* poly_sin.c */ /* poly_sin.c */
extern void poly_sine(FPU_REG *st0_ptr); extern void poly_sine(FPU_REG * st0_ptr);
extern void poly_cos(FPU_REG *st0_ptr); extern void poly_cos(FPU_REG * st0_ptr);
/* poly_tan.c */ /* poly_tan.c */
extern void poly_tan(FPU_REG *st0_ptr); extern void poly_tan(FPU_REG * st0_ptr);
/* reg_add_sub.c */ /* reg_add_sub.c */
extern int FPU_add(FPU_REG const *b, u_char tagb, int destrnr, int control_w); extern int FPU_add(FPU_REG const *b, u_char tagb, int destrnr, int control_w);
extern int FPU_sub(int flags, int rm, int control_w); extern int FPU_sub(int flags, int rm, int control_w);
...@@ -109,32 +111,34 @@ extern void fucompp(void); ...@@ -109,32 +111,34 @@ extern void fucompp(void);
/* reg_constant.c */ /* reg_constant.c */
extern void fconst(void); extern void fconst(void);
/* reg_ld_str.c */ /* reg_ld_str.c */
extern int FPU_load_extended(long double __user *s, int stnr); extern int FPU_load_extended(long double __user * s, int stnr);
extern int FPU_load_double(double __user *dfloat, FPU_REG *loaded_data); extern int FPU_load_double(double __user * dfloat, FPU_REG * loaded_data);
extern int FPU_load_single(float __user *single, FPU_REG *loaded_data); extern int FPU_load_single(float __user * single, FPU_REG * loaded_data);
extern int FPU_load_int64(long long __user *_s); extern int FPU_load_int64(long long __user * _s);
extern int FPU_load_int32(long __user *_s, FPU_REG *loaded_data); extern int FPU_load_int32(long __user * _s, FPU_REG * loaded_data);
extern int FPU_load_int16(short __user *_s, FPU_REG *loaded_data); extern int FPU_load_int16(short __user * _s, FPU_REG * loaded_data);
extern int FPU_load_bcd(u_char __user *s); extern int FPU_load_bcd(u_char __user * s);
extern int FPU_store_extended(FPU_REG *st0_ptr, u_char st0_tag, extern int FPU_store_extended(FPU_REG * st0_ptr, u_char st0_tag,
long double __user *d); long double __user * d);
extern int FPU_store_double(FPU_REG *st0_ptr, u_char st0_tag, double __user *dfloat); extern int FPU_store_double(FPU_REG * st0_ptr, u_char st0_tag,
extern int FPU_store_single(FPU_REG *st0_ptr, u_char st0_tag, float __user *single); double __user * dfloat);
extern int FPU_store_int64(FPU_REG *st0_ptr, u_char st0_tag, long long __user *d); extern int FPU_store_single(FPU_REG * st0_ptr, u_char st0_tag,
extern int FPU_store_int32(FPU_REG *st0_ptr, u_char st0_tag, long __user *d); float __user * single);
extern int FPU_store_int16(FPU_REG *st0_ptr, u_char st0_tag, short __user *d); extern int FPU_store_int64(FPU_REG * st0_ptr, u_char st0_tag,
extern int FPU_store_bcd(FPU_REG *st0_ptr, u_char st0_tag, u_char __user *d); long long __user * d);
extern int FPU_round_to_int(FPU_REG *r, u_char tag); extern int FPU_store_int32(FPU_REG * st0_ptr, u_char st0_tag, long __user * d);
extern u_char __user *fldenv(fpu_addr_modes addr_modes, u_char __user *s); extern int FPU_store_int16(FPU_REG * st0_ptr, u_char st0_tag, short __user * d);
extern void frstor(fpu_addr_modes addr_modes, u_char __user *data_address); extern int FPU_store_bcd(FPU_REG * st0_ptr, u_char st0_tag, u_char __user * d);
extern u_char __user *fstenv(fpu_addr_modes addr_modes, u_char __user *d); extern int FPU_round_to_int(FPU_REG * r, u_char tag);
extern void fsave(fpu_addr_modes addr_modes, u_char __user *data_address); extern u_char __user *fldenv(fpu_addr_modes addr_modes, u_char __user * s);
extern int FPU_tagof(FPU_REG *ptr); extern void frstor(fpu_addr_modes addr_modes, u_char __user * data_address);
extern u_char __user *fstenv(fpu_addr_modes addr_modes, u_char __user * d);
extern void fsave(fpu_addr_modes addr_modes, u_char __user * data_address);
extern int FPU_tagof(FPU_REG * ptr);
/* reg_mul.c */ /* reg_mul.c */
extern int FPU_mul(FPU_REG const *b, u_char tagb, int deststnr, int control_w); extern int FPU_mul(FPU_REG const *b, u_char tagb, int deststnr, int control_w);
extern int FPU_div(int flags, int regrm, int control_w); extern int FPU_div(int flags, int regrm, int control_w);
/* reg_convert.c */ /* reg_convert.c */
extern int FPU_to_exp16(FPU_REG const *a, FPU_REG *x); extern int FPU_to_exp16(FPU_REG const *a, FPU_REG * x);
#endif /* _FPU_PROTO_H */ #endif /* _FPU_PROTO_H */
...@@ -14,114 +14,102 @@ ...@@ -14,114 +14,102 @@
#include "fpu_system.h" #include "fpu_system.h"
#include "exception.h" #include "exception.h"
void FPU_pop(void) void FPU_pop(void)
{ {
fpu_tag_word |= 3 << ((top & 7)*2); fpu_tag_word |= 3 << ((top & 7) * 2);
top++; top++;
} }
int FPU_gettag0(void) int FPU_gettag0(void)
{ {
return (fpu_tag_word >> ((top & 7)*2)) & 3; return (fpu_tag_word >> ((top & 7) * 2)) & 3;
} }
int FPU_gettagi(int stnr) int FPU_gettagi(int stnr)
{ {
return (fpu_tag_word >> (((top+stnr) & 7)*2)) & 3; return (fpu_tag_word >> (((top + stnr) & 7) * 2)) & 3;
} }
int FPU_gettag(int regnr) int FPU_gettag(int regnr)
{ {
return (fpu_tag_word >> ((regnr & 7)*2)) & 3; return (fpu_tag_word >> ((regnr & 7) * 2)) & 3;
} }
void FPU_settag0(int tag) void FPU_settag0(int tag)
{ {
int regnr = top; int regnr = top;
regnr &= 7; regnr &= 7;
fpu_tag_word &= ~(3 << (regnr*2)); fpu_tag_word &= ~(3 << (regnr * 2));
fpu_tag_word |= (tag & 3) << (regnr*2); fpu_tag_word |= (tag & 3) << (regnr * 2);
} }
void FPU_settagi(int stnr, int tag) void FPU_settagi(int stnr, int tag)
{ {
int regnr = stnr+top; int regnr = stnr + top;
regnr &= 7; regnr &= 7;
fpu_tag_word &= ~(3 << (regnr*2)); fpu_tag_word &= ~(3 << (regnr * 2));
fpu_tag_word |= (tag & 3) << (regnr*2); fpu_tag_word |= (tag & 3) << (regnr * 2);
} }
void FPU_settag(int regnr, int tag) void FPU_settag(int regnr, int tag)
{ {
regnr &= 7; regnr &= 7;
fpu_tag_word &= ~(3 << (regnr*2)); fpu_tag_word &= ~(3 << (regnr * 2));
fpu_tag_word |= (tag & 3) << (regnr*2); fpu_tag_word |= (tag & 3) << (regnr * 2);
} }
int FPU_Special(FPU_REG const *ptr) int FPU_Special(FPU_REG const *ptr)
{ {
int exp = exponent(ptr); int exp = exponent(ptr);
if ( exp == EXP_BIAS+EXP_UNDER ) if (exp == EXP_BIAS + EXP_UNDER)
return TW_Denormal; return TW_Denormal;
else if ( exp != EXP_BIAS+EXP_OVER ) else if (exp != EXP_BIAS + EXP_OVER)
return TW_NaN; return TW_NaN;
else if ( (ptr->sigh == 0x80000000) && (ptr->sigl == 0) ) else if ((ptr->sigh == 0x80000000) && (ptr->sigl == 0))
return TW_Infinity; return TW_Infinity;
return TW_NaN; return TW_NaN;
} }
int isNaN(FPU_REG const *ptr) int isNaN(FPU_REG const *ptr)
{ {
return ( (exponent(ptr) == EXP_BIAS+EXP_OVER) return ((exponent(ptr) == EXP_BIAS + EXP_OVER)
&& !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)) ); && !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)));
} }
int FPU_empty_i(int stnr) int FPU_empty_i(int stnr)
{ {
int regnr = (top+stnr) & 7; int regnr = (top + stnr) & 7;
return ((fpu_tag_word >> (regnr*2)) & 3) == TAG_Empty; return ((fpu_tag_word >> (regnr * 2)) & 3) == TAG_Empty;
} }
int FPU_stackoverflow(FPU_REG ** st_new_ptr)
int FPU_stackoverflow(FPU_REG **st_new_ptr)
{ {
*st_new_ptr = &st(-1); *st_new_ptr = &st(-1);
return ((fpu_tag_word >> (((top - 1) & 7)*2)) & 3) != TAG_Empty; return ((fpu_tag_word >> (((top - 1) & 7) * 2)) & 3) != TAG_Empty;
} }
void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr) void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr)
{ {
reg_copy(r, &st(stnr)); reg_copy(r, &st(stnr));
FPU_settagi(stnr, tag); FPU_settagi(stnr, tag);
} }
void FPU_copy_to_reg1(FPU_REG const *r, u_char tag) void FPU_copy_to_reg1(FPU_REG const *r, u_char tag)
{ {
reg_copy(r, &st(1)); reg_copy(r, &st(1));
FPU_settagi(1, tag); FPU_settagi(1, tag);
} }
void FPU_copy_to_reg0(FPU_REG const *r, u_char tag) void FPU_copy_to_reg0(FPU_REG const *r, u_char tag)
{ {
int regnr = top; int regnr = top;
regnr &= 7; regnr &= 7;
reg_copy(r, &st(0)); reg_copy(r, &st(0));
fpu_tag_word &= ~(3 << (regnr*2)); fpu_tag_word &= ~(3 << (regnr * 2));
fpu_tag_word |= (tag & 3) << (regnr*2); fpu_tag_word |= (tag & 3) << (regnr * 2);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
allows. 9-byte would probably be sufficient. allows. 9-byte would probably be sufficient.
*/ */
typedef struct { typedef struct {
unsigned long lsw; unsigned long lsw;
unsigned long midw; unsigned long midw;
unsigned long msw; unsigned long msw;
} Xsig; } Xsig;
asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b, asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b,
...@@ -33,12 +33,12 @@ asmlinkage void polynomial_Xsig(Xsig *, const unsigned long long *x, ...@@ -33,12 +33,12 @@ asmlinkage void polynomial_Xsig(Xsig *, const unsigned long long *x,
asmlinkage void mul32_Xsig(Xsig *, const unsigned long mult); asmlinkage void mul32_Xsig(Xsig *, const unsigned long mult);
asmlinkage void mul64_Xsig(Xsig *, const unsigned long long *mult); asmlinkage void mul64_Xsig(Xsig *, const unsigned long long *mult);
asmlinkage void mul_Xsig_Xsig(Xsig *dest, const Xsig *mult); asmlinkage void mul_Xsig_Xsig(Xsig * dest, const Xsig * mult);
asmlinkage void shr_Xsig(Xsig *, const int n); asmlinkage void shr_Xsig(Xsig *, const int n);
asmlinkage int round_Xsig(Xsig *); asmlinkage int round_Xsig(Xsig *);
asmlinkage int norm_Xsig(Xsig *); asmlinkage int norm_Xsig(Xsig *);
asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest); asmlinkage void div_Xsig(Xsig * x1, const Xsig * x2, const Xsig * dest);
/* Macro to extract the most significant 32 bits from a long long */ /* Macro to extract the most significant 32 bits from a long long */
#define LL_MSW(x) (((unsigned long *)&x)[1]) #define LL_MSW(x) (((unsigned long *)&x)[1])
...@@ -49,7 +49,6 @@ asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest); ...@@ -49,7 +49,6 @@ asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest);
/* Macro to access the 8 ms bytes of an Xsig as a long long */ /* Macro to access the 8 ms bytes of an Xsig as a long long */
#define XSIG_LL(x) (*(unsigned long long *)&x.midw) #define XSIG_LL(x) (*(unsigned long long *)&x.midw)
/* /*
Need to run gcc with optimizations on to get these to Need to run gcc with optimizations on to get these to
actually be in-line. actually be in-line.
...@@ -63,59 +62,53 @@ asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest); ...@@ -63,59 +62,53 @@ asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest);
static inline unsigned long mul_32_32(const unsigned long arg1, static inline unsigned long mul_32_32(const unsigned long arg1,
const unsigned long arg2) const unsigned long arg2)
{ {
int retval; int retval;
asm volatile ("mull %2; movl %%edx,%%eax" \ asm volatile ("mull %2; movl %%edx,%%eax":"=a" (retval)
:"=a" (retval) \ :"0"(arg1), "g"(arg2)
:"0" (arg1), "g" (arg2) \ :"dx");
:"dx"); return retval;
return retval;
} }
/* Add the 12 byte Xsig x2 to Xsig dest, with no checks for overflow. */ /* Add the 12 byte Xsig x2 to Xsig dest, with no checks for overflow. */
static inline void add_Xsig_Xsig(Xsig *dest, const Xsig *x2) static inline void add_Xsig_Xsig(Xsig * dest, const Xsig * x2)
{ {
asm volatile ("movl %1,%%edi; movl %2,%%esi;\n" asm volatile ("movl %1,%%edi; movl %2,%%esi;\n"
"movl (%%esi),%%eax; addl %%eax,(%%edi);\n" "movl (%%esi),%%eax; addl %%eax,(%%edi);\n"
"movl 4(%%esi),%%eax; adcl %%eax,4(%%edi);\n" "movl 4(%%esi),%%eax; adcl %%eax,4(%%edi);\n"
"movl 8(%%esi),%%eax; adcl %%eax,8(%%edi);\n" "movl 8(%%esi),%%eax; adcl %%eax,8(%%edi);\n":"=g"
:"=g" (*dest):"g" (dest), "g" (x2) (*dest):"g"(dest), "g"(x2)
:"ax","si","di"); :"ax", "si", "di");
} }
/* Add the 12 byte Xsig x2 to Xsig dest, adjust exp if overflow occurs. */ /* Add the 12 byte Xsig x2 to Xsig dest, adjust exp if overflow occurs. */
/* Note: the constraints in the asm statement didn't always work properly /* Note: the constraints in the asm statement didn't always work properly
with gcc 2.5.8. Changing from using edi to using ecx got around the with gcc 2.5.8. Changing from using edi to using ecx got around the
problem, but keep fingers crossed! */ problem, but keep fingers crossed! */
static inline void add_two_Xsig(Xsig *dest, const Xsig *x2, long int *exp) static inline void add_two_Xsig(Xsig * dest, const Xsig * x2, long int *exp)
{ {
asm volatile ("movl %2,%%ecx; movl %3,%%esi;\n" asm volatile ("movl %2,%%ecx; movl %3,%%esi;\n"
"movl (%%esi),%%eax; addl %%eax,(%%ecx);\n" "movl (%%esi),%%eax; addl %%eax,(%%ecx);\n"
"movl 4(%%esi),%%eax; adcl %%eax,4(%%ecx);\n" "movl 4(%%esi),%%eax; adcl %%eax,4(%%ecx);\n"
"movl 8(%%esi),%%eax; adcl %%eax,8(%%ecx);\n" "movl 8(%%esi),%%eax; adcl %%eax,8(%%ecx);\n"
"jnc 0f;\n" "jnc 0f;\n"
"rcrl 8(%%ecx); rcrl 4(%%ecx); rcrl (%%ecx)\n" "rcrl 8(%%ecx); rcrl 4(%%ecx); rcrl (%%ecx)\n"
"movl %4,%%ecx; incl (%%ecx)\n" "movl %4,%%ecx; incl (%%ecx)\n"
"movl $1,%%eax; jmp 1f;\n" "movl $1,%%eax; jmp 1f;\n"
"0: xorl %%eax,%%eax;\n" "0: xorl %%eax,%%eax;\n" "1:\n":"=g" (*exp), "=g"(*dest)
"1:\n" :"g"(dest), "g"(x2), "g"(exp)
:"=g" (*exp), "=g" (*dest) :"cx", "si", "ax");
:"g" (dest), "g" (x2), "g" (exp)
:"cx","si","ax");
} }
/* Negate (subtract from 1.0) the 12 byte Xsig */ /* Negate (subtract from 1.0) the 12 byte Xsig */
/* This is faster in a loop on my 386 than using the "neg" instruction. */ /* This is faster in a loop on my 386 than using the "neg" instruction. */
static inline void negate_Xsig(Xsig *x) static inline void negate_Xsig(Xsig * x)
{ {
asm volatile("movl %1,%%esi;\n" asm volatile ("movl %1,%%esi;\n"
"xorl %%ecx,%%ecx;\n" "xorl %%ecx,%%ecx;\n"
"movl %%ecx,%%eax; subl (%%esi),%%eax; movl %%eax,(%%esi);\n" "movl %%ecx,%%eax; subl (%%esi),%%eax; movl %%eax,(%%esi);\n"
"movl %%ecx,%%eax; sbbl 4(%%esi),%%eax; movl %%eax,4(%%esi);\n" "movl %%ecx,%%eax; sbbl 4(%%esi),%%eax; movl %%eax,4(%%esi);\n"
"movl %%ecx,%%eax; sbbl 8(%%esi),%%eax; movl %%eax,8(%%esi);\n" "movl %%ecx,%%eax; sbbl 8(%%esi),%%eax; movl %%eax,8(%%esi);\n":"=g"
:"=g" (*x):"g" (x):"si","ax","cx"); (*x):"g"(x):"si", "ax", "cx");
} }
#endif /* _POLY_H */ #endif /* _POLY_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -13,41 +13,34 @@ ...@@ -13,41 +13,34 @@
#include "exception.h" #include "exception.h"
#include "fpu_emu.h" #include "fpu_emu.h"
int FPU_to_exp16(FPU_REG const *a, FPU_REG * x)
int FPU_to_exp16(FPU_REG const *a, FPU_REG *x)
{ {
int sign = getsign(a); int sign = getsign(a);
*(long long *)&(x->sigl) = *(const long long *)&(a->sigl); *(long long *)&(x->sigl) = *(const long long *)&(a->sigl);
/* Set up the exponent as a 16 bit quantity. */ /* Set up the exponent as a 16 bit quantity. */
setexponent16(x, exponent(a)); setexponent16(x, exponent(a));
if ( exponent16(x) == EXP_UNDER ) if (exponent16(x) == EXP_UNDER) {
{ /* The number is a de-normal or pseudodenormal. */
/* The number is a de-normal or pseudodenormal. */ /* We only deal with the significand and exponent. */
/* We only deal with the significand and exponent. */
if (x->sigh & 0x80000000) {
if (x->sigh & 0x80000000) /* Is a pseudodenormal. */
{ /* This is non-80486 behaviour because the number
/* Is a pseudodenormal. */ loses its 'denormal' identity. */
/* This is non-80486 behaviour because the number addexponent(x, 1);
loses its 'denormal' identity. */ } else {
addexponent(x, 1); /* Is a denormal. */
} addexponent(x, 1);
else FPU_normalize_nuo(x);
{ }
/* Is a denormal. */
addexponent(x, 1);
FPU_normalize_nuo(x);
} }
}
if ( !(x->sigh & 0x80000000) ) if (!(x->sigh & 0x80000000)) {
{ EXCEPTION(EX_INTERNAL | 0x180);
EXCEPTION(EX_INTERNAL | 0x180); }
}
return sign; return sign;
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#ifndef _STATUS_H_ #ifndef _STATUS_H_
#define _STATUS_H_ #define _STATUS_H_
#include "fpu_emu.h" /* for definition of PECULIAR_486 */ #include "fpu_emu.h" /* for definition of PECULIAR_486 */
#ifdef __ASSEMBLY__ #ifdef __ASSEMBLY__
#define Const__(x) $##x #define Const__(x) $##x
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#define SW_Denorm_Op Const__(0x0002) /* denormalized operand */ #define SW_Denorm_Op Const__(0x0002) /* denormalized operand */
#define SW_Invalid Const__(0x0001) /* invalid operation */ #define SW_Invalid Const__(0x0001) /* invalid operation */
#define SW_Exc_Mask Const__(0x27f) /* Status word exception bit mask */ #define SW_Exc_Mask Const__(0x27f) /* Status word exception bit mask */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
((partial_status & ~SW_Top & 0xffff) | ((top << SW_Top_Shift) & SW_Top)) ((partial_status & ~SW_Top & 0xffff) | ((top << SW_Top_Shift) & SW_Top))
static inline void setcc(int cc) static inline void setcc(int cc)
{ {
partial_status &= ~(SW_C0|SW_C1|SW_C2|SW_C3); partial_status &= ~(SW_C0 | SW_C1 | SW_C2 | SW_C3);
partial_status |= (cc) & (SW_C0|SW_C1|SW_C2|SW_C3); partial_status |= (cc) & (SW_C0 | SW_C1 | SW_C2 | SW_C3);
} }
#ifdef PECULIAR_486 #ifdef PECULIAR_486
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment