#include "irdom.h"
#include "irloop.h"
#include "callgraph.h"
+#include "irextbb_t.h"
#include "irvrfy.h"
}
/**
- * Walker, clears tzhe private link field
+ * Walker, clears the private link field.
*/
static void clear_link(ir_node * node, void * env) {
ird_set_irn_link(node, NULL);
* graphs not visited.
* Free the list with DEL_ARR_F().
*/
-static ir_node ** construct_block_lists(ir_graph *irg) {
+static ir_node **construct_block_lists(ir_graph *irg) {
int i, rem_view = get_interprocedural_view();
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
return ird_get_irg_link(irg);
}
+typedef struct _list_tuple {
+ ir_node **blk_list;
+ ir_extblk **extbb_list;
+} list_tuple;
+
+/** Construct lists to walk ir extended block-wise.
+ * Free the lists in the tuple with DEL_ARR_F().
+ */
+static list_tuple *construct_extblock_lists(ir_graph *irg) {
+ ir_node **blk_list = construct_block_lists(irg);
+ int i;
+ ir_graph *rem = current_ir_graph;
+ list_tuple *lists = xmalloc(sizeof(*lists));
+
+ current_ir_graph = irg;
+
+ lists->blk_list = NEW_ARR_F(ir_node *, 0);
+ lists->extbb_list = NEW_ARR_F(ir_extblk *, 0);
+
+ for (i = ARR_LEN(blk_list) - 1; i >= 0; --i) {
+ ir_extblk *ext;
+
+ if (is_Block(blk_list[i])) {
+ ext = get_Block_extbb(blk_list[i]);
+
+ if (extbb_not_visited(ext)) {
+ ARR_APP1(ir_extblk *, lists->extbb_list, ext);
+ mark_extbb_visited(ext);
+ }
+ }
+ else
+ ARR_APP1(ir_node *, lists->blk_list, blk_list[i]);
+ }
+
+ current_ir_graph = rem;
+ DEL_ARR_F(blk_list);
+ ird_set_irg_link(irg, lists);
+ return lists;
+}
+
/*******************************************************************/
/* flags to steer output */
/*******************************************************************/
static DUMP_NODE_VCGATTR_FUNC dump_node_vcgattr_hook = NULL;
/* set the hook */
-void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook)
-{
+void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook) {
dump_node_vcgattr_hook = hook;
}
/** Returns true if dump file filter is not set, or if it is a
* prefix of name. */
int is_filtered_dump_name(ident *name) {
+ if (!dump_file_filter_id) return 1;
return id_is_prefix(dump_file_filter_id, name);
}
fprintf (F, "%s[%s]", get_irn_opname(n), get_mode_name_ex(get_Load_mode(n), &bad));
break;
-default_case:
default: {
+default_case:
fprintf (F, "%s", get_irn_opname(n));
}
}
/**
- * Dump the tpe of a node n to a file F if it's known.
+ * Dump the type of a node n to a file F if it's known.
*/
static int dump_node_typeinfo(FILE *F, ir_node *n) {
int bad = 0;
}
/**
- * Dump addinional node attributes of some nodes to a file F.
+ * Dump additional node attributes of some nodes to a file F.
*/
static INLINE int
dump_node_nodeattr(FILE *F, ir_node *n)
return bad;
}
+#include <math.h>
+#include "execution_frequency.h"
+#include "callgraph.h"
-/** Dumps a node label without the enclosing ". */
-static int dump_node_label(FILE *F, ir_node *n) {
+void dump_node_ana_vals(FILE *F, ir_node *n) {
+ return;
+ fprintf(F, " %lf*(%2.0lf + %2.0lf) = %2.0lf ",
+ get_irn_exec_freq(n),
+ get_irg_method_execution_frequency(get_irn_irg(n)),
+ pow(5, get_irg_recursion_depth(get_irn_irg(n))),
+ get_irn_exec_freq(n) * (get_irg_method_execution_frequency(get_irn_irg(n)) + pow(5, get_irg_recursion_depth(get_irn_irg(n))))
+ );
+}
+
+
+/* Dumps a node label without the enclosing ". */
+int dump_node_label(FILE *F, ir_node *n) {
int bad = 0;
bad |= dump_node_opcode(F, n);
}
/**
- * checks wheater a node is "constant-like", ie can be treated "block-less"
+ * checks whether a node is "constant-like" ie can be treated "block-less"
*/
static INLINE
bool is_constlike_node(ir_node *n) {
bad = ! irn_vrfy_irg_dump(n, current_ir_graph, &p);
bad |= dump_node_label(F, n);
+ dump_node_ana_vals(F, n);
//dump_node_ana_info(F, n);
fprintf(F, "\" ");
bad |= dump_node_info(F, n);
current_ir_graph = get_const_code_irg();
irg_walk(value, dump_const_node, NULL, F);
/* Decrease visited flag so that we walk with the same flag for the next
- expresssion. This guarantees that we don't dump the same node twice,
+ expression. This guarantees that we don't dump the same node twice,
as for const expressions cse is performed to save memory. */
set_irg_visited(current_ir_graph, get_irg_visited(current_ir_graph) -1);
current_ir_graph = rem;
current_ir_graph = rem;
}
-/** Dumps an irg as a graph.
+/** Dumps an irg as a graph clustered by block nodes.
* If interprocedural view edges can point to nodes out of this graph.
*/
static void dump_graph_from_list(FILE *F, ir_graph *irg) {
fprintf(F, "}\n\n");
}
+/** dumps a graph extended block-wise. Expects all blockless nodes in arr in irgs link.
+ * The outermost nodes: blocks and nodes not op_pin_state_pinned, Bad, Unknown. */
+static void
+dump_extblock_graph(FILE *F, ir_graph *irg) {
+ int i;
+ ir_graph *rem = current_ir_graph;
+ ir_extblk **arr = ird_get_irg_link(irg);
+ current_ir_graph = irg;
+
+ compute_extbb(irg);
+ for (i = ARR_LEN(arr) - 1; i >= 0; --i) {
+ ir_extblk *extbb = arr[i];
+ ir_node *leader = extbb->blks[0];
+ int j;
+
+ fprintf(F, "graph: { title: \"");
+ PRINT_EXTBBID(leader);
+ fprintf(F, "\" label: \"ExtBB %ld\" status:clustered color:lightgreen\n",
+ get_irn_node_nr(leader));
+
+ for (j = ARR_LEN(extbb->blks) - 1; j >= 0; --j) {
+ ir_node * node = extbb->blks[j];
+ if (is_Block(node)) {
+ /* Dumps the block and all the nodes in the block, which are to
+ be found in Block->link. */
+ dump_whole_block(F, node);
+ } else {
+ /* Nodes that are not in a Block. */
+ dump_node(F, node);
+ if (is_Bad(get_nodes_block(node)) && !node_floats(node)) {
+ dump_const_block_local(F, node);
+ }
+ dump_ir_data_edges(F, node);
+ }
+ }
+ fprintf(F, "}\n");
+ }
+
+ if (dump_loop_information_flag && (get_irg_loopinfo_state(irg) & loopinfo_valid))
+ dump_loop_nodes_into_graph(F, irg);
+
+ current_ir_graph = rem;
+ free_extbb(irg);
+}
+
+
/*******************************************************************/
/* Basic type and entity nodes and edges. */
/*******************************************************************/
}
}
-
+#if 0
static int print_type_info(FILE *F, type *tp) {
int bad = 0;
default: break;
} /* switch type */
}
-
+#endif
static void print_typespecific_vcgattr(FILE *F, type *tp) {
switch (get_type_tpop_code(tp)) {
} /* switch type */
}
+
+/* Why not dump_type_node as the others? */
static int print_type_node(FILE *F, type *tp)
{
int bad = 0;
PRINT_TYPEID(tp);
fprintf (F, " label: \"%s %s\"", get_type_tpop_name(tp), get_type_name_ex(tp, &bad));
fprintf (F, " info1: \"");
+#if 0
bad |= print_type_info(F, tp);
print_typespecific_info(F, tp);
+#else
+ dump_type_to_file(F, tp, dump_verbosity_max);
+#endif
fprintf (F, "\"");
print_typespecific_vcgattr(F, tp);
fprintf (F, "}\n");
return bad;
}
+int dump_type_node(FILE *F, type *tp) {
+ return print_type_node(F, tp);
+}
+
+
#define X(a) case a: fprintf(F, #a); break
void dump_entity_node(FILE *F, entity *ent, int color)
{
current_ir_graph = rem;
}
-
-void
-dump_ir_block_graph (ir_graph *irg, const char *suffix)
+/* Dump a firm graph without explicit block nodes. */
+void dump_ir_block_graph (ir_graph *irg, const char *suffix)
{
FILE *f;
int i;
construct_block_lists(irg);
+ /*
+ * If we are in the interprocedural view, we dump not
+ * only the requested irg but also all irgs that can be reached
+ * from irg.
+ */
for (i = 0; i < get_irp_n_irgs(); i++) {
ir_node **arr = ird_get_irg_link(get_irp_irg(i));
if (arr) {
vcg_close(f);
}
-/** dumps a graph with type information */
+/* Dump a firm graph without explicit block nodes but grouped in extended blocks. */
+void dump_ir_extblock_graph (ir_graph *irg, const char *suffix)
+{
+ FILE *F;
+ int i;
+ char *suffix1;
+
+ if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg))))
+ return;
+
+ compute_extbb(irg);
+
+ if (get_interprocedural_view()) suffix1 = "-ip";
+ else suffix1 = "";
+ F = vcg_open(irg, suffix, suffix1);
+ dump_vcg_header(F, get_irg_dump_name(irg), NULL);
+
+ construct_extblock_lists(irg);
+
+ fprintf(F, "graph: { title: \"");
+ PRINT_IRGID(irg);
+ fprintf(F, "\" label: \"%s\" status:clustered color:white \n",
+ get_ent_dump_name(get_irg_entity(irg)));
+
+ for (i = 0; i < get_irp_n_irgs(); i++) {
+ ir_graph *irg = get_irp_irg(i);
+ list_tuple *lists = ird_get_irg_link(irg);
+
+ if (lists) {
+ /* dump the extended blocks first */
+ if (ARR_LEN(lists->extbb_list)) {
+ ird_set_irg_link(irg, lists->extbb_list);
+ dump_extblock_graph(F, irg);
+ }
+
+ /* we may have blocks without extended blocks, bad for instance */
+ if (ARR_LEN(lists->blk_list)) {
+ ird_set_irg_link(irg, lists->blk_list);
+ dump_block_graph(F, irg);
+ }
+
+ DEL_ARR_F(lists->extbb_list);
+ DEL_ARR_F(lists->blk_list);
+ xfree(lists);
+ }
+ }
+
+ /* Close the vcg information for the irg */
+ fprintf(F, "}\n\n");
+
+ vcg_close(F);
+ free_extbb(irg);
+}
+
+/* dumps a graph with type information */
void
dump_ir_graph_w_types (ir_graph *irg, const char *suffix)
{
PRINT_NODEID(block);
fprintf (F, "\" ");
fprintf(F, "info1:\"");
+
+#if 0
if (dump_dominator_information_flag) {
fprintf(F, "dom depth %d\n", get_Block_dom_depth(block));
fprintf(F, "tree pre num %d\n", get_Block_dom_tree_pre_num(block));
fprintf(F, "max subtree pre num %d\n", get_Block_dom_max_subtree_pre_num(block));
- }
+ }
/* show arity and possible Bad predecessors of the block */
fprintf(F, "arity: %d\n", get_Block_n_cfgpreds(block));
for (fl = i = 0; i < get_Block_n_cfgpreds(block); ++i) {
ir_node *pred = get_Block_cfgpred(block, i);
if (is_Bad(pred)) {
- if (! fl)
- fprintf(F, "Bad pred at pos: ");
- fprintf(F, "%d ", i);
- fl = 1;
+ if (! fl)
+ fprintf(F, "Bad pred at pos: ");
+ fprintf(F, "%d ", i);
+ fl = 1;
}
}
if (fl)
fprintf(F, "\n");
+#else
+ /* the generic version. */
+ dump_irnode_to_file(F, block);
+
+ /* Check whether we have bad predecessors to color the block. */
+ for (i = 0; i < get_Block_n_cfgpreds(block); ++i)
+ if ((fl = is_Bad(get_Block_cfgpred(block, i))))
+ break;
+#endif
fprintf (F, "\""); /* closing quote of info */