projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Yep, I think this is a dangerous feature, so warn about it.
[libfirm]
/
testprograms
/
three_cfpred_example.c
diff --git
a/testprograms/three_cfpred_example.c
b/testprograms/three_cfpred_example.c
index
46c8106
..
e8df7ce
100644
(file)
--- a/
testprograms/three_cfpred_example.c
+++ b/
testprograms/three_cfpred_example.c
@@
-10,13
+10,10
@@
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
+#include <stdio.h>
+#include <string.h>
-# include <stdio.h>
-# include <string.h>
-
-# include "irvrfy.h"
-# include "irdump.h"
-# include "firm.h"
+#include <libfirm/firm.h>
/**
* This file constructs a control flow of following shape:
/**
* This file constructs a control flow of following shape:
@@
-49,23
+46,24
@@
*
**/
*
**/
-int main(
int argc, char **argv
)
+int main(
void
)
{
{
- type *prim_t_int;
+ const char *suffix = "";
+ ir_type *prim_t_int;
ir_graph *irg; /* this variable contains the irgraph */
ir_graph *irg; /* this variable contains the irgraph */
- type *owner; /* the class in which this method is defined */
-
type *proc_main; /*
type information for the method main */
-
entity *ent; /* represents this method as
entity of owner */
+
ir_
type *owner; /* the class in which this method is defined */
+
ir_type *proc_main; /* ir_
type information for the method main */
+
ir_entity *ent; /* represents this method as ir_
entity of owner */
ir_node *c1, *c2, *cond, *f, *t, *endBlock, *Block1, *jmp,
*scndCondBlock, *Block2, *Block3, *x;
/* init library */
ir_node *c1, *c2, *cond, *f, *t, *endBlock, *Block1, *jmp,
*scndCondBlock, *Block2, *Block3, *x;
/* init library */
- init_firm
(NULL);
+ init_firm(NULL);
set_optimize(1);
set_optimize(1);
- /*** Make basic
type information for primitive
type int. ***/
- prim_t_int = new_type_primitive(new_id_from_chars
("int", 3), mode_Is);
+ /*** Make basic
ir_type information for primitive ir_
type int. ***/
+ prim_t_int = new_type_primitive(new_id_from_chars("int", 3), mode_Is);
/* 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
/* 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
@@
-83,23
+81,23
@@
int main(int argc, char **argv)
set_method_param_type(proc_main, 0, prim_t_int);
set_method_res_type(proc_main, 0, prim_t_int);
set_method_param_type(proc_main, 0, prim_t_int);
set_method_res_type(proc_main, 0, prim_t_int);
- ent = new_entity
(owner,
-
new_id_from_chars
(METHODNAME, strlen(METHODNAME)),
-
proc_main);
+ ent = new_entity(owner,
+
new_id_from_chars
(METHODNAME, strlen(METHODNAME)),
+ proc_main);
#define NUM_OF_LOCAL_VARS 2
#define NUM_OF_LOCAL_VARS 2
- irg = new_ir_graph
(ent, NUM_OF_LOCAL_VARS);
+ irg = new_ir_graph(ent, NUM_OF_LOCAL_VARS);
/* to make a condition */
/* to make a condition */
- c1 = new_Const
(mode_Is, new_tarval_from_long
(1, mode_Is));
- c2 = new_Proj
(get_irg_args(irg), mode_Is, 0);
+ c1 = new_Const
(mode_Is, new_tarval_from_long
(1, mode_Is));
+ c2 = new_Proj(get_irg_args(irg), mode_Is, 0);
set_value(1, c2);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, pn_Cmp_Eq));
set_value(1, c2);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, pn_Cmp_Eq));
- set_value(0, new_Const
(mode_Is, new_tarval_from_long
(6, mode_Is)));
- f = new_Proj(cond, mode_X,
0
);
- t = new_Proj(cond, mode_X,
1
);
+ set_value(0, new_Const
(mode_Is, new_tarval_from_long
(6, mode_Is)));
+ f = new_Proj(cond, mode_X,
pn_Cond_false
);
+ t = new_Proj(cond, mode_X,
pn_Cond_true
);
mature_immBlock(get_irg_current_block(irg));
/* end block to add jmps */
mature_immBlock(get_irg_current_block(irg));
/* end block to add jmps */
@@
-109,7
+107,7
@@
int main(int argc, char **argv)
Block1 = new_immBlock();
add_immBlock_pred(Block1, t);
mature_immBlock(Block1);
Block1 = new_immBlock();
add_immBlock_pred(Block1, t);
mature_immBlock(Block1);
- set_value(0, new_Const
(mode_Is, new_tarval_from_long
(5, mode_Is)));
+ set_value(0, new_Const
(mode_Is, new_tarval_from_long
(5, mode_Is)));
jmp = new_Jmp();
add_immBlock_pred(endBlock, jmp);
jmp = new_Jmp();
add_immBlock_pred(endBlock, jmp);
@@
-117,10
+115,10
@@
int main(int argc, char **argv)
scndCondBlock = new_immBlock();
add_immBlock_pred(scndCondBlock, f);
mature_immBlock(scndCondBlock);
scndCondBlock = new_immBlock();
add_immBlock_pred(scndCondBlock, f);
mature_immBlock(scndCondBlock);
- c1 = new_Const
(mode_Is, new_tarval_from_long
(3, mode_Is));
+ c1 = new_Const
(mode_Is, new_tarval_from_long
(3, mode_Is));
cond = new_Cond(new_Proj(new_Cmp(c1, get_value(1, mode_Is)), mode_b, pn_Cmp_Eq));
cond = new_Cond(new_Proj(new_Cmp(c1, get_value(1, mode_Is)), mode_b, pn_Cmp_Eq));
- f = new_Proj(cond, mode_X,
0
);
- t = new_Proj(cond, mode_X,
1
);
+ f = new_Proj(cond, mode_X,
pn_Cond_false
);
+ t = new_Proj(cond, mode_X,
pn_Cond_true
);
mature_immBlock(get_irg_current_block(irg));
/* Block 2 */
mature_immBlock(get_irg_current_block(irg));
/* Block 2 */
@@
-142,27
+140,27
@@
int main(int argc, char **argv)
{
ir_node *in[1];
in[0] = get_value(0, mode_Is);
{
ir_node *in[1];
in[0] = get_value(0, mode_Is);
- x = new_Return
(get_store(), 1, in);
+ x = new_Return(get_store(), 1, in);
}
}
- mature_immBlock
(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
/* finish the Block with the end node */
/* finish the Block with the end node */
- add_immBlock_pred
(get_irg_end_block(irg), x);
- mature_immBlock
(get_irg_end_block(irg));
+ add_immBlock_pred(get_irg_end_block(irg), x);
+ mature_immBlock(get_irg_end_block(irg));
/* verify the graph */
irg_vrfy(irg);
/* verify the graph */
irg_vrfy(irg);
- irg_finalize_cons
(irg);
+ irg_finalize_cons(irg);
printf("Optimizing ...\n");
dead_node_elimination(irg);
printf("Dumping the graph and a control flow graph.\n");
printf("Optimizing ...\n");
dead_node_elimination(irg);
printf("Dumping the graph and a control flow graph.\n");
-
char *suffix = ""
;
- dump_
ir_block_graph
(irg, suffix);
-
dump_cfg (irg, suffix
);
- printf("
Use xvcg to view these graphs:
\n");
- printf("
/ben/goetz/bin/xvcg GRAPHNAME
\n\n");
+
dump_ir_block_graph(irg, suffix)
;
+ dump_
cfg
(irg, suffix);
+
printf("Use ycomp to view these graphs:\n"
);
+ printf("
ycomp THREE_CFPRED_EXAMPLE_main.vcg\n
\n");
+ printf("
ycomp THREE_CFPRED_EXAMPLE_main-cfg.vcg
\n\n");
- return
(0);
+ return(0);
}
}