{
X86Instr* i = LibVEX_Alloc(sizeof(X86Instr));
i->tag = Xin_SseLdzLO;
- i->Xin.SseLdzLO.sz = sz;
+ i->Xin.SseLdzLO.sz = toUChar(sz);
i->Xin.SseLdzLO.reg = reg;
i->Xin.SseLdzLO.addr = addr;
vassert(sz == 4 || sz == 8);
if (i->Xin.Sh32.src == 0)
vex_printf("%%cl,");
else
- vex_printf("$%d,", i->Xin.Sh32.src);
+ vex_printf("$%d,", (Int)i->Xin.Sh32.src);
ppHRegX86(i->Xin.Sh32.dst);
return;
case Xin_Test32:
- vex_printf("testl $%d,", i->Xin.Test32.imm32);
+ vex_printf("testl $%d,", (Int)i->Xin.Test32.imm32);
ppHRegX86(i->Xin.Test32.dst);
return;
case Xin_Unary32:
if (i->Xin.Sh3232.amt == 0)
vex_printf(" %%cl,");
else
- vex_printf(" $%d,", i->Xin.Sh3232.amt);
+ vex_printf(" $%d,", (Int)i->Xin.Sh3232.amt);
ppHRegX86(i->Xin.Sh3232.src);
vex_printf(",");
ppHRegX86(i->Xin.Sh3232.dst);
return;
case Xin_Sse32Fx4:
vassert(i->Xin.Sse32Fx4.op != Xsse_MOV);
- unary = i->Xin.Sse32Fx4.op == Xsse_RCPF
- || i->Xin.Sse32Fx4.op == Xsse_RSQRTF
- || i->Xin.Sse32Fx4.op == Xsse_SQRTF;
+ unary = toBool( i->Xin.Sse32Fx4.op == Xsse_RCPF
+ || i->Xin.Sse32Fx4.op == Xsse_RSQRTF
+ || i->Xin.Sse32Fx4.op == Xsse_SQRTF );
addHRegUse(u, HRmRead, i->Xin.Sse32Fx4.src);
addHRegUse(u, unary ? HRmWrite : HRmModify,
i->Xin.Sse32Fx4.dst);
return;
case Xin_Sse32FLo:
vassert(i->Xin.Sse32FLo.op != Xsse_MOV);
- unary = i->Xin.Sse32FLo.op == Xsse_RCPF
- || i->Xin.Sse32FLo.op == Xsse_RSQRTF
- || i->Xin.Sse32FLo.op == Xsse_SQRTF;
+ unary = toBool( i->Xin.Sse32FLo.op == Xsse_RCPF
+ || i->Xin.Sse32FLo.op == Xsse_RSQRTF
+ || i->Xin.Sse32FLo.op == Xsse_SQRTF );
addHRegUse(u, HRmRead, i->Xin.Sse32FLo.src);
addHRegUse(u, unary ? HRmWrite : HRmModify,
i->Xin.Sse32FLo.dst);
return;
case Xin_Sse64Fx2:
vassert(i->Xin.Sse64Fx2.op != Xsse_MOV);
- unary = i->Xin.Sse64Fx2.op == Xsse_RCPF
- || i->Xin.Sse64Fx2.op == Xsse_RSQRTF
- || i->Xin.Sse64Fx2.op == Xsse_SQRTF;
+ unary = toBool( i->Xin.Sse64Fx2.op == Xsse_RCPF
+ || i->Xin.Sse64Fx2.op == Xsse_RSQRTF
+ || i->Xin.Sse64Fx2.op == Xsse_SQRTF );
addHRegUse(u, HRmRead, i->Xin.Sse64Fx2.src);
addHRegUse(u, unary ? HRmWrite : HRmModify,
i->Xin.Sse64Fx2.dst);
return;
case Xin_Sse64FLo:
vassert(i->Xin.Sse64FLo.op != Xsse_MOV);
- unary = i->Xin.Sse64FLo.op == Xsse_RCPF
- || i->Xin.Sse64FLo.op == Xsse_RSQRTF
- || i->Xin.Sse64FLo.op == Xsse_SQRTF;
+ unary = toBool( i->Xin.Sse64FLo.op == Xsse_RCPF
+ || i->Xin.Sse64FLo.op == Xsse_RSQRTF
+ || i->Xin.Sse64FLo.op == Xsse_SQRTF );
addHRegUse(u, HRmRead, i->Xin.Sse64FLo.src);
addHRegUse(u, unary ? HRmWrite : HRmModify,
i->Xin.Sse64FLo.dst);
/* --------- The x86 assembler (bleh.) --------- */
-static UInt iregNo ( HReg r )
+static UChar iregNo ( HReg r )
{
UInt n;
vassert(hregClass(r) == HRcInt32);
vassert(!hregIsVirtual(r));
n = hregNumber(r);
vassert(n <= 7);
- return n;
+ return toUChar(n);
}
static UInt fregNo ( HReg r )
static UChar mkModRegRM ( UChar mod, UChar reg, UChar regmem )
{
- return ((mod & 3) << 6) | ((reg & 7) << 3) | (regmem & 7);
+ return toUChar( ((mod & 3) << 6)
+ | ((reg & 7) << 3)
+ | (regmem & 7) );
}
static UChar mkSIB ( Int shift, Int regindex, Int regbase )
{
- return ((shift & 3) << 6) | ((regindex & 7) << 3) | (regbase & 7);
+ return toUChar( ((shift & 3) << 6)
+ | ((regindex & 7) << 3)
+ | (regbase & 7) );
}
static UChar* emit32 ( UChar* p, UInt w32 )
{
- *p++ = (w32) & 0x000000FF;
- *p++ = (w32 >> 8) & 0x000000FF;
- *p++ = (w32 >> 16) & 0x000000FF;
- *p++ = (w32 >> 24) & 0x000000FF;
+ *p++ = toUChar( w32 & 0x000000FF);
+ *p++ = toUChar((w32 >> 8) & 0x000000FF);
+ *p++ = toUChar((w32 >> 16) & 0x000000FF);
+ *p++ = toUChar((w32 >> 24) & 0x000000FF);
return p;
}
static Bool fits8bits ( UInt w32 )
{
Int i32 = (Int)w32;
- return i32 == ((i32 << 24) >> 24);
+ return toBool(i32 == ((i32 << 24) >> 24));
}
if (fits8bits(am->Xam.IR.imm)
&& am->Xam.IR.reg != hregX86_ESP()) {
*p++ = mkModRegRM(1, iregNo(greg), iregNo(am->Xam.IR.reg));
- *p++ = am->Xam.IR.imm & 0xFF;
+ *p++ = toUChar(am->Xam.IR.imm & 0xFF);
return p;
}
if (am->Xam.IR.reg != hregX86_ESP()) {
&& fits8bits(am->Xam.IR.imm)) {
*p++ = mkModRegRM(1, iregNo(greg), 4);
*p++ = 0x24;
- *p++ = am->Xam.IR.imm & 0xFF;
+ *p++ = toUChar(am->Xam.IR.imm & 0xFF);
return p;
}
ppX86AMode(am);
*p++ = mkModRegRM(1, iregNo(greg), 4);
*p++ = mkSIB(am->Xam.IRRS.shift, am->Xam.IRRS.index,
am->Xam.IRRS.base);
- *p++ = am->Xam.IRRS.imm & 0xFF;
+ *p++ = toUChar(am->Xam.IRRS.imm & 0xFF);
return p;
}
if (am->Xam.IRRS.index != hregX86_ESP()) {
{
vassert(1 <= i && i <= 7);
*p++ = 0xDD;
- *p++ = 0xD8+i;
+ *p++ = toUChar(0xD8+i);
return p;
}
{
vassert(0 <= i && i <= 6);
*p++ = 0xD9;
- *p++ = 0xC0+i;
+ *p++ = toUChar(0xC0+i);
return p;
}
if (i->Xin.Alu32R.op == Xalu_MOV) {
switch (i->Xin.Alu32R.src->tag) {
case Xrmi_Imm:
- *p++ = 0xB8 + iregNo(i->Xin.Alu32R.dst);
+ *p++ = toUChar(0xB8 + iregNo(i->Xin.Alu32R.dst));
p = emit32(p, i->Xin.Alu32R.src->Xrmi.Imm.imm32);
goto done;
case Xrmi_Reg:
if (fits8bits(i->Xin.Alu32R.src->Xrmi.Imm.imm32)) {
*p++ = 0x6B;
p = doAMode_R(p, i->Xin.Alu32R.dst, i->Xin.Alu32R.dst);
- *p++ = 0xFF & i->Xin.Alu32R.src->Xrmi.Imm.imm32;
+ *p++ = toUChar(0xFF & i->Xin.Alu32R.src->Xrmi.Imm.imm32);
} else {
*p++ = 0x69;
p = doAMode_R(p, i->Xin.Alu32R.dst, i->Xin.Alu32R.dst);
case Xrmi_Imm:
if (i->Xin.Alu32R.dst == hregX86_EAX()
&& !fits8bits(i->Xin.Alu32R.src->Xrmi.Imm.imm32)) {
- *p++ = opc_imma;
+ *p++ = toUChar(opc_imma);
p = emit32(p, i->Xin.Alu32R.src->Xrmi.Imm.imm32);
} else
if (fits8bits(i->Xin.Alu32R.src->Xrmi.Imm.imm32)) {
*p++ = 0x83;
p = doAMode_R(p, fake(subopc_imm), i->Xin.Alu32R.dst);
- *p++ = 0xFF & i->Xin.Alu32R.src->Xrmi.Imm.imm32;
+ *p++ = toUChar(0xFF & i->Xin.Alu32R.src->Xrmi.Imm.imm32);
} else {
*p++ = 0x81;
p = doAMode_R(p, fake(subopc_imm), i->Xin.Alu32R.dst);
}
goto done;
case Xrmi_Reg:
- *p++ = opc_rr;
+ *p++ = toUChar(opc_rr);
p = doAMode_R(p, i->Xin.Alu32R.src->Xrmi.Reg.reg,
i->Xin.Alu32R.dst);
goto done;
case Xrmi_Mem:
- *p++ = opc;
+ *p++ = toUChar(opc);
p = doAMode_M(p, i->Xin.Alu32R.dst,
i->Xin.Alu32R.src->Xrmi.Mem.am);
goto done;
}
switch (i->Xin.Alu32M.src->tag) {
case Xri_Reg:
- *p++ = opc;
+ *p++ = toUChar(opc);
p = doAMode_M(p, i->Xin.Alu32M.src->Xri.Reg.reg,
i->Xin.Alu32M.dst);
goto done;
if (fits8bits(i->Xin.Alu32M.src->Xri.Imm.imm32)) {
*p++ = 0x83;
p = doAMode_M(p, fake(subopc_imm), i->Xin.Alu32M.dst);
- *p++ = 0xFF & i->Xin.Alu32M.src->Xri.Imm.imm32;
+ *p++ = toUChar(0xFF & i->Xin.Alu32M.src->Xri.Imm.imm32);
goto done;
} else {
*p++ = 0x81;
default: goto bad;
}
if (i->Xin.Sh32.src == 0) {
- *p++ = opc_cl;
+ *p++ = toUChar(opc_cl);
p = doAMode_R(p, fake(subopc), i->Xin.Sh32.dst);
} else {
- *p++ = opc_imm;
+ *p++ = toUChar(opc_imm);
p = doAMode_R(p, fake(subopc), i->Xin.Sh32.dst);
*p++ = (UChar)(i->Xin.Sh32.src);
}
p = emit32(p, i->Xin.Push.src->Xrmi.Imm.imm32);
goto done;
case Xrmi_Reg:
- *p++ = 0x50 + iregNo(i->Xin.Push.src->Xrmi.Reg.reg);
+ *p++ = toUChar(0x50 + iregNo(i->Xin.Push.src->Xrmi.Reg.reg));
goto done;
default:
goto bad;
/* jump over the following two insns if the condition does not
hold */
if (i->Xin.Call.cond != Xcc_ALWAYS) {
- *p++ = 0x70 + (0xF & (i->Xin.Call.cond ^ 1));
+ *p++ = toUChar(0x70 + (0xF & (i->Xin.Call.cond ^ 1)));
*p++ = 0x07; /* 7 bytes in the next two insns */
}
/* movl $target, %tmp */
- *p++ = 0xB8 + irno;
+ *p++ = toUChar(0xB8 + irno);
p = emit32(p, i->Xin.Call.target);
/* call *%tmp */
*p++ = 0xFF;
- *p++ = 0xD0 + irno;
+ *p++ = toUChar(0xD0 + irno);
goto done;
case Xin_Goto:
jump over the rest of it. */
if (i->Xin.Goto.cond != Xcc_ALWAYS) {
/* jmp fwds if !condition */
- *p++ = 0x70 + (i->Xin.Goto.cond ^ 1);
+ *p++ = toUChar(0x70 + (0xF & (i->Xin.Goto.cond ^ 1)));
ptmp = p; /* fill in this bit later */
*p++ = 0; /* # of bytes to jump over; don't know how many yet. */
}
if (i->Xin.Goto.cond != Xcc_ALWAYS) {
Int delta = p - ptmp;
vassert(delta > 0 && delta < 20);
- *ptmp = (UChar)(delta-1);
+ *ptmp = toUChar(delta-1);
}
goto done;
vassert(i->Xin.CMov32.cond != Xcc_ALWAYS);
/* This generates cmov, which is illegal on P54/P55. */
*p++ = 0x0F;
- *p++ = 0x40 + i->Xin.CMov32.cond;
+ *p++ = toUChar(0x40 + (0xF & i->Xin.CMov32.cond));
if (i->Xin.CMov32.src->tag == Xrm_Reg) {
p = doAMode_R(p, i->Xin.CMov32.dst, i->Xin.CMov32.src->Xrm.Reg.reg);
goto done;
/* Do we need to swap in %eax? */
if (iregNo(i->Xin.Set32.dst) >= 4) {
/* xchg %eax, %dst */
- *p++ = 0x90 + iregNo(i->Xin.Set32.dst);
+ *p++ = toUChar(0x90 + iregNo(i->Xin.Set32.dst));
/* movl $0, %eax */
- *p++ = 0xB8 + iregNo(hregX86_EAX());
+ *p++ =toUChar(0xB8 + iregNo(hregX86_EAX()));
p = emit32(p, 0);
/* setb lo8(%eax) */
*p++ = 0x0F;
- *p++ = 0x90 + (UChar)(i->Xin.Set32.cond);
+ *p++ = toUChar(0x90 + (0xF & i->Xin.Set32.cond));
p = doAMode_R(p, fake(0), hregX86_EAX());
/* xchg %eax, %dst */
- *p++ = 0x90 + iregNo(i->Xin.Set32.dst);
+ *p++ = toUChar(0x90 + iregNo(i->Xin.Set32.dst));
} else {
/* movl $0, %dst */
- *p++ = 0xB8 + iregNo(i->Xin.Set32.dst);
+ *p++ = toUChar(0xB8 + iregNo(i->Xin.Set32.dst));
p = emit32(p, 0);
/* setb lo8(%dst) */
*p++ = 0x0F;
- *p++ = 0x90 + (UChar)(i->Xin.Set32.cond);
+ *p++ = toUChar(0x90 + (0xF & i->Xin.Set32.cond));
p = doAMode_R(p, fake(0), i->Xin.Set32.dst);
}
goto done;
p = do_ffree_st7(p);
p = do_fld_st(p, 1+hregNumber(i->Xin.FpBinary.srcR));
*p++ = 0xD9;
- *p++ = i->Xin.FpBinary.op==Xfp_YL2X ? 0xF1 : 0xF9;
+ *p++ = toUChar(i->Xin.FpBinary.op==Xfp_YL2X ? 0xF1 : 0xF9);
p = do_fstp_st(p, 1+hregNumber(i->Xin.FpBinary.dst));
goto done;
}
--> ffree %st(7) ; fld{s/l} amode ; fstp st(N+1)
*/
p = do_ffree_st7(p);
- *p++ = i->Xin.FpLdSt.sz==4 ? 0xD9 : 0xDD;
+ *p++ = toUChar(i->Xin.FpLdSt.sz==4 ? 0xD9 : 0xDD);
p = doAMode_M(p, fake(0)/*subopcode*/, i->Xin.FpLdSt.addr);
p = do_fstp_st(p, 1+hregNumber(i->Xin.FpLdSt.reg));
goto done;
*/
p = do_ffree_st7(p);
p = do_fld_st(p, 0+hregNumber(i->Xin.FpLdSt.reg));
- *p++ = i->Xin.FpLdSt.sz==4 ? 0xD9 : 0xDD;
+ *p++ = toUChar(i->Xin.FpLdSt.sz==4 ? 0xD9 : 0xDD);
p = doAMode_M(p, fake(3)/*subopcode*/, i->Xin.FpLdSt.addr);
goto done;
}
default: vpanic("emitX86Instr(Xin_FpLdStI-load)");
}
p = do_ffree_st7(p);
- *p++ = opc;
+ *p++ = toUChar(opc);
p = doAMode_M(p, fake(subopc_imm)/*subopcode*/, i->Xin.FpLdStI.addr);
p = do_fstp_st(p, 1+hregNumber(i->Xin.FpLdStI.reg));
goto done;
}
p = do_ffree_st7(p);
p = do_fld_st(p, 0+hregNumber(i->Xin.FpLdStI.reg));
- *p++ = opc;
+ *p++ = toUChar(opc);
p = doAMode_M(p, fake(subopc_imm)/*subopcode*/, i->Xin.FpLdStI.addr);
goto done;
}
case Xin_FpCMov:
/* jmp fwds if !condition */
- *p++ = 0x70 + (i->Xin.FpCMov.cond ^ 1);
+ *p++ = toUChar(0x70 + (i->Xin.FpCMov.cond ^ 1));
*p++ = 0; /* # of bytes in the next bit, which we don't know yet */
ptmp = p;
p = do_fstp_st(p, 1+fregNo(i->Xin.FpCMov.dst));
/* Fill in the jump offset. */
- *(ptmp-1) = p - ptmp;
+ *(ptmp-1) = toUChar(p - ptmp);
goto done;
case Xin_FpLdCW:
p = do_fld_st(p, 0+fregNo(i->Xin.FpCmp.srcL));
/* fucomp %(fR+1) */
*p++ = 0xDD;
- *p++ = 0xE8 + (7 & (1+fregNo(i->Xin.FpCmp.srcR)));
+ *p++ = toUChar(0xE8 + (7 & (1+fregNo(i->Xin.FpCmp.srcR))));
/* fnstsw %ax */
*p++ = 0xDF;
*p++ = 0xE0;
case Xin_SseConst: {
UShort con = i->Xin.SseConst.con;
- p = push_word_from_tags(p, (con >> 12) & 0xF);
- p = push_word_from_tags(p, (con >> 8) & 0xF);
- p = push_word_from_tags(p, (con >> 4) & 0xF);
- p = push_word_from_tags(p, con & 0xF);
+ p = push_word_from_tags(p, toUShort((con >> 12) & 0xF));
+ p = push_word_from_tags(p, toUShort((con >> 8) & 0xF));
+ p = push_word_from_tags(p, toUShort((con >> 4) & 0xF));
+ p = push_word_from_tags(p, toUShort(con & 0xF));
/* movl (%esp), %xmm-dst */
*p++ = 0x0F;
*p++ = 0x10;
- *p++ = 0x04 + 8 * (7 & vregNo(i->Xin.SseConst.dst));
+ *p++ = toUChar(0x04 + 8 * (7 & vregNo(i->Xin.SseConst.dst)));
*p++ = 0x24;
/* addl $16, %esp */
*p++ = 0x83;
case Xin_SseLdSt:
*p++ = 0x0F;
- *p++ = i->Xin.SseLdSt.isLoad ? 0x10 : 0x11;
+ *p++ = toUChar(i->Xin.SseLdSt.isLoad ? 0x10 : 0x11);
p = doAMode_M(p, fake(vregNo(i->Xin.SseLdSt.reg)), i->Xin.SseLdSt.addr);
goto done;
case Xin_SseLdzLO:
vassert(i->Xin.SseLdzLO.sz == 4 || i->Xin.SseLdzLO.sz == 8);
/* movs[sd] amode, %xmm-dst */
- *p++ = i->Xin.SseLdzLO.sz==4 ? 0xF3 : 0xF2;
+ *p++ = toUChar(i->Xin.SseLdzLO.sz==4 ? 0xF3 : 0xF2);
*p++ = 0x0F;
*p++ = 0x10;
p = doAMode_M(p, fake(vregNo(i->Xin.SseLdzLO.reg)),
p = doAMode_R(p, fake(vregNo(i->Xin.Sse32Fx4.dst)),
fake(vregNo(i->Xin.Sse32Fx4.src)) );
if (xtra & 0x100)
- *p++ = (UChar)(xtra & 0xFF);
+ *p++ = toUChar(xtra & 0xFF);
goto done;
case Xin_Sse64Fx2:
p = doAMode_R(p, fake(vregNo(i->Xin.Sse64Fx2.dst)),
fake(vregNo(i->Xin.Sse64Fx2.src)) );
if (xtra & 0x100)
- *p++ = (UChar)(xtra & 0xFF);
+ *p++ = toUChar(xtra & 0xFF);
goto done;
case Xin_Sse32FLo:
p = doAMode_R(p, fake(vregNo(i->Xin.Sse32FLo.dst)),
fake(vregNo(i->Xin.Sse32FLo.src)) );
if (xtra & 0x100)
- *p++ = (UChar)(xtra & 0xFF);
+ *p++ = toUChar(xtra & 0xFF);
goto done;
case Xin_Sse64FLo:
p = doAMode_R(p, fake(vregNo(i->Xin.Sse64FLo.dst)),
fake(vregNo(i->Xin.Sse64FLo.src)) );
if (xtra & 0x100)
- *p++ = (UChar)(xtra & 0xFF);
+ *p++ = toUChar(xtra & 0xFF);
goto done;
case Xin_SseReRg:
case Xin_SseCMov:
/* jmp fwds if !condition */
- *p++ = 0x70 + (i->Xin.SseCMov.cond ^ 1);
+ *p++ = toUChar(0x70 + (i->Xin.SseCMov.cond ^ 1));
*p++ = 0; /* # of bytes in the next bit, which we don't know yet */
ptmp = p;
fake(vregNo(i->Xin.SseCMov.src)) );
/* Fill in the jump offset. */
- *(ptmp-1) = p - ptmp;
+ *(ptmp-1) = toUChar(p - ptmp);
goto done;
case Xin_SseShuf: