Discussion:
vex: r3372 - in /trunk/priv: guest_amd64_helpers.c guest_x86_helpers.c
Add Reply
s***@valgrind.org
2017-05-16 07:59:31 UTC
Reply
Permalink
Raw Message
Author: iraisr
Date: Tue May 16 08:59:31 2017
New Revision: 3372

Log:
Reduce the number of compiler warnings on MIPS platforms
Partial fix for BZ#370028
Slightly modified patch by: Tamara Vlahovic <***@imgtec.com>

Modified:
trunk/priv/guest_amd64_helpers.c
trunk/priv/guest_x86_helpers.c

Modified: trunk/priv/guest_amd64_helpers.c
==============================================================================
--- trunk/priv/guest_amd64_helpers.c (original)
+++ trunk/priv/guest_amd64_helpers.c Tue May 16 08:59:31 2017
@@ -1939,18 +1939,17 @@
themselves are not transferred into the guest state. */
static
VexEmNote do_put_x87 ( Bool moveRegs,
- /*IN*/UChar* x87_state,
+ /*IN*/Fpu_State* x87_state,
/*OUT*/VexGuestAMD64State* vex_state )
{
Int stno, preg;
UInt tag;
ULong* vexRegs = (ULong*)(&vex_state->guest_FPREG[0]);
UChar* vexTags = (UChar*)(&vex_state->guest_FPTAG[0]);
- Fpu_State* x87 = (Fpu_State*)x87_state;
- UInt ftop = (x87->env[FP_ENV_STAT] >> 11) & 7;
- UInt tagw = x87->env[FP_ENV_TAG];
- UInt fpucw = x87->env[FP_ENV_CTRL];
- UInt c3210 = x87->env[FP_ENV_STAT] & 0x4700;
+ UInt ftop = (x87_state->env[FP_ENV_STAT] >> 11) & 7;
+ UInt tagw = x87_state->env[FP_ENV_TAG];
+ UInt fpucw = x87_state->env[FP_ENV_CTRL];
+ UInt c3210 = x87_state->env[FP_ENV_STAT] & 0x4700;
VexEmNote ew;
UInt fpround;
ULong pair;
@@ -1971,7 +1970,7 @@
} else {
/* register is non-empty */
if (moveRegs)
- convert_f80le_to_f64le( &x87->reg[10*stno],
+ convert_f80le_to_f64le( &x87_state->reg[10*stno],
(UChar*)&vexRegs[preg] );
vexTags[preg] = 1;
}
@@ -2000,23 +1999,23 @@
we can approximate it. */
static
void do_get_x87 ( /*IN*/VexGuestAMD64State* vex_state,
- /*OUT*/UChar* x87_state )
+ /*OUT*/Fpu_State* x87_state )
{
Int i, stno, preg;
UInt tagw;
ULong* vexRegs = (ULong*)(&vex_state->guest_FPREG[0]);
UChar* vexTags = (UChar*)(&vex_state->guest_FPTAG[0]);
- Fpu_State* x87 = (Fpu_State*)x87_state;
UInt ftop = vex_state->guest_FTOP;
UInt c3210 = vex_state->guest_FC3210;

for (i = 0; i < 14; i++)
- x87->env[i] = 0;
+ x87_state->env[i] = 0;

- x87->env[1] = x87->env[3] = x87->env[5] = x87->env[13] = 0xFFFF;
- x87->env[FP_ENV_STAT]
+ x87_state->env[1] = x87_state->env[3] = x87_state->env[5]
+ = x87_state->env[13] = 0xFFFF;
+ x87_state->env[FP_ENV_STAT]
= toUShort(((ftop & 7) << 11) | (c3210 & 0x4700));
- x87->env[FP_ENV_CTRL]
+ x87_state->env[FP_ENV_CTRL]
= toUShort(amd64g_create_fpucw( vex_state->guest_FPROUND ));

/* Dump the register stack in ST order. */
@@ -2027,15 +2026,15 @@
/* register is empty */
tagw |= (3 << (2*preg));
convert_f64le_to_f80le( (UChar*)&vexRegs[preg],
- &x87->reg[10*stno] );
+ &x87_state->reg[10*stno] );
} else {
/* register is full. */
tagw |= (0 << (2*preg));
convert_f64le_to_f80le( (UChar*)&vexRegs[preg],
- &x87->reg[10*stno] );
+ &x87_state->reg[10*stno] );
}
}
- x87->env[FP_ENV_TAG] = toUShort(tagw);
+ x87_state->env[FP_ENV_TAG] = toUShort(tagw);
}


@@ -2067,7 +2066,7 @@
Int r, stno;
UShort *srcS, *dstS;

- do_get_x87( gst, (UChar*)&tmp );
+ do_get_x87( gst, &tmp );

/* Now build the proper fxsave x87 image from the fsave x87 image
we just made. */
@@ -2236,7 +2235,7 @@
tmp.env[FP_ENV_TAG] = fp_tags;

/* Now write 'tmp' into the guest state. */
- VexEmNote warnX87 = do_put_x87( True/*moveRegs*/, (UChar*)&tmp, gst );
+ VexEmNote warnX87 = do_put_x87( True/*moveRegs*/, &tmp, gst );

return warnX87;
}
@@ -2440,7 +2439,7 @@
VexEmNote amd64g_dirtyhelper_FLDENV ( /*OUT*/VexGuestAMD64State* vex_state,
/*IN*/HWord x87_state)
{
- return do_put_x87( False, (UChar*)x87_state, vex_state );
+ return do_put_x87( False, (Fpu_State*)x87_state, vex_state );
}


@@ -2492,7 +2491,7 @@
void amd64g_dirtyhelper_FNSAVE ( /*IN*/VexGuestAMD64State* vex_state,
/*OUT*/HWord x87_state)
{
- do_get_x87( vex_state, (UChar*)x87_state );
+ do_get_x87( vex_state, (Fpu_State*)x87_state );
}


@@ -2546,7 +2545,7 @@
VexEmNote amd64g_dirtyhelper_FRSTOR ( /*OUT*/VexGuestAMD64State* vex_state,
/*IN*/HWord x87_state)
{
- return do_put_x87( True, (UChar*)x87_state, vex_state );
+ return do_put_x87( True, (Fpu_State*)x87_state, vex_state );
}



Modified: trunk/priv/guest_x86_helpers.c
==============================================================================
--- trunk/priv/guest_x86_helpers.c (original)
+++ trunk/priv/guest_x86_helpers.c Tue May 16 08:59:31 2017
@@ -1599,18 +1599,17 @@
themselves are not transferred into the guest state. */
static
VexEmNote do_put_x87 ( Bool moveRegs,
- /*IN*/UChar* x87_state,
+ /*IN*/Fpu_State* x87_state,
/*OUT*/VexGuestX86State* vex_state )
{
Int stno, preg;
UInt tag;
ULong* vexRegs = (ULong*)(&vex_state->guest_FPREG[0]);
UChar* vexTags = (UChar*)(&vex_state->guest_FPTAG[0]);
- Fpu_State* x87 = (Fpu_State*)x87_state;
- UInt ftop = (x87->env[FP_ENV_STAT] >> 11) & 7;
- UInt tagw = x87->env[FP_ENV_TAG];
- UInt fpucw = x87->env[FP_ENV_CTRL];
- UInt c3210 = x87->env[FP_ENV_STAT] & 0x4700;
+ UInt ftop = (x87_state->env[FP_ENV_STAT] >> 11) & 7;
+ UInt tagw = x87_state->env[FP_ENV_TAG];
+ UInt fpucw = x87_state->env[FP_ENV_CTRL];
+ UInt c3210 = x87_state->env[FP_ENV_STAT] & 0x4700;
VexEmNote ew;
UInt fpround;
ULong pair;
@@ -1631,7 +1630,7 @@
} else {
/* register is non-empty */
if (moveRegs)
- convert_f80le_to_f64le( &x87->reg[10*stno],
+ convert_f80le_to_f64le( &x87_state->reg[10*stno],
(UChar*)&vexRegs[preg] );
vexTags[preg] = 1;
}
@@ -1660,23 +1659,23 @@
we can approximate it. */
static
void do_get_x87 ( /*IN*/VexGuestX86State* vex_state,
- /*OUT*/UChar* x87_state )
+ /*OUT*/Fpu_State* x87_state )
{
Int i, stno, preg;
UInt tagw;
ULong* vexRegs = (ULong*)(&vex_state->guest_FPREG[0]);
UChar* vexTags = (UChar*)(&vex_state->guest_FPTAG[0]);
- Fpu_State* x87 = (Fpu_State*)x87_state;
UInt ftop = vex_state->guest_FTOP;
UInt c3210 = vex_state->guest_FC3210;

for (i = 0; i < 14; i++)
- x87->env[i] = 0;
+ x87_state->env[i] = 0;

- x87->env[1] = x87->env[3] = x87->env[5] = x87->env[13] = 0xFFFF;
- x87->env[FP_ENV_STAT]
+ x87_state->env[1] = x87_state->env[3] = x87_state->env[5]
+ = x87_state->env[13] = 0xFFFF;
+ x87_state->env[FP_ENV_STAT]
= toUShort(((ftop & 7) << 11) | (c3210 & 0x4700));
- x87->env[FP_ENV_CTRL]
+ x87_state->env[FP_ENV_CTRL]
= toUShort(x86g_create_fpucw( vex_state->guest_FPROUND ));

/* Dump the register stack in ST order. */
@@ -1687,15 +1686,15 @@
/* register is empty */
tagw |= (3 << (2*preg));
convert_f64le_to_f80le( (UChar*)&vexRegs[preg],
- &x87->reg[10*stno] );
+ &x87_state->reg[10*stno] );
} else {
/* register is full. */
tagw |= (0 << (2*preg));
convert_f64le_to_f80le( (UChar*)&vexRegs[preg],
- &x87->reg[10*stno] );
+ &x87_state->reg[10*stno] );
}
}
- x87->env[FP_ENV_TAG] = toUShort(tagw);
+ x87_state->env[FP_ENV_TAG] = toUShort(tagw);
}


@@ -1714,7 +1713,7 @@
Int r, stno;
UShort *srcS, *dstS;

- do_get_x87( gst, (UChar*)&tmp );
+ do_get_x87( gst, &tmp );
mxcsr = x86g_create_mxcsr( gst->guest_SSEROUND );

/* Now build the proper fxsave image from the x87 image we just
@@ -1865,7 +1864,7 @@
tmp.env[FP_ENV_TAG] = fp_tags;

/* Now write 'tmp' into the guest state. */
- warnX87 = do_put_x87( True/*moveRegs*/, (UChar*)&tmp, gst );
+ warnX87 = do_put_x87( True/*moveRegs*/, &tmp, gst );

{ UInt w32 = (((UInt)addrS[12]) & 0xFFFF)
| ((((UInt)addrS[13]) & 0xFFFF) << 16);
@@ -1888,14 +1887,14 @@
/* DIRTY HELPER (reads guest state, writes guest mem) */
void x86g_dirtyhelper_FSAVE ( VexGuestX86State* gst, HWord addr )
{
- do_get_x87( gst, (UChar*)addr );
+ do_get_x87( gst, (Fpu_State*)addr );
}

/* CALLED FROM GENERATED CODE */
/* DIRTY HELPER (writes guest state, reads guest mem) */
VexEmNote x86g_dirtyhelper_FRSTOR ( VexGuestX86State* gst, HWord addr )
{
- return do_put_x87( True/*regs too*/, (UChar*)addr, gst );
+ return do_put_x87( True/*regs too*/, (Fpu_State*)addr, gst );
}

/* CALLED FROM GENERATED CODE */
@@ -1906,7 +1905,7 @@
Int i;
UShort* addrP = (UShort*)addr;
Fpu_State tmp;
- do_get_x87( gst, (UChar*)&tmp );
+ do_get_x87( gst, &tmp );
for (i = 0; i < 14; i++)
addrP[i] = tmp.env[i];
}
@@ -1915,7 +1914,7 @@
/* DIRTY HELPER (writes guest state, reads guest mem) */
VexEmNote x86g_dirtyhelper_FLDENV ( VexGuestX86State* gst, HWord addr )
{
- return do_put_x87( False/*don't move regs*/, (UChar*)addr, gst);
+ return do_put_x87( False/*don't move regs*/, (Fpu_State*)addr, gst);
}

/* VISIBLE TO LIBVEX CLIENT */
@@ -1925,7 +1924,7 @@
void LibVEX_GuestX86_get_x87 ( /*IN*/VexGuestX86State* vex_state,
/*OUT*/UChar* x87_state )
{
- do_get_x87 ( vex_state, x87_state );
+ do_get_x87 ( vex_state, (Fpu_State*)x87_state );
}

/* VISIBLE TO LIBVEX CLIENT */
@@ -1934,7 +1933,7 @@
VexEmNote LibVEX_GuestX86_put_x87 ( /*IN*/UChar* x87_state,
/*MOD*/VexGuestX86State* vex_state )
{
- return do_put_x87 ( True/*moveRegs*/, x87_state, vex_state );
+ return do_put_x87 ( True/*moveRegs*/, (Fpu_State*)x87_state, vex_state );
}

/* VISIBLE TO LIBVEX CLIENT */

Loading...