* i387-fp.c (struct i387_fsave, struct i387_fxsave): Make 16-bit

fields short instead of int.  Add explicit padding.
	(i387_cache_to_fsave): Remove unnecessary casts.
	(i387_fsave_to_cache): Doc fix.
	(i387_cache_to_fxsave): Remove unnecessary casts and masking.
This commit is contained in:
Daniel Jacobowitz 2007-03-30 17:13:02 +00:00
parent f6bee0627d
commit 0c2ead7e16
2 changed files with 32 additions and 21 deletions

View File

@ -1,3 +1,11 @@
2007-03-30 Daniel Jacobowitz <dan@codesourcery.com>
* i387-fp.c (struct i387_fsave, struct i387_fxsave): Make 16-bit
fields short instead of int. Add explicit padding.
(i387_cache_to_fsave): Remove unnecessary casts.
(i387_fsave_to_cache): Doc fix.
(i387_cache_to_fxsave): Remove unnecessary casts and masking.
2007-03-30 Daniel Jacobowitz <dan@codesourcery.com>
* i387-fp.c (i387_cache_to_fxsave): Reinitialize val2 before use.

View File

@ -32,14 +32,18 @@ int num_xmm_registers = 8;
struct i387_fsave {
/* All these are only sixteen bits, plus padding, except for fop (which
is only eleven bits), and fooff / fioff (which are 32 bits each). */
unsigned int fctrl;
unsigned int fstat;
unsigned int ftag;
unsigned short fctrl;
unsigned short pad1;
unsigned short fstat;
unsigned short pad2;
unsigned short ftag;
unsigned short pad3;
unsigned int fioff;
unsigned short fiseg;
unsigned short fop;
unsigned int fooff;
unsigned int foseg;
unsigned short foseg;
unsigned short pad4;
/* Space for eight 80-bit FP values. */
unsigned char st_space[80];
@ -53,13 +57,14 @@ struct i387_fxsave {
unsigned short ftag;
unsigned short fop;
unsigned int fioff;
unsigned int fiseg;
unsigned short fiseg;
unsigned short pad1;
unsigned int fooff;
unsigned int foseg;
unsigned short foseg;
unsigned short pad12;
unsigned int mxcsr;
unsigned int _pad1;
unsigned int pad3;
/* Space for eight 80-bit FP values in 128-bit spaces. */
unsigned char st_space[128];
@ -88,23 +93,23 @@ i387_cache_to_fsave (void *buf)
/* Some registers are 16-bit. */
collect_register_by_name ("fctrl", &val);
*(unsigned short *) &fp->fctrl = val;
fp->fctrl = val;
collect_register_by_name ("fstat", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->fstat = val;
fp->fstat = val;
collect_register_by_name ("ftag", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->ftag = val;
fp->ftag = val;
collect_register_by_name ("fiseg", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->fiseg = val;
fp->fiseg = val;
collect_register_by_name ("foseg", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->foseg = val;
fp->foseg = val;
}
void
@ -137,6 +142,7 @@ i387_fsave_to_cache (const void *buf)
val = fp->foseg & 0xFFFF;
supply_register_by_name ("foseg", &val);
/* fop has only 11 valid bits. */
val = (fp->fop) & 0x7FF;
supply_register_by_name ("fop", &val);
}
@ -165,11 +171,10 @@ i387_cache_to_fxsave (void *buf)
/* Some registers are 16-bit. */
collect_register_by_name ("fctrl", &val);
*(unsigned short *) &fp->fctrl = val;
fp->fctrl = val;
collect_register_by_name ("fstat", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->fstat = val;
fp->fstat = val;
/* Convert to the simplifed tag form stored in fxsave data. */
collect_register_by_name ("ftag", &val);
@ -182,15 +187,13 @@ i387_cache_to_fxsave (void *buf)
if (tag != 3)
val2 |= (1 << i);
}
*(unsigned short *) &fp->ftag = val2;
fp->ftag = val2;
collect_register_by_name ("fiseg", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->fiseg = val;
fp->fiseg = val;
collect_register_by_name ("foseg", &val);
val &= 0xFFFF;
*(unsigned short *) &fp->foseg = val;
fp->foseg = val;
}
static int