X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=testprograms%2Fexception_example.c;h=25e85d8dbaba4542d501419a59f3279b282344d3;hb=e2a0d5aa0061e2277e9e21f5b636e2bec2b22186;hp=21687e4002d4549f7f05f203d24cc61eebda753e;hpb=8331be5638aecdb3f6f21ab2457b25ead4a81322;p=libfirm diff --git a/testprograms/exception_example.c b/testprograms/exception_example.c index 21687e400..25e85d8db 100644 --- a/testprograms/exception_example.c +++ b/testprograms/exception_example.c @@ -11,12 +11,12 @@ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ -# include -# include +#include +#include + + +#include -# include "irvrfy.h" -# include "firm.h" -# include "irdump.h" /** @@ -37,13 +37,13 @@ * return d; **/ -int main(int argc, char **argv) +int main(void) { - type *prim_t_int; + ir_type *prim_t_int; ir_graph *irg; /* this variable contains the irgraph */ - type *owner; /* the class in which this method is defined */ - type *method; /* the type of this method */ - entity *ent; /* represents this method as entity of owner */ + ir_type *owner; /* the class in which this method is defined */ + ir_type *method; /* the ir_type of this method */ + ir_entity *ent; /* represents this method as ir_entity of owner */ ir_node *x, *catch_block, *block, *zero, *a, *b, *c, *d; printf("\nCreating an IR graph: EXCEPTION...\n"); @@ -51,14 +51,14 @@ int main(int argc, char **argv) /* init library */ init_firm (NULL); - /*** Make basic type information for primitive type int. ***/ - prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is); + /*** Make basic ir_type information for primitive ir_type int. ***/ + prim_t_int = new_type_primitive(new_id_from_str ("int"), 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 * all functions as methods in this file. * Therefore we define a class "IF_ELSE_EXAMPLE" with a method main as an - * entity. + * ir_entity. */ #define ENTITYNAME "EXCEPTION_main" @@ -68,7 +68,7 @@ int main(int argc, char **argv) ent = new_entity (owner, new_id_from_str (ENTITYNAME), method); - /* Generates the basic graph for the method represented by entity ent, that + /* Generates the basic graph for the method represented by ir_entity ent, that * is, generates start and end blocks and nodes and a first, initial block. * The constructor needs to know how many local variables the method has. */ @@ -89,13 +89,13 @@ int main(int argc, char **argv) block = get_cur_block(); catch_block = new_immBlock(); - switch_block(block); + set_cur_block(block); /* d = a / 0 */ - d = new_Div(get_store(), get_value(0, mode_Is), zero); + d = new_Div(get_store(), get_value(0, mode_Is), zero, mode_Is, op_pin_state_pinned); set_store(new_Proj(d, mode_M, pn_Div_M)); x = new_Proj(d, mode_X, pn_Div_X_except); - add_in_edge(catch_block, x); + add_immBlock_pred(catch_block, x); d = new_Proj(d, mode_Is, pn_Div_res); set_value(3, d); /* this (3) is variable d */ @@ -104,39 +104,39 @@ int main(int argc, char **argv) set_value (2, c); /* this (2) is variable c */ /* d = b / 0 */ - d = new_Div(get_store(), get_value(1, mode_Is), zero); + d = new_Div(get_store(), get_value(1, mode_Is), zero, mode_Is, op_pin_state_pinned); set_store(new_Proj(d, mode_M, pn_Div_M)); x = new_Proj(d, mode_X, pn_Div_X_except); - add_in_edge(catch_block, x); + add_immBlock_pred(catch_block, x); d = new_Proj(d, mode_Is, pn_Div_res); set_value(3, d); /* this (3) is variable d */ /* return d */ d = get_value(3, mode_Is); x = new_Return (get_store(), 1, &d); - mature_block(get_cur_block()); - add_in_edge(get_irg_end_block(current_ir_graph), x); + mature_immBlock(get_cur_block()); + add_immBlock_pred(get_irg_end_block(current_ir_graph), x); /* return c */ - switch_block(catch_block); + set_cur_block(catch_block); c = get_value(2, mode_Is); x = new_Return (get_store(), 1, &c); - mature_block(get_cur_block()); - add_in_edge(get_irg_end_block(current_ir_graph), x); + mature_immBlock(get_cur_block()); + add_immBlock_pred(get_irg_end_block(current_ir_graph), x); /* Now we can mature the end block as all it's predecessors are known. */ - mature_block (get_irg_end_block(irg)); + mature_immBlock (get_irg_end_block(irg)); - finalize_cons (irg); + irg_finalize_cons (irg); /* verify the graph */ irg_vrfy(irg); printf("Done building the graph. Dumping it.\n"); - dump_ir_block_graph (irg); - dump_ir_graph (irg); - printf("use xvcg to view this graph:\n"); - printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n"); + dump_ir_block_graph (irg, ""); + dump_ir_graph (irg, ""); + printf("Use ycomp to view this graph:\n"); + printf("ycomp GRAPHNAME\n\n"); return (0); }