From f6776724ecac5d72d0d839be19cb08bcfd03b286 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Tue, 28 Dec 2004 13:33:40 +0000 Subject: [PATCH] new dumper for partial graph simplified makros, layout improvement of node info [r4774] --- ir/ir/irdump.c | 49 ++++++++++++++++++++++++++++++++++++++++------- ir/ir/irdump.h | 17 +++++++++++++++- ir/ir/irdump_t.h | 29 ++++++++-------------------- ir/ir/irdumptxt.c | 12 ++++++------ 4 files changed, 72 insertions(+), 35 deletions(-) diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 3f2c87411..b190aa033 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -46,10 +46,11 @@ #include "array.h" #include "pmap.h" #include "eset.h" +#include "pset.h" #if DO_HEAPANALYSIS -void dump_chi_term(FILE *FL, ir_node *n); -void dump_state(FILE *FL, ir_node *n); +void dump_irn_chi_term(FILE *FL, ir_node *n); +void dump_irn_state(FILE *FL, ir_node *n); int get_opt_dump_abstvals(void); typedef unsigned long SeqNo; SeqNo get_Block_seqno(ir_node *n); @@ -842,8 +843,8 @@ static void dump_node(FILE *F, ir_node *n) fprintf(F, "}\n"); dump_const_node_local(F, n); #if DO_HEAPANALYSIS - dump_chi_term(F, n); - dump_state(F, n); + dump_irn_chi_term(F, n); + dump_irn_state(F, n); #endif } @@ -1120,7 +1121,7 @@ dump_whole_block(FILE *F, ir_node *block) { fprintf(F, "}\n"); dump_const_node_local(F, block); #if DO_HEAPANALYSIS - dump_chi_term(F, block); + dump_irn_chi_term(F, block); #endif fprintf(F, "\n"); } @@ -1752,7 +1753,7 @@ FILE *vcg_open (ir_graph *irg, const char * suffix1, const char *suffix2) { * @param irg The graph to be dumped * @param suffix filename suffix */ -static FILE *vcg_open_name (const char *name, const char *suffix) { +FILE *vcg_open_name (const char *name, const char *suffix) { FILE *F; char *fname; /* filename to put the vcg information in */ int i, j, len = strlen(name); @@ -1818,7 +1819,9 @@ dump_ir_graph (ir_graph *irg, const char *suffix ) char *suffix1; rem = current_ir_graph; - if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; + if (strncmp(get_entity_name(get_irg_entity(irg)), + dump_file_filter, strlen(dump_file_filter)) != 0) return; + current_ir_graph = irg; if (get_interprocedural_view()) suffix1 = "-pure-ip"; else suffix1 = "-pure"; @@ -2046,6 +2049,38 @@ dump_cfg (ir_graph *irg, const char *suffix) current_ir_graph = rem; } + +static void descend_and_dump(FILE *F, ir_node *n, int depth, pset *mark_set) { + if (pset_find_ptr(mark_set, n)) return; + + pset_insert_ptr(mark_set, n); + + if (depth > 0) { + dump_whole_node(n, F); + int start = is_Block(n) ? 0 : -1; + for (int i = start; i < get_irn_arity(n); ++i) + descend_and_dump(F, get_irn_n(n, i), depth-1, mark_set); + } else { + dump_node(F, n); + /* Don't dump edges to nodes further out. These might be edges to + nodes we already dumped, if there is a shorter path to these. */ + } +} + +static int subgraph_counter = 0; +void dump_subgraph (ir_node *root, int depth, const char *suffix) { + FILE *F; + char buf[32]; + pset *mark_set = pset_new_ptr(1); + sprintf(buf, "-subg_%03d", subgraph_counter++); + F = vcg_open(get_irn_irg(root), suffix, buf); + dump_vcg_header(F, get_irg_dump_name(get_irn_irg(root)), NULL); + descend_and_dump(F, root, depth, mark_set); + vcg_close(F); + del_pset(mark_set); +} + + static int weight_overall(int rec, int loop) { return 2*rec + loop; } diff --git a/ir/ir/irdump.h b/ir/ir/irdump.h index 118117aa4..a1981bb90 100644 --- a/ir/ir/irdump.h +++ b/ir/ir/irdump.h @@ -167,6 +167,21 @@ void dump_all_ir_graphs (dump_graph_func *dump_graph, const char *suffix); */ void dump_cfg (ir_graph *irg, const char *suffix); +/** Dump a node and its predecessors forming a subgraph to a vcg file. + * + * @param root The node serving as root for the subgraph. + * @param depth Dump nodes on paths starting at root with length depth. + * @param suffix A suffix for the file name. + * + * Dumps the graph to a file. The file name is constructed from the + * name of the entity describing the procedure the passed node is + * in, suffix and the ending -subg_.vcg. nr is a unique number + * for each graph dumped. Eventually overwrites existing files. + * + * @return + * A file containing the subgraph in vcg format. + */ +void dump_subgraph (ir_node *root, int depth, const char *suffix); /* **************************************************************************** */ /* CALLGRAPH DUMPERS */ @@ -278,7 +293,7 @@ int dump_irnode_to_file (FILE *f, ir_node *n); /** Write the irnode and all its attributes to stdout. * */ -void dump_irnode (ir_node *n); +void dump_irnode (ir_node *n); /** Write the graph and all its attributes to the file passed. * Does not write the nodes. diff --git a/ir/ir/irdump_t.h b/ir/ir/irdump_t.h index 689eb777b..b91ae6cc6 100644 --- a/ir/ir/irdump_t.h +++ b/ir/ir/irdump_t.h @@ -47,34 +47,21 @@ #define ENUM_ITEM_NODE_ATTR "color: green" #define CALLGRAPH_EDGE_ATTR "calls" - -#if DEBUG_libfirm && NODEID_AS_LABEL -#define PRINT_NODEID(X) fprintf(F, "n%ld", get_irn_node_nr(X)) -#define PRINT_TYPEID(X) fprintf(F, "\"t%ld\"", get_type_nr(X)) -#define PRINT_ENTID(X) fprintf(F, "e%ld", get_entity_nr(X)) -#define PRINT_IRGID(X) fprintf(F, "g%ld", get_irg_graph_nr(X)) -#define PRINT_CONSTID(X,Y) fprintf(F, "\"n%ldn%ld\"", get_irn_node_nr(X),get_irn_node_nr(Y)) +#define PRINT_NODEID(X) fprintf(F, "n%ld", get_irn_node_nr(X)) +#define PRINT_TYPEID(X) fprintf(F, "\"t%ld\"", get_type_nr(X)) +#define PRINT_ENTID(X) fprintf(F, "e%ld", get_entity_nr(X)) +#define PRINT_IRGID(X) fprintf(F, "g%ld", get_irg_graph_nr(X)) +#define PRINT_CONSTID(X,Y) fprintf(F, "\"n%ldn%ld\"", get_irn_node_nr(X),get_irn_node_nr(Y)) #define PRINT_CONSTBLKID(X,Y) fprintf(F, "n%ldb%ld", get_irn_node_nr(X),get_irn_node_nr(Y)) -#define PRINT_LOOPID(X) fprintf(F, "l%d", get_loop_loop_nr(X)) -#define PRINT_ITEMID(X,Y) fprintf(F, "i%ldT%d", get_type_nr(X), (Y)) - -#else -#define PRINT_NODEID(X) fprintf(F, "n%p", (void *)(X)) -#define PRINT_TYPEID(X) fprintf(F, "\"t%p\"", (void *)(X)) -#define PRINT_ENTID(X) fprintf(F, "e%p", (void *)(X)) -#define PRINT_IRGID(X) fprintf(F, "g%p",(void *)(X)) -#define PRINT_CONSTID(X,Y) fprintf(F, "\"n%pn%p\"", (void*)(X), (void*)(Y)) -#define PRINT_CONSTBLKID(X,Y) fprintf(F, "n%pb%p", (void*)(X), (void*)(Y)) -#define PRINT_LOOPID(X) fprintf(F, "l%p", (void *)(X)) -#define PRINT_ITEMID(X,Y) fprintf(F, "i%pT%d", (void *) (X), (Y)) -#endif - +#define PRINT_LOOPID(X) fprintf(F, "l%d", get_loop_loop_nr(X)) +#define PRINT_ITEMID(X,Y) fprintf(F, "i%ldT%d", get_type_nr(X), (Y)) extern int dump_dominator_information_flag; extern const char *dump_file_filter; extern bool opt_dump_pointer_values_to_info; FILE *vcg_open (ir_graph *irg, const char * suffix1, const char *suffix2); +FILE *vcg_open_name (const char *name, const char *suffix); void dump_vcg_header(FILE *F, const char *name, const char *orientation); const char *get_irg_dump_name(ir_graph *irg); void vcg_close (FILE *F); diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index 7d6a60999..03288b7ea 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -125,7 +125,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { if ((get_irp_ip_view_state() != ip_view_no) && (get_irn_opcode(n) == iro_Filter || get_irn_opcode(n) == iro_Block)) { - fprintf(F, " inter arity: %d", get_irn_inter_arity(n)); + fprintf(F, " inter arity: %d\n", get_irn_inter_arity(n)); fprintf(F, " inter pred nodes: \n"); for ( i = 0; i < get_irn_inter_arity(n); ++i) { fprintf(F, " %d: %s ", i, is_intra_backedge(n, i) ? "be" : " "); @@ -150,20 +150,20 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { fprintf(F, "\n"); } - /* Loop node Someone else please tell me what's wrong ... + /* Loop node. Someone else please tell me what's wrong ... */ if (get_irn_loop(n)) { ir_loop *loop = get_irn_loop(n); assert(loop); - fprintf(F, " in loop %d with depth %d\n", + fprintf(F, " in loop %d with depth %d\n", get_loop_loop_nr(loop), get_loop_depth(loop)); } - */ + /* Source types */ switch (get_irn_opcode(n)) { case iro_Block: { - fprintf(F, " block visited: %ld", get_Block_block_visited(n)); - fprintf(F, " dominator info: not implemented\n"); + fprintf(F, " block visited: %ld\n", get_Block_block_visited(n)); + fprintf(F, " dominator info: output not implemented\n"); /* not dumped: graph_arr */ /* not dumped: mature */ } break; -- 2.20.1