X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=testprograms%2Fcond_example.c;h=bd6ca02c6312a8bb84e73fda5455450508b6433e;hb=4ba1f381673a1b615096a66760b93afa99bf3416;hp=4005c5da42a47bcef3b9078c517c8184f964b569;hpb=a84a02c67f3b1325633a380a5c66179594499ab6;p=libfirm diff --git a/testprograms/cond_example.c b/testprograms/cond_example.c index 4005c5da4..bd6ca02c6 100644 --- a/testprograms/cond_example.c +++ b/testprograms/cond_example.c @@ -29,7 +29,7 @@ int main(int argc, char **argv) entity *ent; /* represents this method as entity of owner */ ir_node *x, *x_then, *arg1, *c2, *c10, *cmpGt, *cmpLt, *and, *f, *t, *b; - printf("creating an IR graph: COND_EXAMPLE...\n"); + printf("\nCreating an IR graph: COND_EXAMPLE...\n"); /* init library */ init_firm (); @@ -57,7 +57,7 @@ int main(int argc, char **argv) irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS); /* get the first argument a of method main - see irgraph.h */ - arg1 = new_Proj(irg->args, mode_i, 0); + arg1 = new_Proj(get_irg_args(irg), mode_i, 0); /* arg1 as first first local variable - makes things simple */ set_value(0, arg1); @@ -84,17 +84,17 @@ int main(int argc, char **argv) f = new_Proj (x, mode_X, 0); /* if condition is false */ t = new_Proj (x, mode_X, 1); /* if condition is true */ - mature_block (irg->current_block); + mature_block (get_irg_current_block(irg)); /* generate and fill the then block */ - b = new_Block (); + b = new_immBlock (); add_in_edge (b, t); set_value (0, new_Const (mode_i, tarval_from_long (mode_i, 1))); mature_block (b); x_then = new_Jmp (); /* generate the fall through block and add all cfg edges */ - b = new_Block (); + b = new_immBlock (); add_in_edge (b, x_then); add_in_edge (b, f); @@ -107,24 +107,24 @@ int main(int argc, char **argv) } /* Now generate all instructions for this block and all its predecessor blocks * so we can mature it. */ - mature_block (irg->current_block); + mature_block (get_irg_current_block(irg)); /* This adds the in edge of the end block which originates at the return statement. The return node passes controlflow to the end block.*/ - add_in_edge (irg->end_block, x); + add_in_edge (get_irg_end_block(irg), x); /* Now we can mature the end block as all it's predecessors are known. */ - mature_block (irg->end_block); + mature_block (get_irg_end_block(irg)); - - printf("\nDone building the graph. Dumping it.\n"); + printf("Optimizing ...\n"); + dead_node_elimination(irg); /* verify the graph */ irg_vrfy(irg); + printf("Done building the graph. Dumping it.\n"); dump_ir_block_graph (irg); - - printf("use xvcg to view this graph:\n"); - printf("/ben/goetz/bin/xvcg GRAPHNAME\n"); + printf("Use xvcg to view this graph:\n"); + printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n"); return (0); }