projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[libfirm]
/
testprograms
/
dead_block_example.c
diff --git
a/testprograms/dead_block_example.c
b/testprograms/dead_block_example.c
index
e5c1a82
..
1809a44
100644
(file)
--- a/
testprograms/dead_block_example.c
+++ b/
testprograms/dead_block_example.c
@@
-54,6
+54,8
@@
int main(int argc, char **argv)
/* init library */
init_firm ();
/* init library */
init_firm ();
+ set_opt_cse(0); /* there is a bug: first and start block are cse!! @@@ */
+
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
* all functions as methods in this file.
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
* all functions as methods in this file.
@@
-64,7
+66,7
@@
int main(int argc, char **argv)
#define METHODNAME "main"
#define NRARGS 0
#define NRES 0
#define METHODNAME "main"
#define NRARGS 0
#define NRES 0
- printf("
c
reating an IR graph: %s...\n", CLASSNAME);
+ printf("
\nC
reating an IR graph: %s...\n", CLASSNAME);
owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
@@
-77,7
+79,7
@@
int main(int argc, char **argv)
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
- /* t
w
o make a condition */
+ /* to make a condition */
c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
set_value(0, c2);
c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
set_value(0, c2);
@@
-85,27
+87,27
@@
int main(int argc, char **argv)
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(
irg->current_block
);
+ mature_block(
get_irg_current_block(irg)
);
/* end block to add jmps */
/* end block to add jmps */
- endBlock = new_Block();
+ endBlock = new_
imm
Block();
/* Block 1 */
/* Block 1 */
- Block1 = new_Block();
+ Block1 = new_
imm
Block();
add_in_edge(Block1, t);
mature_block(Block1);
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
/* Block 2 */
add_in_edge(Block1, t);
mature_block(Block1);
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
/* Block 2 */
- Block2 = new_Block();
+ Block2 = new_
imm
Block();
add_in_edge(Block2, f);
mature_block(Block2);
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
/* dead Block */
add_in_edge(Block2, f);
mature_block(Block2);
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
/* dead Block */
- deadBlock = new_Block();
+ deadBlock = new_
imm
Block();
mature_block(deadBlock);
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
mature_block(deadBlock);
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
@@
-118,28
+120,23
@@
int main(int argc, char **argv)
get_store();
x = new_Return (get_store(), 1, in);
}
get_store();
x = new_Return (get_store(), 1, in);
}
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
+
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ printf("Optimizing ...\n");
+ local_optimize_graph (irg);
+ dead_node_elimination (irg);
/* verify the graph */
irg_vrfy(irg);
/* verify the graph */
irg_vrfy(irg);
- printf("\nDone building the graph.\n");
- set_opt_constant_folding (1);
- set_optimize(1);
- set_opt_cse(1);
- local_optimize_graph (irg);
- dead_node_elimination (irg);
- printf("\nDone local optimization.\n");
printf("Dumping the graph and a control flow graph.\n");
printf("Dumping the graph and a control flow graph.\n");
-
dump_ir_block_graph (irg);
dump_cfg (irg);
dump_ir_block_graph (irg);
dump_cfg (irg);
-
- printf("use xvcg to view these graphs:\n");
- printf("/ben/goetz/bin/xvcg GRAPHNAME\n");
+ printf("Use xvcg to view these graphs:\n");
+ printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
return (0);
}
return (0);
}