X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firgraph.c;h=249fdb55a0347d235e98f9818ebb29b019deaa28;hb=d61b4fcf547abba70184af32e2d3acc77531c623;hp=e5b9fe61d593d98617cef216b3d4c197e446cec2;hpb=3841faf71dcf8efa8312d0ebd9941f1e0fc08d72;p=libfirm diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index e5b9fe61d..249fdb55a 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -7,17 +7,19 @@ */ # include "ircons.h" -# include "irgraph.h" +# include "irgraph_t.h" # include "irprog.h" -# include "iropt.h" +# include "iropt_t.h" # include "array.h" # include "irgmod.h" ir_graph *current_ir_graph; -unsigned long ir_visited = 0; -unsigned long block_visited = 0; - +#if USE_EXPICIT_PHI_IN_STACK +/* really defined in ircons.c */ +typedef struct Phi_in_stack Phi_in_stack; +Phi_in_stack *new_Phi_in_stack(); +#endif /* Allocates a list of nodes: - The start block containing a start node and Proj nodes for it's four @@ -29,7 +31,7 @@ unsigned long block_visited = 0; and optimization. */ ir_graph * -new_ir_graph (entity *ent, int params) +new_ir_graph (entity *ent, int n_loc) { ir_graph *res; ir_node *first_block; @@ -41,29 +43,34 @@ new_ir_graph (entity *ent, int params) /** Internal information for graph construction either held in the graph or *** initialized for each graph. **/ - res->params = params + 1; /* number of local variables that are never + res->n_loc = n_loc + 1; /* number of local variables that are never dereferenced in this graph plus one for the store. This is not the number of parameters to the procedure! */ + res->visited = 0; /* visited flag, for the ir walker */ + res->block_visited=0; /* visited flag, for the 'block'-walker */ + #if USE_EXPICIT_PHI_IN_STACK res->Phi_in_stack = new_Phi_in_stack(); /* A stack needed for automatic Phi generation */ #endif res->obst = (struct obstack *) xmalloc (sizeof (struct obstack)); obstack_init (res->obst); - res->value_table = new_identities (); /* Symbol table for local variables - of this procedure */ + res->value_table = new_identities (); /* value table for global value + numbering for optimizing use in + iropt.c */ /** Type inforamtion for the procedure of the graph **/ res->ent = ent; + set_entity_irg(ent, res); /** Nodes needed in every graph **/ - res->end_block = new_Block (); + res->end_block = new_immBlock (); res->end = new_End (); - res->start_block = new_Block (); - res->start = new_Start (); - res->bad = new_ir_node (res, res->start_block, op_Bad, mode_T, 0, NULL); + res->start_block = new_immBlock (); + res->start = new_Start (); + res->bad = new_ir_node (res, res->start_block, op_Bad, mode_T, 0, NULL); /* Proj results of start node */ projX = new_Proj (res->start, mode_X, pns_initial_exec); @@ -80,87 +87,89 @@ new_ir_graph (entity *ent, int params) mature_block (res->current_block); /** Make a block to start with **/ - first_block = new_Block (); + first_block = new_immBlock (); add_in_edge (first_block, projX); return res; } -/* access routines for all ir_graph attributes */ +/* access routines for all ir_graph attributes: + templates: + {attr type} get_irg_{attribute name} (ir_graph *irg); + void set_irg_{attr name} (ir_graph *irg, {attr type} {attr}); */ ir_node * -get_start_block_of_irgraph (ir_graph *irg) +get_irg_start_block (ir_graph *irg) { return irg->start_block; } void -set_start_block_of_irgraph (ir_graph *irg, ir_node *node) +set_irg_start_block (ir_graph *irg, ir_node *node) { irg->start_block = node; } ir_node * -get_start_of_irgraph (ir_graph *irg) +get_irg_start (ir_graph *irg) { return irg->start; } void -set_start_of_irgraph(ir_graph *irg, ir_node *node) +set_irg_start(ir_graph *irg, ir_node *node) { irg->start = node; } ir_node * -get_end_block_of_irgraph (ir_graph *irg) +get_irg_end_block (ir_graph *irg) { return irg->end_block; } void -set_end_block_of_irgraph (ir_graph *irg, ir_node *node) +set_irg_end_block (ir_graph *irg, ir_node *node) { irg->end_block = node; } ir_node * -get_end_of_irgraph (ir_graph *irg) +get_irg_end (ir_graph *irg) { return irg->end; } void -set_end_of_irgraph (ir_graph *irg, ir_node *node) +set_irg_end (ir_graph *irg, ir_node *node) { irg->end = node; } ir_node * -get_cstore_of_irgraph (ir_graph *irg) +get_irg_cstore (ir_graph *irg) { return irg->cstore; } void -set_cstore_of_irgraph (ir_graph *irg, ir_node *node) +set_irg_cstore (ir_graph *irg, ir_node *node) { irg->cstore = node; } ir_node * -get_frame_of_irgraph (ir_graph *irg) +get_irg_frame (ir_graph *irg) { return irg->frame; } void -set_frame_of_irgraph(ir_graph *irg, ir_node *node) +set_irg_frame (ir_graph *irg, ir_node *node) { irg->frame = node; } - ir_node * get_irg_globals (ir_graph *irg) { @@ -173,64 +182,99 @@ set_irg_globals (ir_graph *irg, ir_node *node) irg->globals = node; } - - ir_node * -get_args_of_irgraph (ir_graph *irg) +get_irg_args (ir_graph *irg) { return irg->args; } void -set_args_of_irgraph(ir_graph *irg, ir_node *node) +set_irg_args (ir_graph *irg, ir_node *node) { irg->args = node; } ir_node * -get_bad_of_irgraph (ir_graph *irg) +get_irg_bad (ir_graph *irg) { return irg->bad; } void -set_bad_of_irgraph(ir_graph *irg, ir_node *node) +set_irg_bad (ir_graph *irg, ir_node *node) { irg->bad = node; } ir_node * -get_current_block_of_irgraph (ir_graph *irg) +get_irg_current_block (ir_graph *irg) { return irg->current_block; } void -set_current_block_of_irgraph(ir_graph *irg, ir_node *node) +set_irg_current_block (ir_graph *irg, ir_node *node) { irg->current_block = node; } entity * -get_ent_of_irgraph(ir_graph *irg) +get_irg_ent (ir_graph *irg) { + assert(irg && irg->ent); return irg->ent; } void -set_ent_of_irgraph(ir_graph *irg, entity *ent) +set_irg_ent (ir_graph *irg, entity *ent) { irg->ent = ent; } int -get_params_of_irgraph(ir_graph *irg) +get_irg_n_loc (ir_graph *irg) +{ + return irg->n_loc; +} + +void +set_irg_n_loc (ir_graph *irg, int n_loc) +{ + irg->n_loc = n_loc; +} + +unsigned long +get_irg_visited (ir_graph *irg) +{ + return irg->visited; +} + +void +set_irg_visited (ir_graph *irg, unsigned long visited) +{ + irg->visited = visited; +} + +void +inc_irg_visited (ir_graph *irg) +{ + irg->visited = irg->visited++; +} + +unsigned long +get_irg_block_visited (ir_graph *irg) +{ + return irg->block_visited; +} + +void +set_irg_block_visited (ir_graph *irg, unsigned long visited) { - return irg->params; + irg->block_visited = visited; } void -set_params_of_irgraph(ir_graph *irg, int params) +inc_irg_block_visited (ir_graph *irg) { - irg->params = params; + irg->block_visited = irg->block_visited++; }