# include "irdump.h"
# include "panic.h"
# include <string.h>
-# include "entity.h"
+# include "entity_t.h"
# include <stdlib.h>
# include "array.h"
# include "irop_t.h"
# include "irgwalk.h"
# include "typewalk.h"
# include "irouts.h"
+#include "irdom.h"
/* Attributes of nodes */
#define DEFAULT_NODE_ATTR ""
#define BLOCK_EDGE_ATTR "class: 2 priority: 2 linestyle: dotted"
#define CF_EDGE_ATTR "color: red"
#define MEM_EDGE_ATTR "color: blue"
+#define DOMINATOR_EDGE_ATTR "color: red"
/* Attributes of edges between Firm nodes and type/entity nodes */
#define NODE2TYPE_EDGE_ATTR "class: 2 priority: 2 linestyle: dotted"
#define PRINT_NODEID(X) fprintf(F, "%p", X)
#endif
+/* A suffix to manipulate the file name. */
+char *dump_file_suffix = NULL;
+
/* file to dump to */
static FILE *F;
int dump_keepalive = 0;
/* A compiler option to dump the out edges in dump_ir_graph */
int dump_out_edge_flag = 0;
-
+int dump_dominator_information_flag = 0;
/* A global variable to record output of the Bad node. */
int Bad_dumped;
/* SymConst */
} else if (n->op->code == iro_SymConst) {
if (get_SymConst_kind(n) == linkage_ptr_info) {
- xfprintf (F, "%I", get_SymConst_ptrinfo(n));
+ /* don't use get_SymConst_ptr_info as it mangles the name. */
+ xfprintf (F, "SymC %I", n->attr.i.tori.ptrinfo);
} else {
assert(get_kind(get_SymConst_type(n)) == k_type);
assert(get_type_ident(get_SymConst_type(n)));
- xfprintf (F, "%s ", id_to_str(get_type_ident(get_SymConst_type(n))));
+ xfprintf (F, "SymC %I ", get_type_ident(get_SymConst_type(n)));
if (get_SymConst_kind == type_tag)
xfprintf (F, "tag");
else
break;
case iro_Sel: {
assert(get_kind(get_Sel_entity(n)) == k_entity);
- xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
+ xfprintf (F, "%I", get_entity_ident(get_Sel_entity(n)));
} break;
default:
} /* end switch */
case iro_Sel:
assert(get_kind(get_Sel_entity(n)) == k_entity);
xfprintf (F, "\"%I ", get_irn_opident(n));
- xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
+ xfprintf (F, "%I", get_entity_ident(get_Sel_entity(n)));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_SymConst:
switch (get_entity_visibility(ent)) {
case local: fprintf (F, "local\n"); break;
case external_visible: fprintf (F, "external_visible\n"); break;
- case external_allocated: fprintf (F, "external_allocate\nd");break;
+ case external_allocated: fprintf (F, "external_allocate\n");break;
}
switch (get_entity_variability(ent)) {
case uninitialized: fprintf (F, "uninitialized");break;
case part_constant: fprintf (F, "part_constant");break;
case constant: fprintf (F, "constant"); break;
}
+ if (is_method_type(get_entity_type(ent)))
+ xfprintf (F, "\n irg = %p ", get_entity_irg(ent));
xfprintf(F, "\"}\n");
/* The Edges */
+ /* skip this to reduce graph. Member edge of type is parallel to this edge. *
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
- ENT_OWN_EDGE_ATTR "}\n", ent, get_entity_owner(ent));
+ ENT_OWN_EDGE_ATTR "}\n", ent, get_entity_owner(ent));*/
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
ENT_TYPE_EDGE_ATTR "}\n", ent, get_entity_type(ent));
for(i = 0; i < get_entity_n_overwrites(ent); i++)
/** open file for vcg graph */
ent = get_irg_ent(irg);
- id = get_entity_ld_ident (ent);
+ id = ent->ld_name ? ent->ld_name : ent->name;
+ /* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */
len = id_to_strlen (id);
cp = id_to_str (id);
- fname = malloc (len + 5 + strlen(suffix));
+ if (dump_file_suffix)
+ fname = malloc (len + 5 + strlen(suffix) + strlen(dump_file_suffix));
+ else
+ fname = malloc (len + 5 + strlen(suffix));
strncpy (fname, cp, len); /* copy the filename */
fname[len] = '\0';
+ if (dump_file_suffix) strcat (fname, dump_file_suffix); /* append file suffix */
strcat (fname, suffix); /* append file suffix */
-
- fname = malloc (len + 5 + strlen(suffix));
- strncpy (fname, cp, len); /* copy the filename */
- fname[len] = '\0'; /* ensure string termination */
- /*strcpy (fname, cp); * copy the filename *
- this produces wrong, too long strings in conjuction with the
- jocca frontend. The \0 seems to be missing. */
- strcat (fname, suffix); /* append file suffix */
strcat (fname, ".vcg"); /* append the .vcg suffix */
F = fopen (fname, "w"); /* open file for writing */
if (!F) {
/***********************************************************************/
int node_floats(ir_node *n) {
+
return ((get_op_pinned(get_irn_op(n)) == floats) &&
(get_irg_pinned(current_ir_graph) == floats));
}
if (get_irn_opcode(block) == iro_Block) {
/* This is a block. Dump a node for the block. */
- xfprintf (F, "node: {title: \"%p\" label: \"%I\"}", block,
- block->op->name);
+ xfprintf (F, "node: {title:\""); PRINT_NODEID(block);
+ xfprintf (F, "\" label: \"%I ", block->op->name); PRINT_NODEID(block);
+ xfprintf (F, "\" ");
+ if (dump_dominator_information_flag)
+ xfprintf(F, "info1:\"dom depth %d\"", get_Block_dom_depth(block));
+ xfprintf (F, "}\n");
/* Dump the edges */
- for ( i = 0; i < get_Block_n_cfgpreds(block); i++) {
- pred = get_nodes_Block(skip_Proj(get_Block_cfgpred(block, i)));
+ for ( i = 0; i < get_Block_n_cfgpreds(block); i++)
+ if (get_irn_op(skip_Proj(get_Block_cfgpred(block, i))) != op_Bad) {
+ pred = get_nodes_Block(skip_Proj(get_Block_cfgpred(block, i)));
+ xfprintf (F, "edge: { sourcename: \"");
+ PRINT_NODEID(block);
+ fprintf (F, "\" targetname: \"");
+ PRINT_NODEID(pred);
+ fprintf (F, "\" }\n");
+ }
+
+ /* Dump dominator edge */
+ if (dump_dominator_information_flag && get_Block_idom(block)) {
+ pred = get_Block_idom(block);
xfprintf (F, "edge: { sourcename: \"");
PRINT_NODEID(block);
fprintf (F, "\" targetname: \"");
PRINT_NODEID(pred);
- fprintf (F, "\" }\n");
+ fprintf (F, "\" " DOMINATOR_EDGE_ATTR "}\n");
}
}
}
void
dump_cfg (ir_graph *irg)
{
+ int rem = dump_dominator_information_flag;
vcg_open (irg, "-cfg");
+ if (get_irg_dom_state(irg) != dom_consistent)
+ dump_dominator_information_flag = 0;
+
/* walk over the blocks in the graph */
irg_block_walk(irg->end, dump_block_to_cfg, NULL, NULL);
+ dump_dominator_information_flag = rem;
vcg_close();
}
/* To turn off display of edge labels. Edge labels offen cause xvcg to
abort with a segmentation fault. */
-void turn_of_edge_labels() {
+void turn_off_edge_labels() {
edge_label = 0;
}
-void dump_constant_entity_values() {
+void turn_off_constant_entity_values() {
const_entities = 0;
}
void dump_out_edges() {
dump_out_edge_flag = 1;
}
+
+void dump_dominator_information() {
+ dump_dominator_information_flag = 1;
+}