From: Matthias Braun Date: Thu, 8 Nov 2007 17:07:46 +0000 (+0000) Subject: add support for graph_idx X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=c0abcb049cfb3acd1d006a555012657d1151ddb9;p=libfirm add support for graph_idx [r16489] --- diff --git a/include/libfirm/irgraph.h b/include/libfirm/irgraph.h index 2ed896860..98df80b43 100644 --- a/include/libfirm/irgraph.h +++ b/include/libfirm/irgraph.h @@ -276,8 +276,17 @@ void set_irg_no_mem (ir_graph *irg, ir_node *node); /** Returns the number of value numbers of a graph. */ int get_irg_n_locs (ir_graph *irg); +#ifdef DEBUG_libfirm /** Returns the graph number. */ long get_irg_graph_nr(ir_graph *irg); +#endif + +/** + * Returns the graph number. This is a unique number for the graph and is + * smaller than get_irp_last_idx() + * Note: you cannot use this number for get_irp_irg + */ +int get_irg_idx(const ir_graph *irg); /********************************************************************************/ /* States of an ir_graph. */ diff --git a/include/libfirm/irprog.h b/include/libfirm/irprog.h index 1a2e08f83..b754108ad 100644 --- a/include/libfirm/irprog.h +++ b/include/libfirm/irprog.h @@ -84,18 +84,18 @@ ir_prog *get_irp(void); /** Creates a new ir_prog, returns it and sets irp with it. * Automatically called by init_firm() through init_irprog. */ -ir_prog *new_ir_prog (void); +ir_prog *new_ir_prog(void); /** frees all memory used by irp. Types in type list and irgs in irg * list must be freed by hand before. */ -void free_ir_prog(void); +void free_ir_prog(void); /** Sets the file name / executable name or the like. Initially the ident 'no_name_set'. */ -void set_irp_prog_name (ident *name); +void set_irp_prog_name(ident *name); /** Returns true if the user ever set a program name */ -int irp_prog_name_is_set(void); +int irp_prog_name_is_set(void); /** Gets the file name / executable name or the like. */ @@ -109,29 +109,32 @@ const char *get_irp_prog_name (void); ir_graph *get_irp_main_irg(void); /** Sets the main routine of the compiled program. */ -void set_irp_main_irg(ir_graph *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); +void add_irp_irg(ir_graph *irg); /** Removes irg from the list of irgs and shrinks the list by one. */ -void remove_irp_irg_from_list(ir_graph *irg); +void remove_irp_irg_from_list(ir_graph *irg); /** Removes irg from the list of irgs, deallocates it and shrinks the list by one. */ -void remove_irp_irg(ir_graph *irg); +void remove_irp_irg(ir_graph *irg); + +/** returns the biggest not used irg index number */ +int get_irp_last_idx(void); /** Returns the number of ir graphs in the irp. */ -int get_irp_n_irgs(void); +int get_irp_n_irgs(void); /** Returns the ir graph at position pos in the irp. */ ir_graph *get_irp_irg(int pos); /** Sets the ir graph at position pos. */ -void set_irp_irg(int pos, ir_graph *irg); +void set_irp_irg(int pos, ir_graph *irg); /** Gets the number of graphs _and_ pseudo graphs. */ -int get_irp_n_allirgs(void); +int get_irp_n_allirgs(void); /** Returns the ir graph at position pos of all graphs (including pseudo graphs). Visits first graphs, then pseudo graphs. */ @@ -150,42 +153,42 @@ ir_type *get_glob_type(void); ir_type *get_tls_type(void); /** Adds type to the list of types in irp. */ -void add_irp_type(ir_type *typ); +void add_irp_type(ir_type *typ); /** Removes type from the list of types, deallocates it and shrinks the list by one. */ -void remove_irp_type(ir_type *typ); +void remove_irp_type(ir_type *typ); /** Returns the number of all types in the irp. */ -int get_irp_n_types(void); +int get_irp_n_types(void); /** Returns the type at position pos in the irp. */ ir_type *get_irp_type(int pos); /** Overwrites the type at position pos with another type. */ -void set_irp_type(int pos, ir_type *typ); +void set_irp_type(int pos, ir_type *typ); /** Returns the number of all modes in the irp. */ -int get_irp_n_modes(void); +int get_irp_n_modes(void); /** Returns the mode at position pos in the irp. */ ir_mode *get_irp_mode(int pos); /** Adds opcode to the list of opcodes in irp. */ -void add_irp_opcode(ir_op *opcode); +void add_irp_opcode(ir_op *opcode); /** Removes opcode from the list of opcodes, deallocates it and shrinks the list by one. */ -void remove_irp_opcode(ir_op *opcode); +void remove_irp_opcode(ir_op *opcode); /** Returns the number of all opcodes in the irp. */ -int get_irp_n_opcodes(void); +int get_irp_n_opcodes(void); /** Returns the opcode at position pos in the irp. */ ir_op *get_irp_opcode(int pos); /** Sets the generic function pointer of all opcodes to NULL */ -void clear_irp_opcodes_generic_func(void); +void clear_irp_opcodes_generic_func(void); /** Return the graph for global constants. diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index f16a8302f..103a7633a 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -255,6 +255,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) { add_immBlock_pred(start_block, projX); set_store(initial_mem); + res->index = get_irp_new_irg_idx(); #ifdef DEBUG_libfirm res->graph_nr = get_irp_new_node_nr(); #endif diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index 6e9cbadd4..0e651691f 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -68,6 +68,7 @@ static ir_prog *new_incomplete_ir_prog(void) { res->opcodes = NEW_ARR_F(ir_op *, 0); res->last_region_nr = 0; res->last_label_nr = 1; /* 0 is reserved as non-label */ + res->max_irg_idx = 0; #ifdef DEBUG_libfirm res->max_node_nr = 0; @@ -217,6 +218,10 @@ ir_graph *(get_irp_irg)(int pos){ return _get_irp_irg(pos); } +int get_irp_last_idx(void) { + return irp->max_irg_idx; +} + void set_irp_irg(int pos, ir_graph *irg) { assert(irp && irg); assert(pos < (ARR_LEN(irp->graphs))); diff --git a/ir/ir/irprog_t.h b/ir/ir/irprog_t.h index 761434804..2ceb5229b 100644 --- a/ir/ir/irprog_t.h +++ b/ir/ir/irprog_t.h @@ -120,6 +120,12 @@ get_irp_new_node_nr(void) { } #endif /* DEBUG_libfirm */ +static INLINE int +get_irp_new_irg_idx(void) { + assert(irp); + return irp->max_irg_idx++; +} + static INLINE ir_graph * _get_const_code_irg(void) { return irp->const_code_irg; diff --git a/ir/ir/irtypes.h b/ir/ir/irtypes.h index cfb741d77..a23a85b9f 100644 --- a/ir/ir/irtypes.h +++ b/ir/ir/irtypes.h @@ -483,10 +483,11 @@ struct ir_graph { irg_edges_info_t edge_info; /**< edge info for automatic outs */ ir_node **idx_irn_map; /**< Array mapping node indexes to nodes. */ + int index; /**< a unique number for each graph */ #ifdef DEBUG_libfirm - int n_outs; /**< Size wasted for outs */ - long graph_nr; /**< a unique graph number for each graph to make output - readable. */ + int n_outs; /**< Size wasted for outs */ + long graph_nr; /**< a unique graph number for each + graph to make output readable. */ #endif #ifndef NDEBUG @@ -548,6 +549,7 @@ struct ir_prog { ir_exc_region_t last_region_nr; /**< The last exception region number that was assigned. */ ir_label_t last_label_nr; /**< The highest label number for generating unique labels. */ + int max_irg_idx; /**< highest unused irg index */ #ifdef DEBUG_libfirm long max_node_nr; /**< to generate unique numbers for nodes. */ #endif