More stuff.
git-svn-id: svn://svn.valgrind.org/vex/trunk@64 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/ir/ir_defs.c b/priv/ir/ir_defs.c
index c6fc255..35d9409 100644
--- a/priv/ir/ir_defs.c
+++ b/priv/ir/ir_defs.c
@@ -41,7 +41,10 @@
void ppIRTemp ( IRTemp tmp )
{
- vex_printf( "t%d", tmp);
+ if (tmp == INVALID_IRTEMP)
+ vex_printf("INVALID_IRTEMP");
+ else
+ vex_printf( "t%d", tmp);
}
@@ -67,7 +70,9 @@
{
switch (e->tag) {
case Iex_Get:
- vex_printf( "GET(%d,%d)", e->Iex.Get.offset, e->Iex.Get.size);
+ vex_printf( "GET(%d,", e->Iex.Get.offset);
+ ppIRType(e->Iex.Get.ty);
+ vex_printf(")");
break;
case Iex_Tmp:
ppIRTemp(e->Iex.Tmp.tmp);
@@ -105,7 +110,7 @@
{
switch (s->tag) {
case Ist_Put:
- vex_printf( "PUT(%d,%d) = ", s->Ist.Put.offset, s->Ist.Put.size);
+ vex_printf( "PUT(%d) = ", s->Ist.Put.offset);
ppIRExpr(s->Ist.Put.expr);
break;
case Ist_Tmp:
@@ -220,11 +225,11 @@
/* Constructors -- IRExpr */
-IRExpr* IRExpr_Get ( Int off, Int sz ) {
+IRExpr* IRExpr_Get ( Int off, IRType ty ) {
IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
e->tag = Iex_Get;
e->Iex.Get.offset = off;
- e->Iex.Get.size = sz;
+ e->Iex.Get.ty = ty;
return e;
}
IRExpr* IRExpr_Tmp ( IRTemp tmp ) {
@@ -265,12 +270,11 @@
/* Constructors -- IRStmt */
-IRStmt* IRStmt_Put ( Int off, Int sz, IRExpr* value ) {
+IRStmt* IRStmt_Put ( Int off, IRExpr* value ) {
IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
s->tag = Ist_Put;
s->link = NULL;
s->Ist.Put.offset = off;
- s->Ist.Put.size = sz;
s->Ist.Put.expr = value;
return s;
}
@@ -364,6 +368,8 @@
IRType typeOfIRExpr ( IRTypeEnv* tyenv, IRExpr* e )
{
switch (e->tag) {
+ case Iex_Get:
+ return e->Iex.Get.ty;
case Iex_Tmp:
return lookupIRTypeEnv(tyenv, e->Iex.Tmp.tmp);
case Iex_Const:
diff --git a/priv/main/vex_main.c b/priv/main/vex_main.c
index edd3fcf..52b4537 100644
--- a/priv/main/vex_main.c
+++ b/priv/main/vex_main.c
@@ -94,6 +94,7 @@
IRBB* irbb;
HInstrArray* vcode;
HInstrArray* rcode;
+ Int i;
vassert(vex_initdone);
LibVEX_Clear(False);
@@ -145,6 +146,13 @@
/* Turn it into virtual-registerised code. */
vcode = iselBB ( irbb );
+ vex_printf("\n-------- Virtual registerised code --------\n");
+ for (i = 0; i < vcode->arr_used; i++) {
+ ppInstr(vcode->arr[i]);
+ vex_printf("\n");
+ }
+ vex_printf("\n");
+
/* Register allocate. */
rcode = doRegisterAllocation ( vcode, available_real_regs,
n_available_real_regs,
@@ -152,6 +160,13 @@
genSpill, genReload,
ppInstr, ppReg );
+ vex_printf("\n-------- Post-regalloc code --------\n");
+ for (i = 0; i < rcode->arr_used; i++) {
+ ppInstr(rcode->arr[i]);
+ vex_printf("\n");
+ }
+ vex_printf("\n");
+
/* Assemble, etc. */
LibVEX_Clear(True);
diff --git a/pub/libvex_ir.h b/pub/libvex_ir.h
index 12d84d1..3a6e604 100644
--- a/pub/libvex_ir.h
+++ b/pub/libvex_ir.h
@@ -53,10 +53,12 @@
/* ------------------ Temporaries ------------------ */
-typedef Int IRTemp;
+typedef UInt IRTemp;
extern void ppIRTemp ( IRTemp );
+#define INVALID_IRTEMP ((IRTemp)0xFFFFFFFF)
+
/* ------------------ Binary and unary ops ------------------ */
@@ -98,8 +100,8 @@
IRExprTag tag;
union {
struct {
- Int offset;
- Int size;
+ Int offset;
+ IRType ty;
} Get;
struct {
IRTemp tmp;
@@ -124,7 +126,7 @@
}
IRExpr;
-extern IRExpr* IRExpr_Get ( Int off, Int sz );
+extern IRExpr* IRExpr_Get ( Int off, IRType ty );
extern IRExpr* IRExpr_Tmp ( IRTemp tmp );
extern IRExpr* IRExpr_Binop ( IROp op, IRExpr* arg1, IRExpr* arg2 );
extern IRExpr* IRExpr_Unop ( IROp op, IRExpr* arg );
@@ -151,7 +153,6 @@
union {
struct {
Int offset;
- Int size;
IRExpr* expr;
} Put;
struct {
@@ -167,7 +168,7 @@
}
IRStmt;
-extern IRStmt* IRStmt_Put ( Int off, Int sz, IRExpr* value );
+extern IRStmt* IRStmt_Put ( Int off, IRExpr* value );
extern IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* expr );
extern IRStmt* IRStmt_STle ( IRExpr* addr, IRExpr* value );
diff --git a/test_main.c b/test_main.c
index 95e1717..568333d 100644
--- a/test_main.c
+++ b/test_main.c
@@ -78,7 +78,8 @@
assert(linebuf[0] == '.');
/* second line is: . byte byte byte etc */
//printf("%s", linebuf);
- printf("Basic Block %d, Start %x, nbytes %d\n",
+ printf("\n\n============ Basic Block %d, "
+ "Start %x, nbytes %d ============\n\n",
bb_number, orig_addr, orig_nbytes);
assert(orig_nbytes >= 1 && orig_nbytes <= N_ORIGBUF);
for (i = 0; i < orig_nbytes; i++) {
@@ -250,8 +251,8 @@
printf("\nAfter\n");
for (i = 0; i < rcode->arr_used; i++) {
- ppX86Instr(stdout, rcode->arr[i]);
- printf("\n");
+ ppX86Instr(stdout, rcode->arr[i]);
+ printf("\n");
}
printf("\n");
}