From ba4f8f4ad4379b0c8cb467dc79bc1b1f92958f81 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Tue, 25 Feb 2003 09:58:43 +0000 Subject: [PATCH] Fixed several stuff, DDM messages, visibility of graph_nr, test of DEBUG in irdump [r825] --- ir/ir/irdump.c | 71 ++++++++++++++++++++++++----------------------- ir/ir/irgraph.c | 12 +++++--- ir/ir/irgraph.h | 2 ++ ir/ir/irgraph_t.h | 2 ++ ir/ir/irnode.h | 71 +++++++++++++++++++++++------------------------ 5 files changed, 82 insertions(+), 76 deletions(-) diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 16e8fc526..12d8b6f70 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -12,28 +12,32 @@ # include #endif +# include +# include + # include "irnode_t.h" # include "irgraph_t.h" -# include "irprog.h" -# include "irdump.h" -# include "panic.h" -# include # include "entity_t.h" -# include -# include "array.h" # include "irop_t.h" -# include "tv.h" -# include "type_or_entity.h" +# include "firm_common_t.h" + +# include "irdump.h" + # include "irgwalk.h" # include "typewalk.h" +# include "irprog.h" +# include "tv.h" +# include "type_or_entity.h" # include "irouts.h" # include "irdom.h" -# include "firm_common_t.h" -# include "irloop.h" +# include "irloop.h" + +# include "panic.h" +# include "array.h" +# include "pmap.h" # include "exc.h" -# include "pmap.h" /* Attributes of nodes */ #define DEFAULT_NODE_ATTR "" @@ -847,8 +851,12 @@ void dump_entity_node(entity *ent) { } xfprintf(F, "\nname: %I\nld_name: %I", get_entity_ident(ent), get_entity_ld_ident(ent)); fprintf(F, "\noffset: %d", get_entity_offset(ent)); - if (is_method_type(get_entity_type(ent))) - { fprintf (F, "\nirg = "); PRINT_IRGID(get_entity_irg(ent)); } + if (is_method_type(get_entity_type(ent))) { + if (get_entity_irg(ent)) /* can be null */ + { fprintf (F, "\nirg = "); PRINT_IRGID(get_entity_irg(ent)); } + else + { fprintf (F, "\nirg = NULL"); } + } fprintf(F, "\"\n}\n"); } @@ -870,10 +878,10 @@ dump_type_info (type_or_ent *tore, void *env) { /* skip this to reduce graph. Member edge of type is parallel to this edge. * fprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " ENT_OWN_EDGE_ATTR "}\n", ent, get_entity_owner(ent));*/ - PRINT_ENT_TYPE_EDGE(ent,get_entity_type(ent),ENT_TYPE_EDGE_ATTR); + PRINT_ENT_TYPE_EDGE(ent, get_entity_type(ent), ENT_TYPE_EDGE_ATTR); if(is_class_type(get_entity_owner(ent))) { for(i = 0; i < get_entity_n_overwrites(ent); i++){ - PRINT_ENT_ENT_EDGE(ent,get_entity_overwrites(ent, i), ENT_OVERWRITES_EDGE_ATTR); + PRINT_ENT_ENT_EDGE(ent, get_entity_overwrites(ent, i), ENT_OVERWRITES_EDGE_ATTR); } } /* attached subgraphs */ @@ -881,8 +889,8 @@ dump_type_info (type_or_ent *tore, void *env) { if (is_atomic_entity(ent)) { value = get_atomic_ent_value(ent); if (value) { - PRINT_ENT_NODE_EDGE(ent,value,ENT_VALUE_EDGE_ATTR,i); - /* + PRINT_ENT_NODE_EDGE(ent, value, ENT_VALUE_EDGE_ATTR, i); + /* fprintf (F, "edge: { sourcename: \"%p\" targetname: \"", GET_ENTID(ent)); PRINT_NODEID(value); fprintf(F, "\" " ENT_VALUE_EDGE_ATTR "\"}\n"); @@ -896,12 +904,12 @@ dump_type_info (type_or_ent *tore, void *env) { if (value) { PRINT_ENT_NODE_EDGE(ent,value,ENT_VALUE_EDGE_ATTR,i); dump_const_expression(value); - PRINT_ENT_ENT_EDGE(ent,get_compound_ent_value_member(ent, i),ENT_CORR_EDGE_ATTR,i); + PRINT_ENT_ENT_EDGE(ent, get_compound_ent_value_member(ent, i), ENT_CORR_EDGE_ATTR, i); /* - fprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " - ENT_CORR_EDGE_ATTR "}\n", GET_ENTID(ent), - get_compound_ent_value_member(ent, i), i); - */ + fprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " + ENT_CORR_EDGE_ATTR "}\n", GET_ENTID(ent), + get_compound_ent_value_member(ent, i), i); + */ } } } @@ -909,31 +917,24 @@ dump_type_info (type_or_ent *tore, void *env) { } break; case k_type: { -#ifndef DEBUG type *tp = (type *)tore; -#endif - - print_type_node(tp); /* and now the edges */ switch (get_type_tpop_code(tp)) { case tpo_class: { - for (i=0; i < get_class_n_supertypes(tp); i++) - { - PRINT_TYPE_TYPE_EDGE(tp,get_class_supertype(tp, i),TYPE_SUPER_EDGE_ATTR); + for (i=0; i < get_class_n_supertypes(tp); i++) { + PRINT_TYPE_TYPE_EDGE(tp,get_class_supertype(tp, i),TYPE_SUPER_EDGE_ATTR); } - for (i=0; i < get_class_n_members(tp); i++) - { - PRINT_TYPE_ENT_EDGE(tp,get_class_member(tp, i),TYPE_MEMBER_EDGE_ATTR); + for (i=0; i < get_class_n_members(tp); i++) { + PRINT_TYPE_ENT_EDGE(tp,get_class_member(tp, i),TYPE_MEMBER_EDGE_ATTR); } } break; case tpo_struct: { - for (i=0; i < get_struct_n_members(tp); i++) - { - PRINT_TYPE_ENT_EDGE(tp,get_struct_member(tp, i),TYPE_MEMBER_EDGE_ATTR); + for (i=0; i < get_struct_n_members(tp); i++) { + PRINT_TYPE_ENT_EDGE(tp,get_struct_member(tp, i),TYPE_MEMBER_EDGE_ATTR); } } break; case tpo_method: diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index b21bf0fa1..4cdd97e0c 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -23,7 +23,7 @@ # include "mangle.h" ir_graph *current_ir_graph; -INLINE ir_graph *get_current_ir_graph() { +INLINE ir_graph *get_current_ir_graph(void) { return current_ir_graph; } INLINE void set_current_ir_graph(ir_graph *graph) { @@ -32,13 +32,18 @@ INLINE void set_current_ir_graph(ir_graph *graph) { bool interprocedural_view = false; -INLINE bool get_interprocedural_view() { +INLINE bool get_interprocedural_view(void) { return interprocedural_view; } INLINE void set_interprocedural_view(bool state) { interprocedural_view = state; } +static ident* frame_type_suffix = NULL; +void init_irgraph(void) { + frame_type_suffix = id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX)); +} + #if USE_EXPLICIT_PHI_IN_STACK /* really defined in ircons.c */ typedef struct Phi_in_stack Phi_in_stack; @@ -106,8 +111,7 @@ new_ir_graph (entity *ent, int n_loc) /** contain "inner" methods as in Pascal. **/ - res->frame_type = new_type_class(mangle(get_entity_ident(ent), - id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX)))); + res->frame_type = new_type_class(mangle(get_entity_ident(ent), frame_type_suffix)); /* Remove type from type list. Must be treated differently than other types. */ remove_irp_type_from_list(res->frame_type); diff --git a/ir/ir/irgraph.h b/ir/ir/irgraph.h index d5dfaff7e..a779049d0 100644 --- a/ir/ir/irgraph.h +++ b/ir/ir/irgraph.h @@ -147,6 +147,8 @@ void set_irg_unknown (ir_graph *irg, ir_node *node); int get_irg_n_locs (ir_graph *irg); +INLINE long get_irg_graph_nr(ir_graph *irg); + /********************************************************************************/ /* States of an ir_graph. */ /********************************************************************************/ diff --git a/ir/ir/irgraph_t.h b/ir/ir/irgraph_t.h index f97063093..d928fbab6 100644 --- a/ir/ir/irgraph_t.h +++ b/ir/ir/irgraph_t.h @@ -78,6 +78,8 @@ struct ir_graph { #endif }; +void init_irgraph(void); + INLINE long get_irg_graph_nr(ir_graph *irg) ; /** Make a rudimentary ir graph for the constant code. diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index affc7fb1a..cf898ae89 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -557,45 +557,42 @@ ir_node *get_fragile_op_mem(ir_node *node); /*@{*/ /** Makros for debugging the libfirm */ #ifdef __GNUC__ -/* - * GNU C has the __FUNCTION__ extension - */ -#define DDMSG printf("%s(l.%i)\n", __FUNCTION__, __LINE__) -#define DDMSG1(X) printf("%s(l.%i) %s\n", __FUNCTION__, __LINE__, id_to_str(get_irn_opident(X))) -#define DDMSG2(X) printf("%s(l.%i) %s%s: %ld\n", __FUNCTION__, __LINE__, id_to_str(get_irn_opident(X)), id_to_str(get_irn_modeident(X)), get_irn_node_nr(X)) -#define DDMSG3(X) printf("%s(l.%i) %s: %p\n", __FUNCTION__, __LINE__, print_firm_kind(X), (X)) -#define DDMSG4(X) xprintf("%s(l.%i) %I %I: %p\n", __FUNCTION__, __LINE__, get_type_tpop_nameid(X), get_type_ident(X), (X)) -#define DDMSG5(X) printf("%s%s: %ld", id_to_str(get_irn_opident(X)), id_to_str(get_irn_modeident(X)), get_irn_node_nr(X)) - +/* GNU C has the extension */ +#define __MYFUNC__ __FUNCTION__ +#else +/* use Filename instead */ +#define __MYFUNC__ __FILE__ +#endif -#define DDMN(X) xprintf("%s(l.%i) %I%I: %ld (%p)\n", __FUNCTION__, __LINE__, get_irn_opident(X), get_irn_modeident(X), get_irn_node_nr(X), (X)) -#define DDMNB(X) xprintf("%I%I: %ld (in block %ld)\n", get_irn_opident(X), get_irn_modeident(X), get_irn_node_nr(X), get_irn_node_nr(get_nodes_Block(X))) -#define DDMT(X) xprintf("%s(l.%i) %I %I: %p\n", __FUNCTION__, __LINE__, get_type_tpop_nameid(X), get_type_ident(X), (X)) -#define DDME(X) xprintf("%s(l.%i) %I: %p\n", __FUNCTION__, __LINE__, get_entity_ident(X), (X)) -#define DDMEO(X) xprintf("%s(l.%i) %I (own: %I): %p\n", __FUNCTION__, __LINE__, get_entity_ident(X), get_type_ident(get_entity_owner(X)), (X)) -#define DDMG(X) xprintf("%s(l.%i) %I: %p\n", __FUNCTION__, __LINE__, get_irg_ent(get_entity_ident(X)), (X)) +/** Output the firm kind of the node */ +#define DDMK(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, \ + print_firm_kind(X), (X)); +/** Output information about a node */ +#define DDMN(X) printf("%s(l.%i) %s%s: %ld (%p)\n", __MYFUNC__, __LINE__, \ + get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), (X)) +/** Output information about a node and its block */ +#define DDMNB(X) printf("%s%s: %ld (in block %ld)\n", get_irn_opname(X), \ + get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), \ + get_irn_node_nr(get_nodes_Block(X))) +/** Output information about a type */ +#define DDMT(X) printf("%s(l.%i) %s %s: %ld (%p)\n", __MYFUNC__, __LINE__, \ + get_type_tpop_name(X), get_type_name(X), get_type_nr(X), (X)) +/** Output information about an entity */ +#define DDME(X) printf("%s(l.%i) %s: %ld (%p\n", __MYFUNC__, __LINE__, \ + get_entity_name(X), get_entity_nr(X), (X)) +/** Output information about an entity and its owner */ +#define DDMEO(X) printf("%s(l.%i) %s (own: %s): %ld (%p)\n", __MYFUNC__, __LINE__, \ + get_entity_name(X), get_type_name(get_entity_owner(X)), get_entity_nr(X), (X)) +/** Output information about a graph */ +#define DDMG(X) printf("%s(l.%i) %s: %ld (%p)\n", __MYFUNC__, __LINE__, \ + get_entity_name(get_irg_ent(X)), get_irg_graph_nr(X), (X)) +/** Output information about an ident */ +#define DDMI(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, \ + id_to_str(X), (X)) +/** Output information about a mode */ +#define DDMM(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, \ + get_mode_name(X), (X)) -#else -/* - * use Filename instead - */ -#define DDMSG printf("%s(l.%i)\n", __FILE__, __LINE__) -#define DDMSG1(X) printf("%s(l.%i) %s\n", __FILE__, __LINE__, id_to_str(get_irn_opident(X))) -#define DDMSG2(X) printf("%s(l.%i) %s%s: %ld\n", __FILE__, __LINE__, id_to_str(get_irn_opident(X)), id_to_str(get_irn_modeident(X)), get_irn_node_nr(X)) -#define DDMSG3(X) printf("%s(l.%i) %s: %p\n", __FILE__, __LINE__, print_firm_kind(X), (X)) -#define DDMSG4(X) xprintf("%s(l.%i) %I %I: %p\n", __FILE__, __LINE__, get_type_tpop_nameid(X), get_type_ident(X), (X)) -#define DDMSG5(X) printf("%s%s: %ld", id_to_str(get_irn_opident(X)), id_to_str(get_irn_modeident(X)), get_irn_node_nr(X)) - - -#define DDMN(X) xprintf("%s(l.%i) %I%I: %ld (%p)\n", __FILE__, __LINE__, get_irn_opident(X), get_irn_modeident(X), get_irn_node_nr(X), (X)) -#define DDMNB(X) xprintf("%I%I: %ld (in block %ld)\n", get_irn_opident(X), get_irn_modeident(X), get_irn_node_nr(X), get_irn_node_nr(get_nodes_Block(X))) -#define DDMT(X) xprintf("%s(l.%i) %I %I: %p\n", __FILE__, __LINE__, get_type_tpop_nameid(X), get_type_ident(X), (X)) -#define DDME(X) xprintf("%s(l.%i) %I: %p\n", __FILE__, __LINE__, get_entity_ident(X), (X)) -#define DDMG(X) xprintf("%s(l.%i) %I: %p\n", __FILE__, __LINE__, get_irg_ent(get_entity_ident(X)), (X)) -#define DDMI(X) xprintf("%s(l.%i) %I: %p\n", __FILE__, __LINE__, (X), (X)) -#define DDMM(X) xprintf("%s(l.%i) %I: %p\n", __FILE__, __LINE__, get_mode_ident(X), (X)) - -#endif /* __GNUC__ */ /*@}*/ /* Macros for debug.. */ /*@}*/ /* end of ir_node group definition */ -- 2.20.1