You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(3) |
2
(2) |
3
|
4
(1) |
|
5
|
6
(2) |
7
|
8
(1) |
9
|
10
(2) |
11
(8) |
|
12
(2) |
13
(9) |
14
(2) |
15
(6) |
16
(5) |
17
(3) |
18
|
|
19
|
20
(1) |
21
(1) |
22
(6) |
23
(8) |
24
(2) |
25
(1) |
|
26
|
27
(3) |
28
(8) |
29
(17) |
30
(6) |
31
(3) |
|
|
From: <sv...@va...> - 2017-03-11 21:07:29
|
Author: philippe
Date: Sat Mar 11 21:07:21 2017
New Revision: 16266
Log:
Add missing break for the DRM ioctl operations that do not have any args
Due to this missing break, the code was falling through to
the case VKI_SNDRV_CTL_IOCTL_PVERSION:
and was then setting some bytes as defined at (whatever address is in) ARG3.
Patch and analysis by Daniel Glöckner
Modified:
trunk/coregrind/m_syswrap/syswrap-linux.c
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c Sat Mar 11 21:07:21 2017
@@ -9520,6 +9520,8 @@
case VKI_SNDRV_TIMER_IOCTL_STOP:
case VKI_SNDRV_TIMER_IOCTL_CONTINUE:
case VKI_SNDRV_TIMER_IOCTL_PAUSE:
+ break;
+
case VKI_SNDRV_CTL_IOCTL_PVERSION: {
POST_MEM_WRITE( (Addr)ARG3, sizeof(int) );
break;
|
|
From: <sv...@va...> - 2017-03-11 14:48:42
|
Author: iraisr
Date: Sat Mar 11 14:48:35 2017
New Revision: 3312
Log:
Make compilable x86 VEX isel backend.
Modified:
branches/VEX_JIT_HACKS/priv/host_x86_isel.c
Modified: branches/VEX_JIT_HACKS/priv/host_x86_isel.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/host_x86_isel.c (original)
+++ branches/VEX_JIT_HACKS/priv/host_x86_isel.c Sat Mar 11 14:48:35 2017
@@ -192,18 +192,20 @@
static HReg lookupIRTemp ( ISelEnv* env, IRTemp tmp )
{
- vassert(tmp >= 0);
- vassert(tmp < env->n_vregmap);
- return env->vregmap[tmp];
+ vassert(tmp.id == 0); // TODO-JIT: assume now only IRTypeEnv ID #0
+ vassert(tmp.index >= 0);
+ vassert(tmp.index < env->n_vregmap);
+ return env->vregmap[tmp.index];
}
static void lookupIRTemp64 ( HReg* vrHI, HReg* vrLO, ISelEnv* env, IRTemp tmp )
{
- vassert(tmp >= 0);
- vassert(tmp < env->n_vregmap);
- vassert(! hregIsInvalid(env->vregmapHI[tmp]));
- *vrLO = env->vregmap[tmp];
- *vrHI = env->vregmapHI[tmp];
+ vassert(tmp.id == 0); // TODO-JIT: assume now only IRTypeEnv ID #0
+ vassert(tmp.index >= 0);
+ vassert(tmp.index < env->n_vregmap);
+ vassert(! hregIsInvalid(env->vregmapHI[tmp.index]));
+ *vrLO = env->vregmap[tmp.index];
+ *vrHI = env->vregmapHI[tmp.index];
}
static void addInstr ( ISelEnv* env, X86Instr* instr )
@@ -4089,7 +4091,7 @@
/* Figure out the return type, if any. */
IRType retty = Ity_INVALID;
- if (d->tmp != IRTemp_INVALID)
+ if (!isIRTempInvalid(d->tmp))
retty = typeOfIRTemp(env->type_env, d->tmp);
Bool retty_ok = False;
@@ -4116,7 +4118,7 @@
switch (retty) {
case Ity_INVALID: {
/* No return value. Nothing to do. */
- vassert(d->tmp == IRTemp_INVALID);
+ vassert(isIRTempInvalid(d->tmp));
vassert(rloc.pri == RLPri_None);
vassert(addToSp == 0);
return;
@@ -4174,7 +4176,7 @@
/* --------- ACAS --------- */
case Ist_CAS:
- if (stmt->Ist.CAS.details->oldHi == IRTemp_INVALID) {
+ if (isIRTempInvalid(stmt->Ist.CAS.details->oldHi)) {
/* "normal" singleton CAS */
UChar sz;
IRCAS* cas = stmt->Ist.CAS.details;
@@ -4455,11 +4457,13 @@
env->code = newHInstrArray();
/* Copy BB's type env. */
- env->type_env = bb->tyenv;
+ /* TODO-JIT: Works only with IRTypeEnv ID #0. */
+ vassert(bb->stmts->tyenv->id == 0);
+ env->type_env = bb->stmts->tyenv;
/* Make up an IRTemp -> virtual HReg mapping. This doesn't
change as we go along. */
- env->n_vregmap = bb->tyenv->types_used;
+ env->n_vregmap = bb->stmts->tyenv->types_used;
env->vregmap = LibVEX_Alloc_inline(env->n_vregmap * sizeof(HReg));
env->vregmapHI = LibVEX_Alloc_inline(env->n_vregmap * sizeof(HReg));
@@ -4473,7 +4477,7 @@
j = 0;
for (i = 0; i < env->n_vregmap; i++) {
hregHI = hreg = INVALID_HREG;
- switch (bb->tyenv->types[i]) {
+ switch (bb->stmts->tyenv->types[i]) {
case Ity_I1:
case Ity_I8:
case Ity_I16:
@@ -4483,7 +4487,7 @@
case Ity_F32:
case Ity_F64: hreg = mkHReg(True, HRcFlt64, 0, j++); break;
case Ity_V128: hreg = mkHReg(True, HRcVec128, 0, j++); break;
- default: ppIRType(bb->tyenv->types[i]);
+ default: ppIRType(bb->stmts->tyenv->types[i]);
vpanic("iselBB: IRTemp type");
}
env->vregmap[i] = hreg;
@@ -4505,8 +4509,8 @@
}
/* Ok, finally we can iterate over the statements. */
- for (i = 0; i < bb->stmts_used; i++)
- iselStmt(env, bb->stmts[i]);
+ for (i = 0; i < bb->stmts->stmts_used; i++)
+ iselStmt(env, bb->stmts->stmts[i]);
iselNext(env, bb->next, bb->jumpkind, bb->offsIP);
|
|
From: <sv...@va...> - 2017-03-11 14:43:18
|
Author: iraisr
Date: Sat Mar 11 14:43:10 2017
New Revision: 3311
Log:
Progress further with compilation of x86 VEX frontend.
Modified:
branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c
branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c
branches/VEX_JIT_HACKS/priv/ir_defs.c
branches/VEX_JIT_HACKS/priv/ir_opt.c
branches/VEX_JIT_HACKS/pub/libvex_ir.h
Modified: branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c (original)
+++ branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c Sat Mar 11 14:43:10 2017
@@ -264,9 +264,9 @@
each). We won't know until later the extents and checksums of
the areas, if any, that need to be checked. */
nop = IRStmt_NoOp();
- selfcheck_idx = irsb->stmts_used;
+ selfcheck_idx = irsb->stmts->stmts_used;
for (i = 0; i < 3 * 5; i++)
- addStmtToIRSB( irsb, nop );
+ addStmtToIRStmtVec(irsb->stmts, nop);
/* If the caller supplied a function to add its own preamble, use
it now. */
@@ -315,7 +315,7 @@
/* This is the irsb statement array index of the first stmt in
this insn. That will always be the instruction-mark
descriptor. */
- first_stmt_idx = irsb->stmts_used;
+ first_stmt_idx = irsb->stmts->stmts_used;
/* Add an instruction-mark statement. We won't know until after
disassembling the instruction how long it instruction is, so
@@ -334,19 +334,19 @@
libvex_guest_arm.h. */
if (arch_guest == VexArchARM && (guest_IP_curr_instr & 1)) {
/* Thumb insn => mask out the T bit, but put it in delta */
- addStmtToIRSB( irsb,
- IRStmt_IMark(guest_IP_curr_instr & ~(Addr)1,
- 0, /* len */
- 1 /* delta */
- )
+ addStmtToIRStmtVec(irsb->stmts,
+ IRStmt_IMark(guest_IP_curr_instr & ~(Addr)1,
+ 0, /* len */
+ 1 /* delta */
+ )
);
} else {
/* All other targets: store IP as-is, and set delta to zero. */
- addStmtToIRSB( irsb,
- IRStmt_IMark(guest_IP_curr_instr,
- 0, /* len */
- 0 /* delta */
- )
+ addStmtToIRStmtVec(irsb->stmts,
+ IRStmt_IMark(guest_IP_curr_instr,
+ 0, /* len */
+ 0 /* delta */
+ )
);
}
@@ -384,8 +384,8 @@
vassert(dres.whatNext != Dis_ResteerC);
/* Fill in the insn-mark length field. */
- vassert(first_stmt_idx >= 0 && first_stmt_idx < irsb->stmts_used);
- imark = irsb->stmts[first_stmt_idx];
+ vassert(first_stmt_idx >= 0 && first_stmt_idx < irsb->stmts->stmts_used);
+ imark = irsb->stmts->stmts[first_stmt_idx];
vassert(imark);
vassert(imark->tag == Ist_IMark);
vassert(imark->Ist.IMark.len == 0);
@@ -393,9 +393,9 @@
/* Print the resulting IR, if needed. */
if (vex_traceflags & VEX_TRACE_FE) {
- for (i = first_stmt_idx; i < irsb->stmts_used; i++) {
+ for (i = first_stmt_idx; i < irsb->stmts->stmts_used; i++) {
vex_printf(" ");
- ppIRStmt(irsb->stmts[i]);
+ ppIRStmt(irsb->stmts->stmts[i]);
vex_printf("\n");
}
}
@@ -408,9 +408,9 @@
/* Individual insn disassembly must finish the IR for each
instruction with an assignment to the guest PC. */
- vassert(first_stmt_idx < irsb->stmts_used);
+ vassert(first_stmt_idx < irsb->stmts->stmts_used);
/* it follows that irsb->stmts_used must be > 0 */
- { IRStmt* st = irsb->stmts[irsb->stmts_used-1];
+ { IRStmt* st = irsb->stmts->stmts[irsb->stmts->stmts_used-1];
vassert(st);
vassert(st->tag == Ist_Put);
vassert(st->Ist.Put.offset == offB_GUEST_IP);
@@ -669,8 +669,8 @@
the area of guest code to invalidate should we exit with a
self-check failure. */
- tistart_tmp = newIRTemp(irsb->tyenv, guest_word_type);
- tilen_tmp = newIRTemp(irsb->tyenv, guest_word_type);
+ tistart_tmp = newIRTemp(irsb->stmts->tyenv, guest_word_type);
+ tilen_tmp = newIRTemp(irsb->stmts->tyenv, guest_word_type);
IRConst* base2check_IRConst
= guest_word_type==Ity_I32 ? IRConst_U32(toUInt(base2check))
@@ -679,16 +679,16 @@
= guest_word_type==Ity_I32 ? IRConst_U32(len2check)
: IRConst_U64(len2check);
- irsb->stmts[selfcheck_idx + i * 5 + 0]
+ irsb->stmts->stmts[selfcheck_idx + i * 5 + 0]
= IRStmt_WrTmp(tistart_tmp, IRExpr_Const(base2check_IRConst) );
- irsb->stmts[selfcheck_idx + i * 5 + 1]
+ irsb->stmts->stmts[selfcheck_idx + i * 5 + 1]
= IRStmt_WrTmp(tilen_tmp, IRExpr_Const(len2check_IRConst) );
- irsb->stmts[selfcheck_idx + i * 5 + 2]
+ irsb->stmts->stmts[selfcheck_idx + i * 5 + 2]
= IRStmt_Put( offB_GUEST_CMSTART, IRExpr_RdTmp(tistart_tmp) );
- irsb->stmts[selfcheck_idx + i * 5 + 3]
+ irsb->stmts->stmts[selfcheck_idx + i * 5 + 3]
= IRStmt_Put( offB_GUEST_CMLEN, IRExpr_RdTmp(tilen_tmp) );
/* Generate the entry point descriptors */
@@ -730,7 +730,7 @@
);
}
- irsb->stmts[selfcheck_idx + i * 5 + 4]
+ irsb->stmts->stmts[selfcheck_idx + i * 5 + 4]
= IRStmt_Exit(
IRExpr_Binop(
host_word_type==Ity_I64 ? Iop_CmpNE64 : Iop_CmpNE32,
Modified: branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c (original)
+++ branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c Sat Mar 11 14:43:10 2017
@@ -208,7 +208,8 @@
translated. */
static Addr32 guest_EIP_curr_instr;
-/* The IRSB* into which we're generating code. */
+/* The IRSB* into which we're generating code. All functions below work
+ implicitly with the main statement vector held by irsb->stmts. */
static IRSB* irsb;
@@ -309,17 +310,17 @@
#define R_GS 5
-/* Add a statement to the list held by "irbb". */
+/* Add a statement to the main statement vector held by "irbb->stmts". */
static void stmt ( IRStmt* st )
{
- addStmtToIRSB( irsb, st );
+ addStmtToIRStmtVec(irsb->stmts, st);
}
/* Generate a new temporary of the given type. */
static IRTemp newTemp ( IRType ty )
{
vassert(isPlausibleIRType(ty));
- return newIRTemp( irsb->tyenv, ty );
+ return newIRTemp(irsb->stmts->tyenv, ty);
}
/* Various simple conversions */
@@ -547,7 +548,7 @@
/* Ditto, but write to a reg instead. */
static void putIReg ( Int sz, UInt archreg, IRExpr* e )
{
- IRType ty = typeOfIRExpr(irsb->tyenv, e);
+ IRType ty = typeOfIRExpr(irsb->stmts->tyenv, e);
switch (sz) {
case 1: vassert(ty == Ity_I8); break;
case 2: vassert(ty == Ity_I16); break;
@@ -565,7 +566,7 @@
static void putSReg ( UInt sreg, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_I16);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I16);
stmt( IRStmt_Put( segmentGuestRegOffset(sreg), e ) );
}
@@ -596,37 +597,37 @@
static void putXMMReg ( UInt xmmreg, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_V128);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_V128);
stmt( IRStmt_Put( xmmGuestRegOffset(xmmreg), e ) );
}
static void putXMMRegLane64 ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_I64);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I64);
stmt( IRStmt_Put( xmmGuestRegLane64offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane64F ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_F64);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_F64);
stmt( IRStmt_Put( xmmGuestRegLane64offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane32F ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_F32);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_F32);
stmt( IRStmt_Put( xmmGuestRegLane32offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane32 ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I32);
stmt( IRStmt_Put( xmmGuestRegLane32offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane16 ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_I16);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I16);
stmt( IRStmt_Put( xmmGuestRegLane16offset(xmmreg,laneno), e ) );
}
@@ -734,8 +735,8 @@
static IRExpr* mkAnd1 ( IRExpr* x, IRExpr* y )
{
- vassert(typeOfIRExpr(irsb->tyenv,x) == Ity_I1);
- vassert(typeOfIRExpr(irsb->tyenv,y) == Ity_I1);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, x) == Ity_I1);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, y) == Ity_I1);
return unop(Iop_32to1,
binop(Iop_And32,
unop(Iop_1Uto32,x),
@@ -752,15 +753,15 @@
Addr32 restart_point )
{
IRCAS* cas;
- IRType tyE = typeOfIRExpr(irsb->tyenv, expVal);
- IRType tyN = typeOfIRExpr(irsb->tyenv, newVal);
+ IRType tyE = typeOfIRExpr(irsb->stmts->tyenv, expVal);
+ IRType tyN = typeOfIRExpr(irsb->stmts->tyenv, newVal);
IRTemp oldTmp = newTemp(tyE);
IRTemp expTmp = newTemp(tyE);
vassert(tyE == tyN);
vassert(tyE == Ity_I32 || tyE == Ity_I16 || tyE == Ity_I8);
assign(expTmp, expVal);
- cas = mkIRCAS( IRTemp_INVALID, oldTmp, Iend_LE, addr,
- NULL, mkexpr(expTmp), NULL, newVal );
+ cas = mkIRCAS(IRTemp_INVALID(), oldTmp, Iend_LE, addr,
+ NULL, mkexpr(expTmp), NULL, newVal);
stmt( IRStmt_CAS(cas) );
stmt( IRStmt_Exit(
binop( mkSizedOp(tyE,Iop_CasCmpNE8),
@@ -867,7 +868,7 @@
/* U-widen 8/16/32 bit int expr to 32. */
static IRExpr* widenUto32 ( IRExpr* e )
{
- switch (typeOfIRExpr(irsb->tyenv,e)) {
+ switch (typeOfIRExpr(irsb->stmts->tyenv, e)) {
case Ity_I32: return e;
case Ity_I16: return unop(Iop_16Uto32,e);
case Ity_I8: return unop(Iop_8Uto32,e);
@@ -878,7 +879,7 @@
/* S-widen 8/16/32 bit int expr to 32. */
static IRExpr* widenSto32 ( IRExpr* e )
{
- switch (typeOfIRExpr(irsb->tyenv,e)) {
+ switch (typeOfIRExpr(irsb->stmts->tyenv, e)) {
case Ity_I32: return e;
case Ity_I16: return unop(Iop_16Sto32,e);
case Ity_I8: return unop(Iop_8Sto32,e);
@@ -890,7 +891,7 @@
of these combinations make sense. */
static IRExpr* narrowTo ( IRType dst_ty, IRExpr* e )
{
- IRType src_ty = typeOfIRExpr(irsb->tyenv,e);
+ IRType src_ty = typeOfIRExpr(irsb->stmts->tyenv, e);
if (src_ty == dst_ty)
return e;
if (src_ty == Ity_I32 && dst_ty == Ity_I16)
@@ -970,7 +971,7 @@
Int ccOp = ty==Ity_I8 ? 2 : (ty==Ity_I16 ? 1 : 0);
vassert(ty == Ity_I8 || ty == Ity_I16 || ty == Ity_I32);
- vassert(guard);
+ vassert(!isIRTempInvalid(guard));
/* Both kinds of right shifts are handled by the same thunk
operation. */
@@ -1132,7 +1133,7 @@
IROp plus = mkSizedOp(ty, Iop_Add8);
IROp xor = mkSizedOp(ty, Iop_Xor8);
- vassert(typeOfIRTemp(irsb->tyenv, tres) == ty);
+ vassert(typeOfIRTemp(irsb->stmts->tyenv, tres) == ty);
vassert(sz == 1 || sz == 2 || sz == 4);
thunkOp = sz==4 ? X86G_CC_OP_ADCL
: (sz==2 ? X86G_CC_OP_ADCW : X86G_CC_OP_ADCB);
@@ -1150,12 +1151,12 @@
/* Possibly generate a store of 'tres' to 'taddr'. See comment at
start of this function. */
- if (taddr != IRTemp_INVALID) {
- if (texpVal == IRTemp_INVALID) {
+ if (!isIRTempInvalid(taddr)) {
+ if (isIRTempInvalid(texpVal)) {
vassert(restart_point == 0);
storeLE( mkexpr(taddr), mkexpr(tres) );
} else {
- vassert(typeOfIRTemp(irsb->tyenv, texpVal) == ty);
+ vassert(typeOfIRTemp(irsb->stmts->tyenv, texpVal) == ty);
/* .. and hence 'texpVal' has the same type as 'tres'. */
casLE( mkexpr(taddr),
mkexpr(texpVal), mkexpr(tres), restart_point );
@@ -1186,7 +1187,7 @@
IROp minus = mkSizedOp(ty, Iop_Sub8);
IROp xor = mkSizedOp(ty, Iop_Xor8);
- vassert(typeOfIRTemp(irsb->tyenv, tres) == ty);
+ vassert(typeOfIRTemp(irsb->stmts->tyenv, tres) == ty);
vassert(sz == 1 || sz == 2 || sz == 4);
thunkOp = sz==4 ? X86G_CC_OP_SBBL
: (sz==2 ? X86G_CC_OP_SBBW : X86G_CC_OP_SBBB);
@@ -1204,12 +1205,12 @@
/* Possibly generate a store of 'tres' to 'taddr'. See comment at
start of this function. */
- if (taddr != IRTemp_INVALID) {
- if (texpVal == IRTemp_INVALID) {
+ if (!isIRTempInvalid(taddr)) {
+ if (isIRTempInvalid(texpVal)) {
vassert(restart_point == 0);
storeLE( mkexpr(taddr), mkexpr(tres) );
} else {
- vassert(typeOfIRTemp(irsb->tyenv, texpVal) == ty);
+ vassert(typeOfIRTemp(irsb->stmts->tyenv, texpVal) == ty);
/* .. and hence 'texpVal' has the same type as 'tres'. */
casLE( mkexpr(taddr),
mkexpr(texpVal), mkexpr(tres), restart_point );
@@ -1728,7 +1729,6 @@
default:
vpanic("disAMode(x86)");
- return 0; /*notreached*/
}
}
@@ -1838,7 +1838,7 @@
IRTemp src = newTemp(ty);
IRTemp dst0 = newTemp(ty);
UChar rm = getUChar(delta0);
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
/* addSubCarry == True indicates the intended operation is
add-with-carry or subtract-with-borrow. */
@@ -1861,12 +1861,12 @@
if (addSubCarry && op8 == Iop_Add8) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else
if (addSubCarry && op8 == Iop_Sub8) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else {
assign( dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)) );
@@ -1890,12 +1890,12 @@
if (addSubCarry && op8 == Iop_Add8) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else
if (addSubCarry && op8 == Iop_Sub8) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else {
assign( dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)) );
@@ -1951,7 +1951,7 @@
IRTemp src = newTemp(ty);
IRTemp dst0 = newTemp(ty);
UChar rm = getIByte(delta0);
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
/* addSubCarry == True indicates the intended operation is
add-with-carry or subtract-with-borrow. */
@@ -1974,12 +1974,12 @@
if (addSubCarry && op8 == Iop_Add8) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
putIReg(size, eregOfRM(rm), mkexpr(dst1));
} else
if (addSubCarry && op8 == Iop_Sub8) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
putIReg(size, eregOfRM(rm), mkexpr(dst1));
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
@@ -2011,7 +2011,7 @@
} else {
/* normal store */
helper_ADC( size, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID, 0 );
+ /*store*/addr, IRTemp_INVALID(), 0 );
}
} else
if (addSubCarry && op8 == Iop_Sub8) {
@@ -2022,7 +2022,7 @@
} else {
/* normal store */
helper_SBB( size, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID, 0 );
+ /*store*/addr, IRTemp_INVALID(), 0 );
}
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
@@ -2168,12 +2168,12 @@
else
if (op8 == Iop_Add8 && carrying) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
}
else
if (op8 == Iop_Sub8 && carrying) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
}
else
vpanic("dis_op_imm_A(x86,guest)");
@@ -2291,7 +2291,7 @@
IRTemp dst1 = newTemp(ty);
IRTemp src = newTemp(ty);
IRTemp dst0 = newTemp(ty);
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
IROp op8 = Iop_INVALID;
UInt mask = sz==1 ? 0xFF : (sz==2 ? 0xFFFF : 0xFFFFFFFF);
@@ -2313,11 +2313,11 @@
if (gregOfRM(modrm) == 2 /* ADC */) {
helper_ADC( sz, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
} else
if (gregOfRM(modrm) == 3 /* SBB */) {
helper_SBB( sz, dst1, dst0, src,
- /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
+ /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
if (isAddSub(op8))
@@ -2346,7 +2346,7 @@
} else {
/* normal store */
helper_ADC( sz, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID, 0 );
+ /*store*/addr, IRTemp_INVALID(), 0 );
}
} else
if (gregOfRM(modrm) == 3 /* SBB */) {
@@ -2357,7 +2357,7 @@
} else {
/* normal store */
helper_SBB( sz, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID, 0 );
+ /*store*/addr, IRTemp_INVALID(), 0 );
}
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
@@ -2400,7 +2400,7 @@
IRType ty = szToITy(sz);
IRTemp dst0 = newTemp(ty);
IRTemp dst1 = newTemp(ty);
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
*decode_OK = True;
@@ -2638,7 +2638,7 @@
IRType ty = szToITy(sz);
IRTemp t2 = newTemp(Ity_I32);
IRTemp t2m = newTemp(Ity_I32);
- IRTemp t_addr = IRTemp_INVALID;
+ IRTemp t_addr = IRTemp_INVALID();
HChar dis_buf[50];
UInt mask;
@@ -3043,10 +3043,10 @@
Int len;
UChar modrm;
HChar dis_buf[50];
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
IRType ty = szToITy(sz);
IRTemp t1 = newTemp(ty);
- IRTemp t2 = IRTemp_INVALID;
+ IRTemp t2 = IRTemp_INVALID();
*decode_OK = True;
@@ -3172,14 +3172,14 @@
/* Code shared by all the string ops */
static
-void dis_string_op_increment(Int sz, Int t_inc)
+void dis_string_op_increment(Int sz, IRTemp t_inc)
{
if (sz == 4 || sz == 2) {
- assign( t_inc,
+ assign( t_inc,
binop(Iop_Shl32, IRExpr_Get( OFFB_DFLAG, Ity_I32 ),
mkU8(sz/2) ) );
} else {
- assign( t_inc,
+ assign( t_inc,
IRExpr_Get( OFFB_DFLAG, Ity_I32 ) );
}
}
@@ -3451,7 +3451,7 @@
static void put_emwarn ( IRExpr* e /* :: Ity_I32 */ )
{
- vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I32);
stmt( IRStmt_Put( OFFB_EMNOTE, e ) );
}
@@ -3475,7 +3475,7 @@
static void put_ftop ( IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I32);
stmt( IRStmt_Put( OFFB_FTOP, e ) );
}
@@ -3527,7 +3527,7 @@
static void put_ST_TAG ( Int i, IRExpr* value )
{
IRRegArray* descr;
- vassert(typeOfIRExpr(irsb->tyenv, value) == Ity_I8);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, value) == Ity_I8);
descr = mkIRRegArray( OFFB_FPTAGS, Ity_I8, 8 );
stmt( IRStmt_PutI( mkIRPutI(descr, get_ftop(), i, value) ) );
}
@@ -3551,7 +3551,7 @@
static void put_ST_UNCHECKED ( Int i, IRExpr* value )
{
IRRegArray* descr;
- vassert(typeOfIRExpr(irsb->tyenv, value) == Ity_F64);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, value) == Ity_F64);
descr = mkIRRegArray( OFFB_FPREGS, Ity_F64, 8 );
stmt( IRStmt_PutI( mkIRPutI(descr, get_ftop(), i, value) ) );
/* Mark the register as in-use. */
@@ -5141,7 +5141,7 @@
case 7: { /* FNSTSW m16 */
IRExpr* sw = get_FPU_sw();
- vassert(typeOfIRExpr(irsb->tyenv, sw) == Ity_I16);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, sw) == Ity_I16);
storeLE( mkexpr(addr), sw );
DIP("fnstsw %s\n", dis_buf);
break;
@@ -5543,7 +5543,7 @@
static void putMMXReg ( UInt archreg, IRExpr* e )
{
vassert(archreg < 8);
- vassert(typeOfIRExpr(irsb->tyenv,e) == Ity_I64);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, e) == Ity_I64);
stmt( IRStmt_Put( OFFB_FPREGS + 8 * archreg, e ) );
}
@@ -6193,11 +6193,11 @@
IRType ty = szToITy(sz);
IRTemp gsrc = newTemp(ty);
IRTemp esrc = newTemp(ty);
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
IRTemp tmpSH = newTemp(Ity_I8);
- IRTemp tmpL = IRTemp_INVALID;
- IRTemp tmpRes = IRTemp_INVALID;
- IRTemp tmpSubSh = IRTemp_INVALID;
+ IRTemp tmpL = IRTemp_INVALID();
+ IRTemp tmpRes = IRTemp_INVALID();
+ IRTemp tmpSubSh = IRTemp_INVALID();
IROp mkpair;
IROp getres;
IROp shift;
@@ -6325,7 +6325,7 @@
t_fetched = t_bitno0 = t_bitno1 = t_bitno2
= t_addr0 = t_addr1 = t_esp
- = t_mask = t_new = IRTemp_INVALID;
+ = t_mask = t_new = IRTemp_INVALID();
t_fetched = newTemp(Ity_I8);
t_new = newTemp(Ity_I8);
@@ -6652,7 +6652,7 @@
IRTemp dest2 = newTemp(ty);
IRTemp acc2 = newTemp(ty);
IRTemp cond = newTemp(Ity_I1);
- IRTemp addr = IRTemp_INVALID;
+ IRTemp addr = IRTemp_INVALID();
UChar rm = getUChar(delta0);
/* There are 3 cases to consider:
@@ -6708,7 +6708,7 @@
assign( src, getIReg(size, gregOfRM(rm)) );
assign( acc, getIReg(size, R_EAX) );
stmt( IRStmt_CAS(
- mkIRCAS( IRTemp_INVALID, dest, Iend_LE, mkexpr(addr),
+ mkIRCAS( IRTemp_INVALID(), dest, Iend_LE, mkexpr(addr),
NULL, mkexpr(acc), NULL, mkexpr(src) )
));
setFlags_DEP1_DEP2(Iop_Sub8, acc, dest, ty);
@@ -7542,7 +7542,7 @@
static void put_sse_roundingmode ( IRExpr* sseround )
{
- vassert(typeOfIRExpr(irsb->tyenv, sseround) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->stmts->tyenv, sseround) == Ity_I32);
stmt( IRStmt_Put( OFFB_SSEROUND, sseround ) );
}
@@ -7558,10 +7558,10 @@
assign( hi64, unop(Iop_V128HIto64, mkexpr(t128)) );
assign( lo64, unop(Iop_V128to64, mkexpr(t128)) );
- vassert(t0 && *t0 == IRTemp_INVALID);
- vassert(t1 && *t1 == IRTemp_INVALID);
- vassert(t2 && *t2 == IRTemp_INVALID);
- vassert(t3 && *t3 == IRTemp_INVALID);
+ vassert(t0 && isIRTempInvalid(*t0));
+ vassert(t1 && isIRTempInvalid(*t1));
+ vassert(t2 && isIRTempInvalid(*t2));
+ vassert(t3 && isIRTempInvalid(*t3));
*t0 = newTemp(Ity_I32);
*t1 = newTemp(Ity_I32);
@@ -7597,10 +7597,10 @@
assign( hi32, unop(Iop_64HIto32, mkexpr(t64)) );
assign( lo32, unop(Iop_64to32, mkexpr(t64)) );
- vassert(t0 && *t0 == IRTemp_INVALID);
- vassert(t1 && *t1 == IRTemp_INVALID);
- vassert(t2 && *t2 == IRTemp_INVALID);
- vassert(t3 && *t3 == IRTemp_INVALID);
+ vassert(t0 && isIRTempInvalid(*t0));
+ vassert(t1 && isIRTempInvalid(*t1));
+ vassert(t2 && isIRTempInvalid(*t2));
+ vassert(t3 && isIRTempInvalid(*t3));
*t0 = newTemp(Ity_I16);
*t1 = newTemp(Ity_I16);
@@ -7642,7 +7642,7 @@
Bool emit_AC_emwarn,
Addr32 next_insn_EIP )
{
- vassert(typeOfIRTemp(irsb->tyenv,t1) == Ity_I32);
+ vassert(typeOfIRTemp(irsb->stmts->tyenv,t1) == Ity_I32);
/* t1 is the flag word. Mask out everything except OSZACP and set
the flags thunk to X86G_CC_OP_COPY. */
@@ -8050,8 +8050,6 @@
return t2;
}
vassert(0);
- /*NOTREACHED*/
- return IRTemp_INVALID;
}
/*------------------------------------------------------------*/
@@ -8118,7 +8116,7 @@
*expect_CAS = False;
- addr = t0 = t1 = t2 = t3 = t4 = t5 = t6 = IRTemp_INVALID;
+ addr = t0 = t1 = t2 = t3 = t4 = t5 = t6 = IRTemp_INVALID();
vassert(guest_EIP_bbstart + delta == guest_EIP_curr_instr);
DIP("\t0x%x: ", guest_EIP_bbstart+delta);
@@ -9046,7 +9044,7 @@
if (sz == 4 && insn[0] == 0x0F && insn[1] == 0x70) {
Int order;
IRTemp sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = IRTemp_INVALID();
sV = newTemp(Ity_I64);
dV = newTemp(Ity_I64);
do_MMX_preamble();
@@ -9397,7 +9395,7 @@
IRTemp s3, s2, s1, s0, d3, d2, d1, d0;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
- s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID();
modrm = insn[2];
assign( dV, getXMMReg(gregOfRM(modrm)) );
@@ -9498,7 +9496,7 @@
Bool hi = toBool(insn[1] == 0x15);
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
- s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID();
modrm = insn[2];
assign( dV, getXMMReg(gregOfRM(modrm)) );
@@ -11157,7 +11155,7 @@
IRTemp s3, s2, s1, s0, d3, d2, d1, d0;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
- s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID();
t1 = newTemp(Ity_I64);
t0 = newTemp(Ity_I64);
modrm = insn[2];
@@ -11243,7 +11241,7 @@
if (sz == 2 && insn[0] == 0x0F && insn[1] == 0x70) {
Int order;
IRTemp sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = IRTemp_INVALID();
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
modrm = insn[2];
@@ -11281,7 +11279,7 @@
if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0x70) {
Int order;
IRTemp sVhi, dVhi, sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = IRTemp_INVALID();
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
sVhi = newTemp(Ity_I64);
@@ -11325,7 +11323,7 @@
if (insn[0] == 0xF2 && insn[1] == 0x0F && insn[2] == 0x70) {
Int order;
IRTemp sVlo, dVlo, sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = IRTemp_INVALID();
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
sVlo = newTemp(Ity_I64);
@@ -11802,7 +11800,7 @@
IRTemp s3, s2, s1, s0;
IRTemp sV = newTemp(Ity_V128);
Bool isH = insn[2] == 0x16;
- s3 = s2 = s1 = s0 = IRTemp_INVALID;
+ s3 = s2 = s1 = s0 = IRTemp_INVALID();
modrm = insn[3];
if (epartIsReg(modrm)) {
@@ -11861,7 +11859,7 @@
IRTemp addV = newTemp(Ity_V128);
IRTemp subV = newTemp(Ity_V128);
IRTemp rm = newTemp(Ity_I32);
- a3 = a2 = a1 = a0 = s3 = s2 = s1 = s0 = IRTemp_INVALID;
+ a3 = a2 = a1 = a0 = s3 = s2 = s1 = s0 = IRTemp_INVALID();
modrm = insn[3];
if (epartIsReg(modrm)) {
@@ -11940,7 +11938,7 @@
IRTemp rm = newTemp(Ity_I32);
Bool isAdd = insn[2] == 0x7C;
const HChar* str = isAdd ? "add" : "sub";
- e3 = e2 = e1 = e0 = g3 = g2 = g1 = g0 = IRTemp_INVALID;
+ e3 = e2 = e1 = e0 = g3 = g2 = g1 = g0 = IRTemp_INVALID();
modrm = insn[3];
if (epartIsReg(modrm)) {
@@ -15450,13 +15448,13 @@
guest_EIP_curr_instr = (Addr32)guest_IP;
guest_EIP_bbstart = (Addr32)toUInt(guest_IP - delta);
- x1 = irsb_IN->stmts_used;
+ x1 = irsb_IN->stmts->stmts_used;
expect_CAS = False;
dres = disInstr_X86_WRK ( &expect_CAS, resteerOkFn,
resteerCisOk,
callback_opaque,
delta, archinfo, abiinfo, sigill_diag_IN );
- x2 = irsb_IN->stmts_used;
+ x2 = irsb_IN->stmts->stmts_used;
vassert(x2 >= x1);
/* See comment at the top of disInstr_X86_WRK for meaning of
@@ -15464,7 +15462,7 @@
IRCAS as directed by the returned expect_CAS value. */
has_CAS = False;
for (i = x1; i < x2; i++) {
- if (irsb_IN->stmts[i]->tag == Ist_CAS)
+ if (irsb_IN->stmts->stmts[i]->tag == Ist_CAS)
has_CAS = True;
}
@@ -15478,7 +15476,7 @@
delta, archinfo, abiinfo, sigill_diag_IN );
for (i = x1; i < x2; i++) {
vex_printf("\t\t");
- ppIRStmt(irsb_IN->stmts[i]);
+ ppIRStmt(irsb_IN->stmts->stmts[i]);
vex_printf("\n");
}
/* Failure of this assertion is serious and denotes a bug in
Modified: branches/VEX_JIT_HACKS/priv/ir_defs.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_defs.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_defs.c Sat Mar 11 14:43:10 2017
@@ -1693,7 +1693,7 @@
for (UInt i = 0; i < env->types_used; i++) {
if (i % 8 == 0)
vex_printf( " ");
- IRTemp temp = {env->id, i};
+ IRTemp temp = mkIRTemp(env->id, i);
ppIRTemp(temp);
vex_printf("=");
ppIRType(env->types[i]);
@@ -3739,8 +3739,7 @@
if (env->types_used < env->types_size) {
env->types[env->types_used] = ty;
- IRTemp tmp = {env->id, env->types_used++};
- return tmp;
+ return mkIRTemp(env->id, env->types_used++);
} else {
Int i;
Int new_size = env->types_size==0 ? 8 : 2*env->types_size;
@@ -5008,7 +5007,7 @@
/* Ensure each temp has a plausible type. */
for (UInt i = 0; i < n_temps; i++) {
- IRTemp temp = {id, i};
+ IRTemp temp = mkIRTemp(id, i);
IRType ty = typeOfIRTemp(tyenv, temp);
if (!isPlausibleIRType(ty)) {
vex_printf("Temp ");
Modified: branches/VEX_JIT_HACKS/priv/ir_opt.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_opt.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_opt.c Sat Mar 11 14:43:10 2017
@@ -3790,8 +3790,7 @@
HWord res;
/* env :: IRTemp -> IRTemp */
if (lookupHHW(env, &res, (HWord)tmp.index)) {
- IRTemp ret = {tmp.id, res};
- return ret;
+ return mkIRTemp(tmp.id, res);
} else {
return tmp;
}
Modified: branches/VEX_JIT_HACKS/pub/libvex_ir.h
==============================================================================
--- branches/VEX_JIT_HACKS/pub/libvex_ir.h (original)
+++ branches/VEX_JIT_HACKS/pub/libvex_ir.h Sat Mar 11 14:43:10 2017
@@ -413,7 +413,16 @@
}
IRTemp;
-#define IRTemp_INVALID {IRTyEnvID_INVALID, IRTyEnvIndex_INVALID}
+static inline IRTemp mkIRTemp(IRTyEnvID id, IRTyEnvIndex index)
+{
+ IRTemp tmp = {id, index};
+ return tmp;
+}
+
+static inline IRTemp IRTemp_INVALID(void)
+{
+ return mkIRTemp(IRTyEnvID_INVALID, IRTyEnvIndex_INVALID);
+}
/* Pretty-print an IRTemp. */
extern void ppIRTemp ( IRTemp );
|
Author: iraisr
Date: Sat Mar 11 14:07:07 2017
New Revision: 3310
Log:
First cut at introducing "if-then-else" control flow
into Valgrind's intermediate representation (IR).
Major rework done so far in modules: ir_defs.c and ir_opt.c.
Modified:
branches/VEX_JIT_HACKS/priv/ir_defs.c
branches/VEX_JIT_HACKS/priv/ir_inject.c
branches/VEX_JIT_HACKS/priv/ir_opt.c
branches/VEX_JIT_HACKS/priv/main_main.c
branches/VEX_JIT_HACKS/priv/main_util.c
branches/VEX_JIT_HACKS/pub/libvex_ir.h
branches/VEX_JIT_HACKS/useful/test_main.c
Modified: branches/VEX_JIT_HACKS/priv/ir_defs.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_defs.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_defs.c Sat Mar 11 14:07:07 2017
@@ -33,6 +33,8 @@
without prior written permission.
*/
+/* Copyright (C) 2017-2017 Ivo Raisr <iv...@iv...> */
+
#include "libvex_basictypes.h"
#include "libvex_ir.h"
#include "libvex.h"
@@ -111,10 +113,10 @@
void ppIRTemp ( IRTemp tmp )
{
- if (tmp == IRTemp_INVALID)
+ if (isIRTempInvalid(tmp))
vex_printf("IRTemp_INVALID");
else
- vex_printf( "t%u", tmp);
+ vex_printf("t%u:%u", tmp.id, tmp.index);
}
void ppIROp ( IROp op )
@@ -1409,7 +1411,7 @@
void ppIRDirty ( const IRDirty* d )
{
Int i;
- if (d->tmp != IRTemp_INVALID) {
+ if (!isIRTempInvalid(d->tmp)) {
ppIRTemp(d->tmp);
vex_printf(" = ");
}
@@ -1451,7 +1453,7 @@
{
/* Print even structurally invalid constructions, as an aid to
debugging. */
- if (cas->oldHi != IRTemp_INVALID) {
+ if (!isIRTempInvalid(cas->oldHi)) {
ppIRTemp(cas->oldHi);
vex_printf(",");
}
@@ -1567,6 +1569,25 @@
}
}
+void ppIRPhi(const IRPhi* phi)
+{
+ ppIRTemp(phi->dst);
+ vex_printf(" = phi(");
+ ppIRTemp(phi->srcThen);
+ vex_printf(",");
+ ppIRTemp(phi->srcElse);
+ vex_printf(")");
+}
+
+void ppIRPhiVec(const IRPhiVec* phis)
+{
+ for (UInt i = 0; i < phis->phis_used; i++) {
+ vex_printf(" ");
+ ppIRPhi(phis->phis[i]);
+ vex_printf("\n");
+ }
+}
+
void ppIRStmt ( const IRStmt* s )
{
if (!s) {
@@ -1649,19 +1670,32 @@
ppIRJumpKind(s->Ist.Exit.jk);
vex_printf(" } ");
break;
- default:
+ case Ist_IfThenElse:
+ vex_printf("if (");
+ ppIRExpr(s->Ist.IfThenElse.cond);
+ vex_printf(") then {\n");
+ ppIRStmtVec(s->Ist.IfThenElse.then_leg); // TODO-JIT: indent properly
+ vex_printf("} else {\n");
+ ppIRStmtVec(s->Ist.IfThenElse.else_leg); // TODO-JIT: indent properly
+ vex_printf("}\n");
+ IRPhiVec* phi_nodes = s->Ist.IfThenElse.phi_nodes;
+ if (phi_nodes != NULL) {
+ ppIRPhiVec(phi_nodes);
+ }
+ break;
+ default:
vpanic("ppIRStmt");
}
}
void ppIRTypeEnv ( const IRTypeEnv* env )
{
- UInt i;
- for (i = 0; i < env->types_used; i++) {
+ for (UInt i = 0; i < env->types_used; i++) {
if (i % 8 == 0)
vex_printf( " ");
- ppIRTemp(i);
- vex_printf( ":");
+ IRTemp temp = {env->id, i};
+ ppIRTemp(temp);
+ vex_printf("=");
ppIRType(env->types[i]);
if (i % 8 == 7)
vex_printf( "\n");
@@ -1672,17 +1706,22 @@
vex_printf( "\n");
}
-void ppIRSB ( const IRSB* bb )
+/* TODO-JIT: account for indentation */
+void ppIRStmtVec(const IRStmtVec* stmts)
{
- Int i;
- vex_printf("IRSB {\n");
- ppIRTypeEnv(bb->tyenv);
+ ppIRTypeEnv(stmts->tyenv);
vex_printf("\n");
- for (i = 0; i < bb->stmts_used; i++) {
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
vex_printf( " ");
- ppIRStmt(bb->stmts[i]);
- vex_printf( "\n");
+ ppIRStmt(stmts->stmts[i]);
+ vex_printf("\n");
}
+}
+
+void ppIRSB ( const IRSB* bb )
+{
+ vex_printf("IRSB {\n");
+ ppIRStmtVec(bb->stmts);
vex_printf( " PUT(%d) = ", bb->offsIP );
ppIRExpr( bb->next );
vex_printf( "; exit-");
@@ -2056,15 +2095,16 @@
/* Constructors -- IRDirty */
IRDirty* emptyIRDirty ( void ) {
- IRDirty* d = LibVEX_Alloc_inline(sizeof(IRDirty));
- d->cee = NULL;
- d->guard = NULL;
- d->args = NULL;
- d->tmp = IRTemp_INVALID;
- d->mFx = Ifx_None;
- d->mAddr = NULL;
- d->mSize = 0;
- d->nFxState = 0;
+ IRDirty* d = LibVEX_Alloc_inline(sizeof(IRDirty));
+ d->cee = NULL;
+ d->guard = NULL;
+ d->args = NULL;
+ d->tmp.id = IRTyEnvID_INVALID;
+ d->tmp.index = IRTyEnvIndex_INVALID;
+ d->mFx = Ifx_None;
+ d->mAddr = NULL;
+ d->mSize = 0;
+ d->nFxState = 0;
return d;
}
@@ -2131,6 +2171,24 @@
/* Constructors -- IRStmt */
+IRPhi* mkIRPhi(IRTemp dst, IRTemp srcThen, IRTemp srcElse)
+{
+ IRPhi* phi = LibVEX_Alloc_inline(sizeof(IRPhi));
+ phi->dst = dst;
+ phi->srcThen = srcThen;
+ phi->srcElse = srcElse;
+ return phi;
+}
+
+IRPhiVec* emptyIRPhiVec(void)
+{
+ IRPhiVec* vec = LibVEX_Alloc_inline(sizeof(IRPhiVec));
+ vec->phis_used = 0;
+ vec->phis_size = 8;
+ vec->phis = LibVEX_Alloc_inline(vec->phis_size * sizeof(IRPhi*));
+ return vec;
+}
+
IRStmt* IRStmt_NoOp ( void )
{
/* Just use a single static closure. */
@@ -2239,6 +2297,18 @@
return s;
}
+IRStmt* IRStmt_IfThenElse(IRExpr* cond, IRStmtVec* then_leg,
+ IRStmtVec* else_leg, IRPhiVec* phi_nodes)
+{
+ IRStmt* s = LibVEX_Alloc_inline(sizeof(IRStmt));
+ s->tag = Ist_IfThenElse;
+ s->Ist.IfThenElse.cond = cond;
+ s->Ist.IfThenElse.then_leg = then_leg;
+ s->Ist.IfThenElse.else_leg = else_leg;
+ s->Ist.IfThenElse.phi_nodes = phi_nodes;
+ return s;
+}
+
/* Constructors -- IRTypeEnv */
@@ -2248,31 +2318,54 @@
env->types = LibVEX_Alloc_inline(8 * sizeof(IRType));
env->types_size = 8;
env->types_used = 0;
+ env->id = IRTyEnvID_INVALID;
return env;
}
+/* Constructors -- IRStmtVec */
+
+IRStmtVec* emptyIRStmtVec(void)
+{
+ IRStmtVec* stmts = LibVEX_Alloc_inline(sizeof(IRStmtVec));
+ stmts->tyenv = emptyIRTypeEnv();
+ stmts->stmts_used = 0;
+ stmts->stmts_size = 8;
+ stmts->stmts = LibVEX_Alloc_inline(stmts->stmts_size * sizeof(IRStmt*));
+ stmts->parent = NULL;
+ return stmts;
+}
+
+
/* Constructors -- IRSB */
IRSB* emptyIRSB ( void )
{
- IRSB* bb = LibVEX_Alloc_inline(sizeof(IRSB));
- bb->tyenv = emptyIRTypeEnv();
- bb->stmts_used = 0;
- bb->stmts_size = 8;
- bb->stmts = LibVEX_Alloc_inline(bb->stmts_size * sizeof(IRStmt*));
- bb->next = NULL;
- bb->jumpkind = Ijk_Boring;
- bb->offsIP = 0;
+ IRSB* bb = LibVEX_Alloc_inline(sizeof(IRSB));
+ bb->stmts = emptyIRStmtVec();
+ bb->id_seq = 0;
+ bb->next = NULL;
+ bb->jumpkind = Ijk_Boring;
+ bb->offsIP = 0;
+
+ bb->stmts->tyenv->id = nextIRTyEnvID(bb);
return bb;
}
+IRTyEnvID nextIRTyEnvID(IRSB* irsb)
+{
+ IRTyEnvID next = irsb->id_seq;
+ irsb->id_seq += 1;
+ vassert(irsb->id_seq < IRTyEnvID_INVALID);
+ return next;
+}
-/*---------------------------------------------------------------*/
-/*--- (Deep) copy constructors. These make complete copies ---*/
-/*--- the original, which can be modified without affecting ---*/
-/*--- the original. ---*/
-/*---------------------------------------------------------------*/
+
+/*----------------------------------------------------------------*/
+/*--- (Deep) copy constructors. These make complete copies ---*/
+/*--- of the original, which can be modified without affecting ---*/
+/*--- the original. ---*/
+/*----------------------------------------------------------------*/
/* Copying IR Expr vectors (for call args). */
@@ -2437,7 +2530,27 @@
deepCopyIRExpr(puti->data));
}
-IRStmt* deepCopyIRStmt ( const IRStmt* s )
+IRPhi* deepCopyIRPhi(const IRPhi* phi)
+{
+ return mkIRPhi(phi->dst, phi->srcThen, phi->srcElse);
+}
+
+IRPhiVec* deepCopyIRPhiVec(const IRPhiVec* vec)
+{
+ if (vec == NULL) {
+ return NULL;
+ }
+
+ IRPhiVec* vec2 = LibVEX_Alloc_inline(sizeof(IRPhiVec));
+ vec2->phis_used = vec2->phis_size = vec->phis_used;
+ IRPhi **phis2 = LibVEX_Alloc_inline(vec2->phis_used * sizeof(IRPhi*));
+ for (UInt i = 0; i < vec2->phis_used; i++)
+ phis2[i] = deepCopyIRPhi(vec->phis[i]);
+ vec2->phis = phis2;
+ return vec2;
+}
+
+IRStmt* deepCopyIRStmt(const IRStmt* s, IRStmtVec* parent)
{
switch (s->tag) {
case Ist_NoOp:
@@ -2494,43 +2607,59 @@
s->Ist.Exit.jk,
deepCopyIRConst(s->Ist.Exit.dst),
s->Ist.Exit.offsIP);
+ case Ist_IfThenElse:
+ return IRStmt_IfThenElse(deepCopyIRExpr(s->Ist.IfThenElse.cond),
+ deepCopyIRStmtVec(s->Ist.IfThenElse.then_leg, parent),
+ deepCopyIRStmtVec(s->Ist.IfThenElse.else_leg, parent),
+ deepCopyIRPhiVec(s->Ist.IfThenElse.phi_nodes));
default:
vpanic("deepCopyIRStmt");
}
}
-IRTypeEnv* deepCopyIRTypeEnv ( const IRTypeEnv* src )
+IRStmtVec* deepCopyIRStmtVec(const IRStmtVec* src, IRStmtVec* parent)
{
- Int i;
- IRTypeEnv* dst = LibVEX_Alloc_inline(sizeof(IRTypeEnv));
+ IRStmtVec* vec2 = LibVEX_Alloc_inline(sizeof(IRStmtVec));
+ vec2->tyenv = deepCopyIRTypeEnv(src->tyenv);
+ vec2->parent = parent;
+ vec2->stmts_used = vec2->stmts_size = src->stmts_used;
+ IRStmt **stmts2 = LibVEX_Alloc_inline(vec2->stmts_used * sizeof(IRStmt*));
+ for (UInt i = 0; i < vec2->stmts_used; i++) {
+ stmts2[i] = deepCopyIRStmt(src->stmts[i], vec2);
+ }
+ vec2->stmts = stmts2;
+ return vec2;
+}
+
+IRTypeEnv* deepCopyIRTypeEnv(const IRTypeEnv* src)
+{
+ IRTypeEnv* dst = LibVEX_Alloc_inline(sizeof(IRTypeEnv));
dst->types_size = src->types_size;
dst->types_used = src->types_used;
- dst->types = LibVEX_Alloc_inline(dst->types_size * sizeof(IRType));
- for (i = 0; i < src->types_used; i++)
+ dst->types = LibVEX_Alloc_inline(dst->types_size * sizeof(IRType));
+ for (UInt i = 0; i < src->types_used; i++)
dst->types[i] = src->types[i];
+ dst->id = src->id;
return dst;
}
IRSB* deepCopyIRSB ( const IRSB* bb )
{
- Int i;
- IRStmt** sts2;
IRSB* bb2 = deepCopyIRSBExceptStmts(bb);
- bb2->stmts_used = bb2->stmts_size = bb->stmts_used;
- sts2 = LibVEX_Alloc_inline(bb2->stmts_used * sizeof(IRStmt*));
- for (i = 0; i < bb2->stmts_used; i++)
- sts2[i] = deepCopyIRStmt(bb->stmts[i]);
- bb2->stmts = sts2;
+ // TODO-JIT: does a deep copy of bb->stmts->tyenv once more
+ bb2->stmts = deepCopyIRStmtVec(bb->stmts, NULL);
return bb2;
}
IRSB* deepCopyIRSBExceptStmts ( const IRSB* bb )
{
- IRSB* bb2 = emptyIRSB();
- bb2->tyenv = deepCopyIRTypeEnv(bb->tyenv);
- bb2->next = deepCopyIRExpr(bb->next);
- bb2->jumpkind = bb->jumpkind;
- bb2->offsIP = bb->offsIP;
+ IRSB* bb2 = emptyIRSB();
+ bb2->stmts = emptyIRStmtVec();
+ bb2->stmts->tyenv = deepCopyIRTypeEnv(bb->stmts->tyenv);
+ bb2->id_seq = bb->id_seq;
+ bb2->next = deepCopyIRExpr(bb->next);
+ bb2->jumpkind = bb->jumpkind;
+ bb2->offsIP = bb->offsIP;
return bb2;
}
@@ -3543,22 +3672,54 @@
/*---------------------------------------------------------------*/
+/*--- Helper functions for the IR -- IR Phi Nodes ---*/
+/*---------------------------------------------------------------*/
+
+void addIRPhi(IRStmt* st, IRPhi* phi)
+{
+ vassert(st->tag == Ist_IfThenElse);
+
+ IRPhiVec* phi_nodes = st->Ist.IfThenElse.phi_nodes;
+ if (phi_nodes == NULL) {
+ phi_nodes = emptyIRPhiVec();
+ st->Ist.IfThenElse.phi_nodes = phi_nodes;
+ }
+
+ if (phi_nodes->phis_used == phi_nodes->phis_size) {
+ IRPhi** phis2 = LibVEX_Alloc_inline(2 * phi_nodes->phis_size * sizeof(IRPhi*));
+ for (UInt i = 0; i < phi_nodes->phis_size; i++)
+ phis2[i] = phi_nodes->phis[i];
+ phi_nodes->phis = phis2;
+ phi_nodes->phis_size *= 2;
+ }
+
+ vassert(phi_nodes->phis_used < phi_nodes->phis_size);
+ phi_nodes->phis[phi_nodes->phis_used] = phi;
+ phi_nodes->phis_used += 1;
+}
+
+
+/*---------------------------------------------------------------*/
/*--- Helper functions for the IR -- IR Basic Blocks ---*/
/*---------------------------------------------------------------*/
+void addStmtToIRStmtVec(IRStmtVec* stmts, IRStmt* st)
+{
+ if (stmts->stmts_used == stmts->stmts_size) {
+ IRStmt** stmts2 = LibVEX_Alloc_inline(2 * stmts->stmts_size * sizeof(IRStmt*));
+ for (UInt i = 0; i < stmts->stmts_size; i++)
+ stmts2[i] = stmts->stmts[i];
+ stmts->stmts = stmts2;
+ stmts->stmts_size *= 2;
+ }
+ vassert(stmts->stmts_used < stmts->stmts_size);
+ stmts->stmts[stmts->stmts_used] = st;
+ stmts->stmts_used++;
+}
+
void addStmtToIRSB ( IRSB* bb, IRStmt* st )
{
- Int i;
- if (bb->stmts_used == bb->stmts_size) {
- IRStmt** stmts2 = LibVEX_Alloc_inline(2 * bb->stmts_size * sizeof(IRStmt*));
- for (i = 0; i < bb->stmts_size; i++)
- stmts2[i] = bb->stmts[i];
- bb->stmts = stmts2;
- bb->stmts_size *= 2;
- }
- vassert(bb->stmts_used < bb->stmts_size);
- bb->stmts[bb->stmts_used] = st;
- bb->stmts_used++;
+ addStmtToIRStmtVec(bb->stmts, st);
}
@@ -3574,9 +3735,12 @@
vassert(env->types_used >= 0);
vassert(env->types_size >= 0);
vassert(env->types_used <= env->types_size);
+ vassert(env->id != IRTyEnvID_INVALID);
+
if (env->types_used < env->types_size) {
env->types[env->types_used] = ty;
- return env->types_used++;
+ IRTemp tmp = {env->id, env->types_used++};
+ return tmp;
} else {
Int i;
Int new_size = env->types_size==0 ? 8 : 2*env->types_size;
@@ -3598,9 +3762,9 @@
inline
IRType typeOfIRTemp ( const IRTypeEnv* env, IRTemp tmp )
{
- vassert(tmp >= 0);
- vassert(tmp < env->types_used);
- return env->types[tmp];
+ vassert(tmp.index >= 0);
+ vassert(tmp.index < env->types_used);
+ return env->types[tmp.index];
}
IRType typeOfIRConst ( const IRConst* con )
@@ -3729,6 +3893,9 @@
return UNLIKELY(is_IRExpr_VECRET_or_GSPTR(e));
}
+static Bool isFlatIRStmtVec(const IRStmtVec* stmts);
+
+static
Bool isFlatIRStmt ( const IRStmt* st )
{
Int i;
@@ -3828,11 +3995,25 @@
return True;
case Ist_Exit:
return isIRAtom(st->Ist.Exit.guard);
+ case Ist_IfThenElse:
+ return isIRAtom(st->Ist.IfThenElse.cond)
+ && isFlatIRStmtVec(st->Ist.IfThenElse.then_leg)
+ && isFlatIRStmtVec(st->Ist.IfThenElse.else_leg);
default:
vpanic("isFlatIRStmt(st)");
}
}
+static
+Bool isFlatIRStmtVec(const IRStmtVec* stmts)
+{
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
+ if (!isFlatIRStmt(stmts->stmts[i]))
+ return False;
+ }
+
+ return True;
+}
/*---------------------------------------------------------------*/
/*--- Sanity checking ---*/
@@ -3845,6 +4026,10 @@
bit expression, depending on the guest's word size.
Each temp is assigned only once, before its uses.
+ Each temp is referenced from the right scope.
+
+ Phi functions refer to existing, already assigned temporaries from
+ [parent, then leg, else leg] type environments.
*/
static inline Int countArgs ( IRExpr** args )
@@ -3903,74 +4088,107 @@
}
}
-/* Traverse a Stmt/Expr, inspecting IRTemp uses. Report any out of
- range ones. Report any which are read and for which the current
- def_count is zero. */
+/* Traverse a Stmt/Expr, inspecting IRTemp uses. Report any out of range or out
+ of scope ones. Report any which are read and for which the current
+ def_count is zero. Report any which are assigned more than once or assigned
+ after being used. */
+
+static Bool inRangeIRTemp(const IRStmtVec* stmts, IRTemp tmp)
+{
+ vassert(tmp.id != IRTyEnvID_INVALID);
+
+ if (tmp.index >= 0 || tmp.index < stmts->tyenv->types_used) {
+ return True;
+ }
+ return False;
+}
+
+static Bool inScopeIRTemp(const IRStmtVec* stmts, IRTemp tmp)
+{
+ vassert(tmp.id != IRTyEnvID_INVALID);
+
+ if (stmts->tyenv->id == tmp.id) {
+ return True;
+ }
+ if (stmts->parent != NULL) {
+ return inScopeIRTemp(stmts->parent, tmp);
+ }
+ return False;
+}
static
-void useBeforeDef_Temp ( const IRSB* bb, const IRStmt* stmt, IRTemp tmp,
- Int* def_counts )
+void useBeforeDef_Temp(const IRSB* bb, const IRStmtVec* stmts,
+ const IRStmt* stmt, IRTemp tmp, UInt* def_counts[])
{
- if (tmp < 0 || tmp >= bb->tyenv->types_used)
- sanityCheckFail(bb,stmt, "out of range Temp in IRExpr");
- if (def_counts[tmp] < 1)
- sanityCheckFail(bb,stmt, "IRTemp use before def in IRExpr");
+ vassert(tmp.id != IRTyEnvID_INVALID);
+
+ if (!inRangeIRTemp(stmts, tmp))
+ sanityCheckFail(bb, stmt, "out of range Temp in IRExpr");
+ if (!inScopeIRTemp(stmts, tmp))
+ sanityCheckFail(bb, stmt, "out of scope Temp in IRExpr");
+ if (def_counts[tmp.id][tmp.index] < 1)
+ sanityCheckFail(bb, stmt, "IRTemp use before def in IRExpr");
}
static
-void assignedOnce_Temp(const IRSB *bb, const IRStmt *stmt, IRTemp tmp,
- Int *def_counts, UInt n_def_counts,
- const HChar *err_msg_out_of_range,
- const HChar *err_msg_assigned_more_than_once)
+void assignedOnce_Temp(const IRSB* bb, const IRStmtVec* stmts,
+ const IRStmt* stmt, IRTemp tmp, UInt* def_counts[],
+ const HChar* err_msg_out_of_range,
+ const HChar* err_msg_out_of_scope,
+ const HChar* err_msg_assigned_more_than_once)
{
- if (tmp < 0 || tmp >= n_def_counts) {
+ vassert(tmp.id != IRTyEnvID_INVALID);
+
+ if (!inRangeIRTemp(stmts, tmp))
sanityCheckFail(bb, stmt, err_msg_out_of_range);
- }
+ if (!inScopeIRTemp(stmts, tmp))
+ sanityCheckFail(bb, stmt, err_msg_out_of_scope);
- def_counts[tmp]++;
- if (def_counts[tmp] > 1) {
- sanityCheckFail(bb, stmt, err_msg_assigned_more_than_once);
+ def_counts[tmp.id][tmp.index]++;
+ if (def_counts[tmp.id][tmp.index] > 1) {
+ sanityCheckFail(bb,stmt,err_msg_assigned_more_than_once);
}
}
static
-void useBeforeDef_Expr ( const IRSB* bb, const IRStmt* stmt,
- const IRExpr* expr, Int* def_counts )
+void useBeforeDef_Expr(const IRSB *bb, const IRStmtVec* stmts,
+ const IRStmt* stmt, const IRExpr* expr,
+ UInt* def_counts[])
{
Int i;
switch (expr->tag) {
case Iex_Get:
break;
case Iex_GetI:
- useBeforeDef_Expr(bb,stmt,expr->Iex.GetI.ix,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.GetI.ix, def_counts);
break;
case Iex_RdTmp:
- useBeforeDef_Temp(bb,stmt,expr->Iex.RdTmp.tmp,def_counts);
+ useBeforeDef_Temp(bb, stmts, stmt, expr->Iex.RdTmp.tmp, def_counts);
break;
case Iex_Qop: {
const IRQop* qop = expr->Iex.Qop.details;
- useBeforeDef_Expr(bb,stmt,qop->arg1,def_counts);
- useBeforeDef_Expr(bb,stmt,qop->arg2,def_counts);
- useBeforeDef_Expr(bb,stmt,qop->arg3,def_counts);
- useBeforeDef_Expr(bb,stmt,qop->arg4,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, qop->arg1, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, qop->arg2, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, qop->arg3, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, qop->arg4, def_counts);
break;
}
case Iex_Triop: {
const IRTriop* triop = expr->Iex.Triop.details;
- useBeforeDef_Expr(bb,stmt,triop->arg1,def_counts);
- useBeforeDef_Expr(bb,stmt,triop->arg2,def_counts);
- useBeforeDef_Expr(bb,stmt,triop->arg3,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, triop->arg1, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, triop->arg2, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, triop->arg3, def_counts);
break;
}
case Iex_Binop:
- useBeforeDef_Expr(bb,stmt,expr->Iex.Binop.arg1,def_counts);
- useBeforeDef_Expr(bb,stmt,expr->Iex.Binop.arg2,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.Binop.arg1, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.Binop.arg2, def_counts);
break;
case Iex_Unop:
- useBeforeDef_Expr(bb,stmt,expr->Iex.Unop.arg,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.Unop.arg, def_counts);
break;
case Iex_Load:
- useBeforeDef_Expr(bb,stmt,expr->Iex.Load.addr,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.Load.addr, def_counts);
break;
case Iex_Const:
break;
@@ -3981,16 +4199,17 @@
/* These aren't allowed in CCall lists. Let's detect
and throw them out here, though, rather than
segfaulting a bit later on. */
- sanityCheckFail(bb,stmt, "IRExprP__* value in CCall arg list");
+ sanityCheckFail(bb,stmt,
+ "IRExprP__* value in CCall arg list");
} else {
- useBeforeDef_Expr(bb,stmt,arg,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, arg, def_counts);
}
}
break;
case Iex_ITE:
- useBeforeDef_Expr(bb,stmt,expr->Iex.ITE.cond,def_counts);
- useBeforeDef_Expr(bb,stmt,expr->Iex.ITE.iftrue,def_counts);
- useBeforeDef_Expr(bb,stmt,expr->Iex.ITE.iffalse,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.ITE.cond, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.ITE.iftrue, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, expr->Iex.ITE.iffalse, def_counts);
break;
default:
vpanic("useBeforeDef_Expr");
@@ -3998,7 +4217,40 @@
}
static
-void useBeforeDef_Stmt ( const IRSB* bb, const IRStmt* stmt, Int* def_counts )
+void useBeforeDef_PhiNodes(const IRSB* bb, const IRStmtVec* stmts,
+ const IRStmt* stmt, const IRPhiVec* phi_nodes,
+ UInt* def_counts[])
+{
+ vassert(stmt->tag == Ist_IfThenElse);
+
+ for (UInt i = 0; i < phi_nodes->phis_used; i++) {
+ const IRPhi* phi = phi_nodes->phis[i];
+ useBeforeDef_Temp(bb, stmts, stmt, phi->srcThen, def_counts);
+ useBeforeDef_Temp(bb, stmts, stmt, phi->srcElse, def_counts);
+
+ /* Check also that referenced IRStmtVec's actually exist and belong to
+ "parent", "then", and "else", respectively. */
+ if (phi->dst.id != stmts->tyenv->id) {
+ sanityCheckFail(bb,stmt,"Istmt.IfThenElse.Phi.dst does not "
+ "reference parent IRStmtVec");
+ }
+ if (phi->srcThen.id != stmt->Ist.IfThenElse.then_leg->tyenv->id) {
+ sanityCheckFail(bb,stmt,"Istmt.IfThenElse.Phi.srcThen does not "
+ "reference \"then\" IRStmtVec leg");
+ }
+ if (phi->srcElse.id != stmt->Ist.IfThenElse.else_leg->tyenv->id) {
+ sanityCheckFail(bb,stmt,"Istmt.IfThenElse.Phi.srcElse does not "
+ "reference \"else\" IRStmtVec leg");
+ }
+ }
+}
+
+static void useBeforeDef_Stmts(const IRSB* bb, const IRStmtVec* stmts,
+ UInt* def_counts[]);
+
+static
+void useBeforeDef_Stmt(const IRSB* bb, const IRStmtVec* stmts,
+ const IRStmt* stmt, UInt* def_counts[])
{
Int i;
const IRDirty* d;
@@ -4010,50 +4262,51 @@
case Ist_IMark:
break;
case Ist_AbiHint:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.AbiHint.base,def_counts);
- useBeforeDef_Expr(bb,stmt,stmt->Ist.AbiHint.nia,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.AbiHint.base, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.AbiHint.nia, def_counts);
break;
case Ist_Put:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.Put.data,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.Put.data, def_counts);
break;
case Ist_PutI:
puti = stmt->Ist.PutI.details;
- useBeforeDef_Expr(bb,stmt,puti->ix,def_counts);
- useBeforeDef_Expr(bb,stmt,puti->data,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, puti->ix, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, puti->data, def_counts);
break;
case Ist_WrTmp:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.WrTmp.data,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.WrTmp.data, def_counts);
break;
case Ist_Store:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.Store.addr,def_counts);
- useBeforeDef_Expr(bb,stmt,stmt->Ist.Store.data,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.Store.addr, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.Store.data, def_counts);
break;
case Ist_StoreG:
sg = stmt->Ist.StoreG.details;
- useBeforeDef_Expr(bb,stmt,sg->addr,def_counts);
- useBeforeDef_Expr(bb,stmt,sg->data,def_counts);
- useBeforeDef_Expr(bb,stmt,sg->guard,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, sg->addr, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, sg->data, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, sg->guard, def_counts);
break;
case Ist_LoadG:
lg = stmt->Ist.LoadG.details;
- useBeforeDef_Expr(bb,stmt,lg->addr,def_counts);
- useBeforeDef_Expr(bb,stmt,lg->alt,def_counts);
- useBeforeDef_Expr(bb,stmt,lg->guard,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, lg->addr, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, lg->alt, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, lg->guard, def_counts);
break;
case Ist_CAS:
cas = stmt->Ist.CAS.details;
- useBeforeDef_Expr(bb,stmt,cas->addr,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, cas->addr, def_counts);
if (cas->expdHi)
- useBeforeDef_Expr(bb,stmt,cas->expdHi,def_counts);
- useBeforeDef_Expr(bb,stmt,cas->expdLo,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, cas->expdHi, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, cas->expdLo, def_counts);
if (cas->dataHi)
- useBeforeDef_Expr(bb,stmt,cas->dataHi,def_counts);
- useBeforeDef_Expr(bb,stmt,cas->dataLo,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, cas->dataHi, def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, cas->dataLo, def_counts);
break;
case Ist_LLSC:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.LLSC.addr,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.LLSC.addr, def_counts);
if (stmt->Ist.LLSC.storedata != NULL)
- useBeforeDef_Expr(bb,stmt,stmt->Ist.LLSC.storedata,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.LLSC.storedata,
+ def_counts);
break;
case Ist_Dirty:
d = stmt->Ist.Dirty.details;
@@ -4063,17 +4316,27 @@
/* This is ensured by isFlatIRStmt */
;
} else {
- useBeforeDef_Expr(bb,stmt,arg,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, arg, def_counts);
}
}
if (d->mFx != Ifx_None)
- useBeforeDef_Expr(bb,stmt,d->mAddr,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, d->mAddr, def_counts);
break;
case Ist_NoOp:
case Ist_MBE:
break;
case Ist_Exit:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.Exit.guard,def_counts);
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.Exit.guard, def_counts);
+ break;
+ case Ist_IfThenElse:
+ useBeforeDef_Expr(bb, stmts, stmt, stmt->Ist.IfThenElse.cond,
+ def_counts);
+ useBeforeDef_Stmts(bb, stmt->Ist.IfThenElse.then_leg, def_counts);
+ useBeforeDef_Stmts(bb, stmt->Ist.IfThenElse.else_leg, def_counts);
+ if (stmt->Ist.IfThenElse.phi_nodes != NULL) {
+ useBeforeDef_PhiNodes(bb, stmts, stmt,
+ stmt->Ist.IfThenElse.phi_nodes, def_counts);
+ }
break;
default:
vpanic("useBeforeDef_Stmt");
@@ -4081,48 +4344,81 @@
}
static
-void assignedOnce_Stmt(const IRSB *bb, const IRStmt *stmt,
- Int *def_counts, UInt n_def_counts)
+void useBeforeDef_Stmts(const IRSB* bb, const IRStmtVec* stmts,
+ UInt* def_counts[])
+{
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
+ useBeforeDef_Stmt(bb, stmts, stmts->stmts[i], def_counts);
+ }
+}
+
+static void assignedOnce_Stmts(const IRSB* bb, const IRStmtVec* stmts,
+ UInt* def_counts[]);
+
+static
+void assignedOnce_Stmt(const IRSB* bb, const IRStmtVec* stmts,
+ const IRStmt* stmt, UInt* def_counts[])
{
switch (stmt->tag) {
case Ist_WrTmp:
assignedOnce_Temp(
- bb, stmt, stmt->Ist.WrTmp.tmp, def_counts, n_def_counts,
+ bb, stmts, stmt, stmt->Ist.WrTmp.tmp, def_counts,
"IRStmt.Tmp: destination tmp is out of range",
+ "IRStmt.Tmp: destination tmp is out of scope",
"IRStmt.Tmp: destination tmp is assigned more than once");
break;
case Ist_LoadG:
assignedOnce_Temp(
- bb, stmt, stmt->Ist.LoadG.details->dst, def_counts, n_def_counts,
+ bb, stmts, stmt, stmt->Ist.LoadG.details->dst, def_counts,
"IRStmt.LoadG: destination tmp is out of range",
+ "IRStmt.LoadG: destination tmp is out of scope",
"IRStmt.LoadG: destination tmp is assigned more than once");
break;
case Ist_Dirty:
- if (stmt->Ist.Dirty.details->tmp != IRTemp_INVALID) {
+ if (!isIRTempInvalid(stmt->Ist.Dirty.details->tmp)) {
assignedOnce_Temp(
- bb, stmt, stmt->Ist.Dirty.details->tmp, def_counts, n_def_counts,
+ bb, stmts, stmt, stmt->Ist.Dirty.details->tmp, def_counts,
"IRStmt.Dirty: destination tmp is out of range",
+ "IRStmt.Dirty: destination tmp is out of scope",
"IRStmt.Dirty: destination tmp is assigned more than once");
}
break;
case Ist_CAS:
- if (stmt->Ist.CAS.details->oldHi != IRTemp_INVALID) {
+ if (!isIRTempInvalid(stmt->Ist.CAS.details->oldHi)) {
assignedOnce_Temp(
- bb, stmt, stmt->Ist.CAS.details->oldHi, def_counts, n_def_counts,
+ bb, stmts, stmt, stmt->Ist.CAS.details->oldHi, def_counts,
"IRStmt.CAS: destination tmpHi is out of range",
+ "IRStmt.CAS: destination tmpHi is out of scope",
"IRStmt.CAS: destination tmpHi is assigned more than once");
}
assignedOnce_Temp(
- bb, stmt, stmt->Ist.CAS.details->oldLo, def_counts, n_def_counts,
+ bb, stmts, stmt, stmt->Ist.CAS.details->oldLo, def_counts,
"IRStmt.CAS: destination tmpLo is out of range",
+ "IRStmt.CAS: destination tmpLo is out of scope",
"IRStmt.CAS: destination tmpLo is assigned more than once");
break;
case Ist_LLSC:
assignedOnce_Temp(
- bb, stmt, stmt->Ist.LLSC.result, def_counts, n_def_counts,
+ bb, stmts, stmt, stmt->Ist.LLSC.result, def_counts,
"IRStmt.LLSC: destination tmp is out of range",
+ "IRStmt.LLSC: destination tmp is out of scope",
"IRStmt.LLSC: destination tmp is assigned more than once");
break;
+ case Ist_IfThenElse: {
+ assignedOnce_Stmts(bb, stmt->Ist.IfThenElse.then_leg, def_counts);
+ assignedOnce_Stmts(bb, stmt->Ist.IfThenElse.else_leg, def_counts);
+ const IRPhiVec* phi_nodes = stmt->Ist.IfThenElse.phi_nodes;
+ if (phi_nodes != NULL) {
+ for (UInt i = 0; i < phi_nodes->phis_used; i++) {
+ assignedOnce_Temp(
+ bb, stmts, stmt, phi_nodes->phis[i]->dst, def_counts,
+ "IRStmt.IfThenElse.Phi: destination tmp is out of range",
+ "IRStmt.IfThenElse.Phi: destination tmp is out of scope",
+ "IRStmt.IfThenElse: destination tmp is assigned more than once");
+ }
+ }
+ break;
+ }
// Ignore all other cases
case Ist_NoOp: case Ist_IMark: case Ist_AbiHint: case Ist_Put: case Ist_PutI:
case Ist_Store: case Ist_StoreG: case Ist_MBE: case Ist_Exit:
@@ -4133,18 +4429,27 @@
}
static
-void tcExpr ( const IRSB* bb, const IRStmt* stmt, const IRExpr* expr,
- IRType gWordTy )
+void assignedOnce_Stmts(const IRSB* bb, const IRStmtVec* stmts,
+ UInt* def_counts[])
+{
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
+ assignedOnce_Stmt(bb, stmts, stmts->stmts[i], def_counts);
+ }
+}
+
+static
+void tcExpr(const IRSB* bb, const IRStmtVec* stmts, const IRStmt* stmt,
+ const IRExpr* expr, IRType gWordTy)
{
Int i;
IRType t_dst, t_arg1, t_arg2, t_arg3, t_arg4;
- const IRTypeEnv* tyenv = bb->tyenv;
+ const IRTypeEnv* tyenv = stmts->tyenv;
switch (expr->tag) {
case Iex_Get:
case Iex_RdTmp:
break;
case Iex_GetI:
- tcExpr(bb,stmt, expr->Iex.GetI.ix, gWordTy );
+ tcExpr(bb, stmts, stmt, expr->Iex.GetI.ix, gWordTy);
if (typeOfIRExpr(tyenv,expr->Iex.GetI.ix) != Ity_I32)
sanityCheckFail(bb,stmt,"IRExpr.GetI.ix: not :: Ity_I32");
if (!saneIRRegArray(expr->Iex.GetI.descr))
@@ -4153,10 +4458,10 @@
case Iex_Qop: {
IRType ttarg1, ttarg2, ttarg3, ttarg4;
const IRQop* qop = expr->Iex.Qop.details;
- tcExpr(bb,stmt, qop->arg1, gWordTy );
- tcExpr(bb,stmt, qop->arg2, gWordTy );
- tcExpr(bb,stmt, qop->arg3, gWordTy );
- tcExpr(bb,stmt, qop->arg4, gWordTy );
+ tcExpr(bb, stmts, stmt, qop->arg1, gWordTy);
+ tcExpr(bb, stmts, stmt, qop->arg2, gWordTy);
+ tcExpr(bb, stmts, stmt, qop->arg3, gWordTy);
+ tcExpr(bb, stmts, stmt, qop->arg4, gWordTy);
typeOfPrimop(qop->op,
&t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID
@@ -4205,9 +4510,9 @@
case Iex_Triop: {
IRType ttarg1, ttarg2, ttarg3;
const IRTriop *triop = expr->Iex.Triop.details;
- tcExpr(bb,stmt, triop->arg1, gWordTy );
- tcExpr(bb,stmt, triop->arg2, gWordTy );
- tcExpr(bb,stmt, triop->arg3, gWordTy );
+ tcExpr(bb, stmts, stmt, triop->arg1, gWordTy);
+ tcExpr(bb, stmts, stmt, triop->arg2, gWordTy);
+ tcExpr(bb, stmts, stmt, triop->arg3, gWordTy);
typeOfPrimop(triop->op,
&t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID
@@ -4249,8 +4554,8 @@
}
case Iex_Binop: {
IRType ttarg1, ttarg2;
- tcExpr(bb,stmt, expr->Iex.Binop.arg1, gWordTy );
- tcExpr(bb,stmt, expr->Iex.Binop.arg2, gWordTy );
+ tcExpr(bb, stmts, stmt, expr->Iex.Binop.arg1, gWordTy);
+ tcExpr(bb, stmts, stmt, expr->Iex.Binop.arg2, gWordTy);
typeOfPrimop(expr->Iex.Binop.op,
&t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID
@@ -4286,7 +4591,7 @@
break;
}
case Iex_Unop:
- tcExpr(bb,stmt, expr->Iex.Unop.arg, gWordTy );
+ tcExpr(bb, stmts, stmt, expr->Iex.Unop.arg, gWordTy);
typeOfPrimop(expr->Iex.Unop.op,
&t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
if (t_arg1 == Ity_INVALID || t_arg2 != Ity_INVALID
@@ -4296,7 +4601,7 @@
sanityCheckFail(bb,stmt,"Iex.Unop: arg ty doesn't match op ty");
break;
case Iex_Load:
- tcExpr(bb,stmt, expr->Iex.Load.addr, gWordTy);
+ tcExpr(bb, stmts, stmt, expr->Iex.Load.addr, gWordTy);
if (typeOfIRExpr(tyenv, expr->Iex.Load.addr) != gWordTy)
sanityCheckFail(bb,stmt,"Iex.Load.addr: not :: guest word type");
if (expr->Iex.Load.end != Iend_LE && expr->Iex.Load.end != Iend_BE)
@@ -4313,10 +4618,11 @@
IRExpr* arg = expr->Iex.CCall.args[i];
if (UNLIKELY(is_IRExpr_VECRET_or_GSPTR(arg)))
sanityCheckFail(bb,stmt,"Iex.CCall.args: is VECRET/GSPTR");
- tcExpr(bb,stmt, arg, gWordTy);
+ tcExpr(bb, stmts, stmt, arg, gWordTy);
}
if (expr->Iex.CCall.retty == Ity_I1)
- sanityCheckFail(bb,stmt,"Iex.CCall.retty: cannot return :: Ity_I1");
+ sanityCheckFail(bb,stmt,
+ "Iex.CCall.retty: cannot return :: Ity_I1");
for (i = 0; expr->Iex.CCall.args[i]; i++)
if (typeOfIRExpr(tyenv, expr->Iex.CCall.args[i]) == Ity_I1)
sanityCheckFail(bb,stmt,"Iex.CCall.arg: arg :: Ity_I1");
@@ -4326,9 +4632,9 @@
sanityCheckFail(bb,stmt,"Iex.Const.con: invalid const");
break;
case Iex_ITE:
- tcExpr(bb,stmt, expr->Iex.ITE.cond, gWordTy);
- tcExpr(bb,stmt, expr->Iex.ITE.iftrue, gWordTy);
- tcExpr(bb,stmt, expr->Iex.ITE.iffalse, gWordTy);
+ tcExpr(bb, stmts, stmt, expr->Iex.ITE.cond, gWordTy);
+ tcExpr(bb, stmts, stmt, expr->Iex.ITE.iftrue, gWordTy);
+ tcExpr(bb, stmts, stmt, expr->Iex.ITE.iffalse, gWordTy);
if (typeOfIRExpr(tyenv, expr->Iex.ITE.cond) != Ity_I1)
sanityCheckFail(bb,stmt,"Iex.ITE.cond: cond :: Ity_I1");
if (typeOfIRExpr(tyenv, expr->Iex.ITE.iftrue)
@@ -4340,13 +4646,30 @@
}
}
+static
+void tcPhi(const IRSB* bb, const IRStmtVec* stmts, const IRStmt* stmt,
+ const IRPhi* phi)
+{
+ const IRTypeEnv* tyenv = stmts->tyenv;
+ if (typeOfIRTemp(tyenv, phi->srcThen) != typeOfIRTemp(tyenv, phi->srcElse)) {
+ sanityCheckFail(bb,stmt,"IRStmt.IfThenElse.Phi: 'then' and 'else' "
+ "tmp do not match");
+ }
+ if (typeOfIRTemp(tyenv, phi->dst) != typeOfIRTemp(tyenv, phi->srcThen)) {
+ sanityCheckFail(bb,stmt,"IRStmt.IfThenElse.Phi: 'dst' and 'then' "
+ "tmp do not match");
+ }
+}
+
+static void tcStmts(const IRSB* bb, const IRStmtVec* stmts, Bool require_flat,
+ IRType gWordTy);
static
-void tcStmt ( const IRSB* bb, const IRStmt* stmt, IRType gWordTy )
+void tcStmt(const IRSB* bb, const IRStmtVec* stmts, const IRStmt* stmt,
+ Bool require_flat, IRType gWordTy)
{
- Int i;
IRType tyExpd, tyData;
- const IRTypeEnv* tyenv = bb->tyenv;
+ const IRTypeEnv* tyenv = stmts->tyenv;
switch (stmt->tag) {
case Ist_IMark:
/* Somewhat heuristic, but rule out totally implausible
@@ -4365,18 +4688,18 @@
"not :: guest word type");
break;
case Ist_Put:
- tcExpr( bb, stmt, stmt->Ist.Put.data, gWordTy );
+ tcExpr(bb, stmts, stmt, stmt->Ist.Put.data, gWordTy);
if (typeOfIRExpr(tyenv,stmt->Ist.Put.data) == Ity_I1)
sanityCheckFail(bb,stmt,"IRStmt.Put.data: cannot Put :: Ity_I1");
break;
case Ist_PutI:{
const IRPutI* puti = stmt->Ist.PutI.details;
- tcExpr( bb, stmt, puti->data, gWordTy );
- tcExpr( bb, stmt, puti->ix, gWordTy );
+ tcExpr(bb, stmts, stmt, puti->data, gWordTy);
+ tcExpr(bb, stmts, stmt, puti->ix, gWordTy);
if (typeOfIRExpr(tyenv,puti->data) == Ity_I1)
- sanityCheckFail(bb,stmt,"IRStmt.PutI.data: cannot PutI :: Ity_I1");
- if (typeOfIRExpr(tyenv,puti->data)
- != puti->descr->elemTy)
+ sanityCheckFail(bb,stmt,
+ "IRStmt.PutI.data: cannot PutI :: Ity_I1");
+ if (typeOfIRExpr(tyenv,puti->data) != puti->descr->elemTy)
sanityCheckFail(bb,stmt,"IRStmt.PutI.data: data ty != elem ty");
if (typeOfIRExpr(tyenv,puti->ix) != Ity_I32)
sanityCheckFail(bb,stmt,"IRStmt.PutI.ix: not :: Ity_I32");
@@ -4385,15 +4708,15 @@
break;
}
case Ist_WrTmp:
- tcExpr( bb, stmt, stmt->Ist.WrTmp.data, gWordTy );
+ tcExpr(bb, stmts, stmt, stmt->Ist.WrTmp.data, gWordTy);
if (typeOfIRTemp(tyenv, stmt->Ist.WrTmp.tmp)
!= typeOfIRExpr(tyenv, stmt->Ist.WrTmp.data))
sanityCheckFail(bb,stmt,
"IRStmt.Put.Tmp: tmp and expr do not match");
break;
case Ist_Store:
- tcExpr( bb, stmt, stmt->Ist.Store.addr, gWordTy );
- tcExpr( bb, stmt, stmt->Ist.Store.data, gWordTy );
+ tcExpr(bb, stmts, stmt, stmt->Ist.Store.addr, gWordTy);
+ tcExpr(bb, stmts, stmt, stmt->Ist.Store.data, gWordTy);
if (typeOfIRExpr(tyenv, stmt->Ist.Store.addr) != gWordTy)
sanityCheckFail(bb,stmt,
"IRStmt.Store.addr: not :: guest word type");
@@ -4405,9 +4728,9 @@
break;
case Ist_StoreG: {
const IRStoreG* sg = stmt->Ist.StoreG.details;
- tcExpr( bb, stmt, sg->addr, gWordTy );
- tcExpr( bb, stmt, sg->data, gWordTy );
- tcExpr( bb, stmt, sg->guard, gWordTy );
+ tcExpr(bb, stmts, stmt, sg->addr, gWordTy);
+ tcExpr(bb, stmts, stmt, sg->data, gWordTy);
+ tcExpr(bb, stmts, stmt, sg->guard, gWordTy);
if (typeOfIRExpr(tyenv, sg->addr) != gWordTy)
sanityCheckFail(bb,stmt,"IRStmtG...addr: not :: guest word type");
if (typeOfIRExpr(tyenv, sg->data) == Ity_I1)
@@ -4420,9 +4743,9 @@
}
case Ist_LoadG: {
const IRLoadG* lg = stmt->Ist.LoadG.details;
- tcExpr( bb, stmt, lg->addr, gWordTy );
- tcExpr( bb, stmt, lg->alt, gWordTy );
- tcExpr( bb, stmt, lg->guard, gWordTy );
+ tcExpr(bb, stmts, stmt, lg->addr, gWordTy);
+ tcExpr(bb, stmts, stmt, lg->alt, gWordTy);
+ tcExpr(bb, stmts, stmt, lg->guard, gWordTy);
if (typeOfIRExpr(tyenv, lg->guard) != Ity_I1)
sanityCheckFail(bb,stmt,"IRStmt.LoadG.guard: not :: Ity_I1");
if (typeOfIRExpr(tyenv, lg->addr) != gWordTy)
@@ -4439,12 +4762,12 @@
case Ist_CAS: {
const IRCAS* cas = stmt->Ist.CAS.details;
/* make sure it's definitely either a CAS or a DCAS */
- if (cas->oldHi == IRTemp_INVALID
+ if (isIRTempInvalid(cas->oldHi)
&& cas->expdHi == NULL && cas->dataHi == NULL) {
/* fine; it's a single cas */
}
else
- if (cas->oldHi != IRTemp_INVALID
+ if (!isIRTempInvalid(cas->oldHi)
&& cas->expdHi != NULL && cas->dataHi != NULL) {
/* fine; it's a double cas */
}
@@ -4453,7 +4776,7 @@
goto bad_cas;
}
/* check the address type */
- tcExpr( bb, stmt, cas->addr, gWordTy );
+ tcExpr(bb, stmts, stmt, cas->addr, gWordTy);
if (typeOfIRExpr(tyenv, cas->addr) != gWordTy) goto bad_cas;
/* check types on the {old,expd,data}Lo components agree */
tyExpd = typeOfIRExpr(tyenv, cas->expdLo);
@@ -4470,7 +4793,7 @@
}
/* If it's a DCAS, check types on the {old,expd,data}Hi
components too */
- if (cas->oldHi != IRTemp_INVALID) {
+ if (!isIRTempInvalid(cas->oldHi)) {
tyExpd = typeOfIRExpr(tyenv, cas->expdHi);
tyData = typeOfIRExpr(tyenv, cas->dataHi);
if (tyExpd != tyData) goto bad_cas;
@@ -4526,7 +4849,7 @@
}
if (d->nFxState < 0 || d->nFxState > VEX_N_FXSTATE)
goto bad_dirty;
- for (i = 0; i < d->nFxState; i++) {
+ for (UInt i = 0; i < d->nFxState; i++) {
if (d->fxState[i].fx == Ifx_None) goto bad_dirty;
if (d->fxState[i].size <= 0) goto bad_dirty;
if (d->fxState[i].nRepeats == 0) {
@@ -4541,18 +4864,18 @@
}
/* check guard */
if (d->guard == NULL) goto bad_dirty;
- tcExpr( bb, stmt, d->guard, gWordTy );
+ tcExpr(bb, stmts, stmt, d->guard, gWordTy);
if (typeOfIRExpr(tyenv, d->guard) != Ity_I1)
sanityCheckFail(bb,stmt,"IRStmt.Dirty.guard not :: Ity_I1");
/* check types, minimally */
IRType retTy = Ity_INVALID;
- if (d->tmp != IRTemp_INVALID) {
+ if (!isIRTempInvalid(d->tmp)) {
retTy = typeOfIRTemp(tyenv, d->tmp);
if (retTy == Ity_I1)
sanityCheckFail(bb,stmt,"IRStmt.Dirty.dst :: Ity_I1");
}
UInt nVECRETs = 0, nGSPTRs = 0;
- for (i = 0; d->args[i] != NULL; i++) {
+ for (UInt i = 0; d->args[i] != NULL; i++) {
if (i >= 32)
sanityCheckFail(bb,stmt,"IRStmt.Dirty: > 32 args");
const IRExpr* arg = d->args[i];
@@ -4611,7 +4934,7 @@
}
break;
case Ist_Exit:
- tcExpr( bb, stmt, stmt->Ist.Exit.guard, gWordTy );
+ tcExpr(bb, stmts, stmt, stmt->Ist.Exit.guard, gWordTy);
if (typeOfIRExpr(tyenv,stmt->Ist.Exit.guard) != Ity_I1)
sanityCheckFail(bb,stmt,"IRStmt.Exit.guard: not :: Ity_I1");
if (!saneIRConst(stmt->Ist.Exit.dst))
@@ -4622,77 +4945,139 @@
if (stmt->Ist.Exit.offsIP < 16)
sanityCheckFail(bb,stmt,"IRStmt.Exit.offsIP: too low");
break;
+ case Ist_IfThenElse:
+ tcExpr(bb, stmts, stmt, stmt->Ist.IfThenElse.cond, gWordTy);
+ if (typeOfIRExpr(tyenv, stmt->Ist.IfThenElse.cond) != Ity_I1)
+ sanityCheckFail(bb,stmt,"IRStmt.IfThenElse.cond: not :: Ity_I1");
+ tcStmts(bb, stmt->Ist.IfThenElse.then_leg, require_flat, gWordTy);
+ tcStmts(bb, stmt->Ist.IfThenElse.else_leg, require_flat, gWordTy);
+ const IRPhiVec* phi_nodes = stmt->Ist.IfThenElse.phi_nodes;
+ if (phi_nodes != NULL) {
+ for (UInt i = 0; i < phi_nodes->phis_used; i++) {
+ tcPhi(bb, stmts, stmt, phi_nodes->phis[i]);
+ }
+ }
+ break;
default:
vpanic("tcStmt");
}
}
-void sanityCheckIRSB ( const IRSB* bb, const HChar* caller,
- Bool require_flat, IRType guest_word_size )
+static
+void tcStmts(const IRSB* bb, const IRStmtVec* stmts, Bool require_flat,
+ IRType gWordTy)
{
- Int i;
- Int n_temps = bb->tyenv->types_used;
- Int* def_counts = LibVEX_Alloc_inline(n_temps * sizeof(Int));
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
+ tcStmt(bb, stmts, stmts->stmts[i], require_flat, gWordTy);
+ }
+}
- if (0)
- vex_printf("sanityCheck: %s\n", caller);
+static
+void sanityCheckIRStmtVec(const IRSB* bb, const IRStmtVec* stmts,
+ Bool require_flat, UInt* def_counts[],
+ UInt n_stmt_vecs, UInt id_counts[])
+{
+ const IRTypeEnv* tyenv = stmts->tyenv;
+ IRTyEnvID id = tyenv->id;
+ if (id == IRTyEnvID_INVALID) {
+ vpanic("sanityCheckIRStmtVec: invalid IRTypeEnv ID");
+ }
+
+ if (id >= n_stmt_vecs) {
+ vex_printf("IRTypeEnv's ID (%u) is larger than number of IRStmtVec's "
+ "(%u)\n", id, n_stmt_vecs);
+ sanityCheckFail(bb, NULL, "IRTypeEnv's ID larger than number of "
+ "IRStmtVec's");
+ }
- vassert(guest_word_size == Ity_I32
- || guest_word_size == Ity_I64);
+ id_counts[id] += 1;
+ if (id_counts[id] > 1) {
+ sanityCheckFail(bb, NULL, "the same IRTyEnv ID used more than once");
+ }
+
+ UInt n_temps = tyenv->types_used;
+ def_counts[id] = LibVEX_Alloc_inline(n_temps * sizeof(UInt));
+ for (UInt i = 0; i < n_temps; i++)
+ def_counts[id][i] = 0;
- if (bb->stmts_used < 0 || bb->stmts_size < 8
- || bb->stmts_used > bb->stmts_size)
- /* this BB is so strange we can't even print it */
- vpanic("sanityCheckIRSB: stmts array limits wierd");
+ if (stmts->stmts_used < 0 || stmts->stmts_size < 8
+ || stmts->stmts_used > stmts->stmts_size) {
+ /* this IRStmtVec is so strange we can't even print it */
+ vpanic("sanityCheckIRStmtVec: stmts array limits wierd");
+ }
/* Ensure each temp has a plausible type. */
- for (i = 0; i < n_temps; i++) {
- IRType ty = typeOfIRTemp(bb->tyenv,(IRTemp)i);
+ for (UInt i = 0; i < n_temps; i++) {
+ IRTemp temp = {id, i};
+ IRType ty = typeOfIRTemp(tyenv, temp);
if (!isPlausibleIRType(ty)) {
- vex_printf("Temp t%d declared with implausible type 0x%x\n",
- i, (UInt)ty);
- sanityCheckFail(bb,NULL,"Temp declared with implausible type");
+ vex_printf("Temp ");
+ ppIRTemp(temp);
+ vex_printf(" declared with implausible type 0x%x\n", (UInt) ty);
+ sanityCheckFail(bb, NULL, "Temp declared with implausible type");
}
}
- const IRStmt* stmt;
-
/* Check for flatness, if required. */
if (require_flat) {
- for (i = 0; i < bb->stmts_used; i++) {
- stmt = bb->stmts[i];
- if (!stmt)
- sanityCheckFail(bb, stmt, "IRStmt: is NULL");
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
+ const IRStmt *stmt = stmts->stmts[i];
+ if (stmt == NULL)
+ sanityCheckFail(bb,stmt,"IRStmt: is NULL");
if (!isFlatIRStmt(stmt))
- sanityCheckFail(bb, stmt, "IRStmt: is not flat");
+ sanityCheckFail(bb,stmt,"IRStmt: is not flat");
+ if (stmt->tag == Ist_IfThenElse) {
+ sanityCheckIRStmtVec(bb, stmt->Ist.IfThenElse.then_leg,
+ require_flat, def_counts, n_stmt_vecs, id_counts);
+ sanityCheckIRStmtVec(bb, stmt->Ist.IfThenElse.else_leg,
+ require_flat, def_counts, n_stmt_vecs, id_counts);
+ }
}
- if (!isIRAtom(bb->next))
- sanityCheckFail(bb, NULL, "bb->next is not an atom");
}
+}
+
+
+/* Sanity checks basic block of IR.
+ Also checks for IRTyEnvID uniqueness. */
+void sanityCheckIRSB(const IRSB* bb, const HChar* caller, Bool require_flat,
+ IRType gWordTy)
+{
+ UInt n_stmt_vecs = bb->id_seq;
+ UInt **def_counts = LibVEX_Alloc_inline(n_stmt_vecs * sizeof(UInt *));
+ UInt *id_counts = LibVEX_Alloc_inline(n_stmt_vecs * sizeof(UInt));
+ for (UInt i = 0; i < n_stmt_vecs; i++) {
+ def_counts[i] = NULL;
+ id_counts[i] = 0;
+ }
+
+ if (0)
+ vex_printf("sanityCheck: %s\n", caller);
+
+ vassert(gWordTy == Ity_I32 || gWordTy == Ity_I64);
+
+ sanityCheckIRStmtVec(bb, bb->stmts, require_flat, def_counts, n_stmt_vecs,
+ id_counts);
/* Count the defs of each temp. Only one def is allowed.
Also, check that each used temp has already been defd. */
+ useBeforeDef_Stmts(bb, bb->stmts, def_counts);
+ assignedOnce_Stmts(bb, bb->stmts, def_counts);
+ tcStmts(bb, bb->stmts, require_flat, gWordTy);
- for (i = 0; i < n_temps; i++)
- def_counts[i] = 0;
+ if (require_flat) {
+ if (!isIRAtom(bb->next)) {
+ sanityCheckFail(bb, NULL, "bb->next is not an atom");
+ }
+ }
- for (i = 0; i < bb->stmts_used; i++) {
- stmt = bb->stmts[i];
- /* Check any temps used by this statement. */
- useBeforeDef_Stmt(bb,stmt,def_counts);
-
- /* Now make note of any temps defd by this statement. */
- assignedOnce_Stmt(bb, stmt, def_counts, n_temps);
- }
-
- /* Typecheck everything. */
- for (i = 0; i < bb->stmts_used; i++)
- tcStmt(bb, bb->stmts[i], guest_word_size);
- if (typeOfIRExpr(bb->tyenv,bb->next) != guest_word_size)
+ /* Typecheck also next destination. */
+ if (typeOfIRExpr(bb->stmts->tyenv, bb->next) != gWordTy) {
sanityCheckFail(bb, NULL, "bb->next field has wrong type");
+ }
/* because it would intersect with host_EvC_* */
- if (bb->offsIP < 16)
+ if (bb->offsIP < 16) {
sanityCheckFail(bb, NULL, "bb->offsIP: too low");
+ }
}
/*---------------------------------------------------------------*/
@@ -4805,7 +5190,7 @@
vassert(isIRAtom(a1));
vassert(isIRAtom(a2));
if (a1->tag == Iex_RdTmp && a2->tag == Iex_RdTmp)
- return toBool(a1->Iex.RdTmp.tmp == a2->Iex.RdTmp.tmp);
+ return eqIRTemp(a1->Iex.RdTmp.tmp, a2->Iex.RdTmp.tmp);
if (a1->tag == Iex_Const && a2->tag == Iex_Const)
return eqIRConst(a1->Iex.Const.con, a2->Iex.Const.con);
return False;
Modified: branches/VEX_JIT_HACKS/priv/ir_inject.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_inject.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_inject.c Sat Mar 11 14:07:07 2017
@@ -43,7 +43,7 @@
#define binop(kind, a1, a2) IRExpr_Binop(kind, a1, a2)
#define triop(kind, a1, a2, a3) IRExpr_Triop(kind, a1, a2, a3)
#define qop(kind, a1, a2, a3, a4) IRExpr_Qop(kind, a1, a2, a3, a4)
-#define stmt(irsb, st) addStmtToIRSB(irsb, st)
+#define stmt(irsb, st) addStmtToIRStmtVec(irsb->stmts, st)
/* The IR Injection Control Block. vex_inject_ir will query its contents
@@ -125,13 +125,13 @@
static void
store_aux(IRSB *irsb, IREndness endian, IRExpr *addr, IRExpr *data)
{
- if (typeOfIRExpr(irsb->tyenv, data) == Ity_D64) {
+ if (typeOfIRExpr(irsb->stmts->tyenv, data) == Ity_D64) {
/* The insn selectors do not support writing a DFP value to memory.
So we need to fix it here by reinterpreting the DFP value as an
integer and storing that. */
data = unop(Iop_ReinterpD64asI64, data);
}
- if (typeOfIRExpr(irsb->tyenv, data) == Ity_I1) {
+ if (typeOfIRExpr(irsb->stmts->tyenv, data) == Ity_I1) {
/* We cannot store a single bit. So we store it in a 32-bit container.
See also load_aux. */
data = unop(Iop_1Uto32, data);
@@ -158,7 +158,7 @@
vpanic("invalid #bytes for address");
}
- IRType type = typeOfIRExpr(irsb->tyenv, data);
+ IRType type = typeOfIRExpr(irsb->stmts->tyenv, data);
vassert(type == Ity_I1 || sizeofIRType(type) <= 16);
@@ -188,7 +188,7 @@
/* Inject IR stmts depending on the data provided in the control
- block iricb. */
+ block iricb. IR statements are injected into main IRStmtVec with ID #0. */
void
vex_inject_ir(IRSB *irsb, IREndness endian)
{
@@ -310,11 +310,11 @@
if (0) {
vex_printf("BEGIN inject\n");
if (iricb.t_result == Ity_I1 || sizeofIRType(iricb.t_result) <= 8) {
- ppIRStmt(irsb->stmts[irsb->stmts_used - 1]);
+ ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 1]);
} else if (sizeofIRType(iricb.t_result) == 16) {
- ppIRStmt(irsb->stmts[irsb->stmts_used - 2]);
+ ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 2]);
vex_printf("\n");
- ppIRStmt(irsb->stmts[irsb->stmts_used - 1]);
+ ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 1]);
}
vex_printf("\nEND inject\n");
}
Modified: branches/VEX_JIT_HACKS/priv/ir_opt.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_opt.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_opt.c Sat Mar 11 14:07:07 2017
@@ -266,7 +266,7 @@
/* Non-critical helper, heuristic for reducing the number of tmp-tmp
copies made by flattening. If in doubt return False. */
-static Bool isFlat ( IRExpr* e )
+static Bool isFlat(const IRExpr* e)
{
if (e->tag == Iex_Get)
return True;
@@ -280,102 +280,102 @@
/* Flatten out 'ex' so it is atomic, returning a new expression with
the same value, after having appended extra IRTemp assignments to
- the end of 'bb'. */
+ the end of 'stmts'. */
-static IRExpr* flatten_Expr ( IRSB* bb, IRExpr* ex )
+static IRExpr* flatten_Expr(IRStmtVec* stmts, IRExpr* ex)
{
Int i;
IRExpr** newargs;
- IRType ty = typeOfIRExpr(bb->tyenv, ex);
+ IRTypeEnv* tyenv = stmts->tyenv;
+ IRType ty = typeOfIRExpr(tyenv, ex);
IRTemp t1;
switch (ex->tag) {
case Iex_GetI:
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb, IRStmt_WrTmp(t1,
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_GetI(ex->Iex.GetI.descr,
- flatten_Expr(bb, ex->Iex.GetI.ix),
+ flatten_Expr(stmts, ex->Iex.GetI.ix),
ex->Iex.GetI.bias)));
return IRExpr_RdTmp(t1);
case Iex_Get:
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb,
- IRStmt_WrTmp(t1, ex));
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1, ex));
return IRExpr_RdTmp(t1);
case Iex_Qop: {
IRQop* qop = ex->Iex.Qop.details;
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb, IRStmt_WrTmp(t1,
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Qop(qop->op,
- flatten_Expr(bb, qop->arg1),
- flatten_Expr(bb, qop->arg2),
- flatten_Expr(bb, qop->arg3),
- flatten_Expr(bb, qop->arg4))));
+ flatten_Expr(stmts, qop->arg1),
+ flatten_Expr(stmts, qop->arg2),
+ flatten_Expr(stmts, qop->arg3),
+ flatten_Expr(stmts, qop->arg4))));
return IRExpr_RdTmp(t1);
}
case Iex_Triop: {
IRTriop* triop = ex->Iex.Triop.details;
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb, IRStmt_WrTmp(t1,
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Triop(triop->op,
- flatten_Expr(bb, triop->arg1),
- flatten_Expr(bb, triop->arg2),
- flatten_Expr(bb, triop->arg3))));
+ flatten_Expr(stmts, triop->arg1),
+ flatten_Expr(stmts, triop->arg2),
+ flatten_Expr(stmts, triop->arg3))));
return IRExpr_RdTmp(t1);
}
case Iex_Binop:
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb, IRStmt_WrTmp(t1,
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Binop(ex->Iex.Binop.op,
- flatten_Expr(bb, ex->Iex.Binop.arg1),
- flatten_Expr(bb, ex->Iex.Binop.arg2))));
+ flatten_Expr(stmts, ex->Iex.Binop.arg1),
+ flatten_Expr(stmts, ex->Iex.Binop.arg2))));
return IRExpr_RdTmp(t1);
case Iex_Unop:
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb, IRStmt_WrTmp(t1,
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Unop(ex->Iex.Unop.op,
- flatten_Expr(bb, ex->Iex.Unop.arg))));
+ flatten_Expr(stmts, ex->Iex.Unop.arg))));
return IRExpr_RdTmp(t1);
case Iex_Load:
- t1 = newIRTemp(bb->tyenv, ty);
- addStmtToIRSB(bb, IRStmt_WrTmp(t1,
+ t1 = newIRTemp(tyenv, ty);
+ addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Load(ex->Iex.Load.end,
ex->Iex.Load.ty,
- flatten_Expr(bb, ex->Iex.Load.addr))));
+ flatten_Expr(stmts, ex->Iex.Load.addr))));
return IRExpr_RdTmp(t1);
case Iex_CCall:
newargs ...
[truncated message content] |
|
From: <sv...@va...> - 2017-03-11 13:59:35
|
Author: iraisr
Date: Sat Mar 11 13:59:28 2017
New Revision: 16265
Log:
Focus on x86 frontend and backend first
Modified:
branches/VALGRIND_JIT_HACKS/Makefile.vex.am
Modified: branches/VALGRIND_JIT_HACKS/Makefile.vex.am
==============================================================================
--- branches/VALGRIND_JIT_HACKS/Makefile.vex.am (original)
+++ branches/VALGRIND_JIT_HACKS/Makefile.vex.am Sat Mar 11 13:59:28 2017
@@ -130,20 +130,6 @@
priv/guest_generic_x87.c \
priv/guest_x86_helpers.c \
priv/guest_x86_toIR.c \
- priv/guest_amd64_helpers.c \
- priv/guest_amd64_toIR.c \
- priv/guest_ppc_helpers.c \
- priv/guest_ppc_toIR.c \
- priv/guest_arm_helpers.c \
- priv/guest_arm_toIR.c \
- priv/guest_arm64_helpers.c \
- priv/guest_arm64_toIR.c \
- priv/guest_s390_helpers.c \
- priv/guest_s390_toIR.c \
- priv/guest_mips_helpers.c \
- priv/guest_mips_toIR.c \
- priv/guest_tilegx_helpers.c \
- priv/guest_tilegx_toIR.c \
priv/host_generic_regs.c \
priv/host_generic_simd64.c \
priv/host_generic_simd128.c \
@@ -151,23 +137,7 @@
priv/host_generic_maddf.c \
priv/host_generic_reg_alloc2.c \
priv/host_x86_defs.c \
- priv/host_x86_isel.c \
- priv/host_amd64_defs.c \
- priv/host_amd64_isel.c \
- priv/host_ppc_defs.c \
- priv/host_ppc_isel.c \
- priv/host_arm_defs.c \
- priv/host_arm_isel.c \
- priv/host_arm64_defs.c \
- priv/host_arm64_isel.c \
- priv/host_s390_defs.c \
- priv/host_s390_isel.c \
- priv/s390_disasm.c \
- priv/host_mips_defs.c \
- priv/host_mips_isel.c \
- priv/host_tilegx_defs.c \
- priv/host_tilegx_isel.c \
- priv/tilegx_disasm.c
+ priv/host_x86_isel.c
LIBVEXMULTIARCH_SOURCES = priv/multiarch_main_main.c
|
|
From: <sv...@va...> - 2017-03-11 13:52:36
|
Author: iraisr
Date: Sat Mar 11 13:52:29 2017
New Revision: 16264
Log:
Swizzle VEX external to branches/VEX_JIT_HACKS
Modified:
branches/VALGRIND_JIT_HACKS/ (props changed)
|
|
From: <sv...@va...> - 2017-03-11 07:39:42
|
Author: iraisr
Date: Sat Mar 11 07:39:35 2017
New Revision: 3309
Log:
Create branches/VEX_JIT_HACKS as a copy of trunk r3308.
Added:
branches/VEX_JIT_HACKS/ (props changed)
- copied from r3308, trunk/
|
|
From: <sv...@va...> - 2017-03-11 07:38:17
|
Author: iraisr
Date: Sat Mar 11 07:38:08 2017
New Revision: 16263
Log:
Create branches/VALGRIND_JIT_HACKS as a copy of trunk r16262.
Added:
branches/VALGRIND_JIT_HACKS/ (props changed)
- copied from r16262, trunk/
|