From 0cc9b819312ce76172b2bc692d313d104bbf5603 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Wed, 12 Jul 2000 14:38:28 +0000 Subject: [PATCH] *** empty log message *** [r47] --- Changes | 14 ++++++++++++++ ir/ir/irdump.c | 21 ++++++++++++++++++++ ir/ir/irnode.c | 3 ++- ir/ir/irprog.c | 32 +++++++++++++++++++++++++++---- ir/ir/irprog.h | 25 ++++++++++++++++-------- testprograms/oo_program_example.c | 20 ++++++++++--------- 6 files changed, 93 insertions(+), 22 deletions(-) diff --git a/Changes b/Changes index 2464ecfd6..71f60fb5f 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,17 @@ + 12.7.2000 Goetz + Changed output of oo_prog_example: now uses the internal list + of all irgs. Had to implement some of the access routines for + that. Also fixed a bug in irdump. Main routines did not use + current_ir_graph properly. + + 12.7.2000 Goetz + Implemented some missing parts in irgopt. + Added field irg to entity. Only valid if entity is a method. + Had to resove a cyclic de[endency between irgraph.h and entity.h + for this. + Added fields sub and super to type_class for inheritance. + Added field main_irg to irprog. + 7.7.2000 Chris Fixed some bugs in irgopt.c Added some missing 'get_new_node' methods, so the new obstack contains diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index cc26f8ec0..652ac7ec0 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -540,12 +540,18 @@ dump_whole_node (ir_node *n, void* env) { void dump_ir_graph (ir_graph *irg) { + ir_graph *rem; + rem = current_ir_graph; + current_ir_graph = irg; + vcg_open (irg, ""); /* walk over the graph */ irg_walk(irg->end, dump_whole_node, NULL, NULL); vcg_close(); + + current_ir_graph = rem; } /***********************************************************************/ @@ -589,12 +595,17 @@ dump_ir_block (ir_node *block, void *env) { void dump_ir_block_graph (ir_graph *irg) { + ir_graph *rem; + rem = current_ir_graph; + current_ir_graph = irg; + vcg_open (irg, ""); /* walk over the blocks in the graph */ irg_block_walk(irg->end, dump_ir_block, NULL, irg); vcg_close(); + current_ir_graph = rem; } @@ -641,12 +652,17 @@ dump_cfg (ir_graph *irg) void dump_type_graph (ir_graph *irg) { + ir_graph *rem; + rem = current_ir_graph; + current_ir_graph = irg; + vcg_open (irg, "-type"); /* walk over the blocks in the graph */ type_walk(irg, dump_type_info, NULL, NULL); vcg_close(); + current_ir_graph = rem; } @@ -658,6 +674,10 @@ dump_type_graph (ir_graph *irg) void dump_ir_graph_w_types (ir_graph *irg) { + ir_graph *rem; + rem = current_ir_graph; + current_ir_graph = irg; + vcg_open (irg, "-all"); /* dump common ir graph */ @@ -669,4 +689,5 @@ dump_ir_graph_w_types (ir_graph *irg) irg_walk(irg->end, dump_node2type_edges, NULL, NULL); vcg_close(); + current_ir_graph = rem; } diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 6e7827522..0858a7a37 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -173,7 +173,8 @@ inline ir_node * get_irn_n (ir_node *node, int n) { assert (node); - // assert (get_irn_arity (node) > n); + /* GL commented the assert in, 12.7.00, let's see whether it works */ + assert (get_irn_arity (node) > n); return skip_nop(node->in[n+1]); } diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index f8054bc98..934ed8b1d 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -33,8 +33,20 @@ ir_prog *new_ir_prog (void) { return res; } - /** Functions to access the fields of ir_prog **/ + + +/* Access the main routine of the compiled program. */ +ir_graph *get_irp_main_irg() { + assert (irp); + return irp->main_irg; +} + +void set_irp_main_irg(ir_graph *main_irg) { + assert (irp); + irp->main_irg = main_irg; +} + type_class *get_glob_type(void) { assert(irp); return irp->glob_type; @@ -43,18 +55,30 @@ type_class *get_glob_type(void) { /* Adds irg to the list of ir graphs in irp. */ void add_irp_irg(ir_graph *irg) { assert (irg != NULL); - assert(irp); + assert(irp && irp->graphs); ARR_APP1 (ir_graph *, irp->graphs, irg); } +int get_irp_n_irgs() { + assert (irp && irp->graphs); + /* Strangely the first element of the array is NULL. Why?? */ + return (ARR_LEN((irp)->graphs) - 1); +} + +ir_graph *get_irp_irg(int pos){ + assert (irp && irp->graphs); + /* Strangely the first element of the array is NULL. Why?? */ + return irp->graphs[pos+1]; +} + /* Adds type to the list of types in irp. */ -void add_irp_type(type *typ) { +void add_irp_type(type *typ) { assert (typ != NULL); assert(irp); ARR_APP1 (type *, irp->types, typ); } -int get_irp_new_node_nr() { +int get_irp_new_node_nr() { assert(irp); irp->max_node_nr = irp->max_node_nr + 1; return irp->max_node_nr - 1; diff --git a/ir/ir/irprog.h b/ir/ir/irprog.h index 72fb75b46..99c4157fb 100644 --- a/ir/ir/irprog.h +++ b/ir/ir/irprog.h @@ -22,23 +22,28 @@ # include "type.h" /*# include "obst.h"*/ -typedef struct ir_prog { +struct ir_prog { firm_kind kind; + ir_graph *main_irg; /* entry point to the compiled program */ + /* or a list, in case we compile a library or the like? */ ir_graph **graphs; /* all graphs in the ir */ type **types; /* all types in the ir */ type_class *glob_type; /* global type. Class as it can have fields and procedures. Does this work? Better name??? @@@ */ - /*struct obstack *obst; * @@@ Should we place all types and entities themselves - on an obstack, too? */ + /*struct obstack *obst; * @@@ Should we place all types and + entities on an obstack, too? */ #ifdef DEBUG_libfirm - long max_node_nr; + long max_node_nr; /* to generate unique numbers for nodes. */ #endif -} ir_prog; +}; + +typedef struct ir_prog ir_prog; /* A variable from where everything in the ir can be accessed. */ ir_prog *irp; + /* initializes ir_prog. Calles the constructor for an ir_prog. */ void init_irprog(void); @@ -46,11 +51,15 @@ void init_irprog(void); Automatically called by init_firm through init_irprog. */ ir_prog *new_ir_prog (void); +/* Access the main routine of the compiled program. */ +ir_graph *get_irp_main_irg(); +void set_irp_main_irg(ir_graph *main_irg); + /* Adds irg to the list of ir graphs in irp. */ void add_irp_irg(ir_graph *irg); -/* get_irp_n_irgs() * GL Chris: immer globale irp benutzen! * - get_irp_irg(int pos) - set_irp_irg() und das gleiche fuer type */ +int get_irp_n_irgs(); +ir_graph *get_irp_irg(int pos); + /* set_irp_irg() und das gleiche fuer type */ /* Adds type to the list of types in irp. */ void add_irp_type(type *typ); diff --git a/testprograms/oo_program_example.c b/testprograms/oo_program_example.c index 7bd6f99ea..e2c823bb0 100644 --- a/testprograms/oo_program_example.c +++ b/testprograms/oo_program_example.c @@ -50,6 +50,8 @@ main(void) ir_node *self, *par1, *a_ptr; ir_node *a_val; + int i; + init_firm (); set_opt_constant_folding(0); @@ -67,6 +69,8 @@ main(void) proc_main_e = new_entity ((type *)owner, id_from_str ("main", 4), (type *)proc_main); main_irg = new_ir_graph (proc_main_e, 4); + /* Remark that this irg is the main routine of the program. */ + set_irp_main_irg(main_irg); /* There is only one block in main, it contains the constants and the calls. */ c2 = new_Const (mode_i, tarval_from_long (mode_i, 2)); @@ -138,9 +142,6 @@ main(void) printf("\nDone building the graph.\n"); irg_vrfy(main_irg); - printf("Dumping the graph and a type graph.\n"); - dump_ir_block_graph (main_irg); - dump_type_graph(main_irg); /****************************************************************************/ @@ -169,9 +170,6 @@ main(void) printf("\nDone building the graph.\n"); irg_vrfy(set_a_irg); - printf("Dumping the graph and a type graph.\n"); - dump_ir_block_graph (set_a_irg); - dump_type_graph(set_a_irg); /****************************************************************************/ @@ -206,9 +204,13 @@ main(void) irg_vrfy(main_irg); printf("\nDone building the graph.\n"); - printf("Dumping the graph and a type graph.\n"); - dump_ir_block_graph (c_irg); - dump_type_graph(c_irg); + + printf("Dumping graphs of all procedures.\n"); + + for (i = 0; i < get_irp_n_irgs(); i++) { + dump_ir_block_graph (get_irp_irg(i)); + dump_type_graph(get_irp_irg(i)); + } /****************************************************************************/ -- 2.20.1