#include <stdlib.h>
#include <stdarg.h>
-#include "firm_common_t.h"
-
#include "list.h"
#include "irnode_t.h"
#include "irop.h"
#include "irdump_t.h"
+#include "irpass_t.h"
#include "irgwalk.h"
#include "tv_t.h"
return ERROR_TXT;
}
-/**
- * returns the name of a type or <ERROR> if mode is NOT a mode object.
- * in the later case, sets bad
- */
-const char *get_type_name_ex(const ir_type *tp, int *bad) {
- if (is_type(tp))
- return get_type_name(tp);
- *bad |= 1;
- return ERROR_TXT;
-}
-
#define CUSTOM_COLOR_BASE 100
static const char *color_names[ird_color_count];
static const char *color_rgb[ird_color_count];
fprintf(F, "color:%s", color_names[color]);
}
+/**
+ * Prints the edge kind of a given IR node.
+ *
+ * Projs should be dumped near their predecessor, so they get "nearedge".
+ */
+static void print_node_edge_kind(FILE *F, ir_node *node) {
+ if (is_Proj(node)) {
+ fprintf(F, "nearedge: ");
+ } else {
+ fprintf(F, "edge: ");
+ }
+}
+
/**
* Prints the edge from a type S to a type T with additional info fmt, ...
* to the file F.
fprintf(F, "SymC %s offset", get_entity_name(get_SymConst_entity(n)));
break;
case symconst_type_tag:
- fprintf(F, "SymC %s tag", get_type_name_ex(get_SymConst_type(n), &bad));
+ ir_fprintf(F, "SymC %+F tag", get_SymConst_type(n));
break;
case symconst_type_size:
- fprintf(F, "SymC %s size", get_type_name_ex(get_SymConst_type(n), &bad));
+ ir_fprintf(F, "SymC %+F size", get_SymConst_type(n));
break;
case symconst_type_align:
- fprintf(F, "SymC %s align", get_type_name_ex(get_SymConst_type(n), &bad));
+ ir_fprintf(F, "SymC %+F align", get_SymConst_type(n));
break;
case symconst_enum_const:
- fprintf(F, "SymC %s enum", get_enumeration_name(get_SymConst_enum(n)));
+ fprintf(F, "SymC %s enum", get_enumeration_const_name(get_SymConst_enum(n)));
break;
}
break;
if (get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_consistent ||
get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_inconsistent) {
ir_type *tp = get_irn_typeinfo_type(n);
- if (tp != firm_none_type)
- fprintf(F, "[%s] ", get_type_name_ex(tp, &bad));
- else
+ if (tp != firm_none_type) {
+ ir_fprintf(F, "[%+F]", tp);
+ } else {
fprintf(F, "[] ");
+ }
}
}
return bad;
/** the lookup table for Proj(Call) names */
static const pns_lookup_t call_lut[] = {
#define X(a) { pn_Call_##a, #a }
- X(M_regular),
+ X(M),
X(X_regular),
X(X_except),
X(T_result),
- X(M_except),
X(P_value_res_base)
#undef X
};
X(M),
X(X_regular),
X(X_except),
- X(M_except)
#undef X
};
X(X_regular),
X(X_except),
X(res),
- X(M_except),
#undef X
};
fprintf(F, "%s ", get_ent_dump_name(get_Sel_entity(n)));
break;
case iro_Cast:
- fprintf(F, "(%s) ", get_type_name_ex(get_Cast_type(n), &bad));
+ ir_fprintf(F, "(%+F)", get_Cast_type(n));
break;
case iro_Confirm:
fprintf(F, "%s ", get_pnc_string(get_Confirm_cmp(n)));
break;
case iro_CopyB:
- fprintf(F, "(%s) ", get_type_name_ex(get_CopyB_type(n), &bad));
+ ir_fprintf(F, "(%+F)", get_CopyB_type(n));
break;
default:
int bad = 0;
bad |= dump_node_opcode(F, n);
+ fputs(" ", F);
bad |= dump_node_mode(F, n);
fprintf(F, " ");
bad |= dump_node_typeinfo(F, n);
return bad;
}
+/* Dumps the vrp information of a node to a file */
+int dump_vrp_info(FILE *F, ir_node *n) {
+ if (!n->vrp.valid) {
+ return 1;
+ }
+
+ fprintf(F, "range_type: %d\n", n->vrp.range_type);
+ if (n->vrp.range_type == VRP_RANGE || n->vrp.range_type ==
+ VRP_ANTIRANGE) {
+ ir_fprintf(F, "range_bottom: %F\n",n->vrp.range_bottom);
+ ir_fprintf(F, "range_top: %F\n", n->vrp.range_top);
+ }
+ ir_fprintf(F, "bits_set: %T\n", n->vrp.bits_set);
+ ir_fprintf(F, "bits_not_set: %T\n", n->vrp.bits_not_set);
+ if (n->vrp.bits_node == NULL) {
+ fprintf(F, "bits_node: None");
+ } else {
+ fprintf(F, "bits_node: #%ld\n", get_irn_node_nr(n->vrp.bits_node));
+ }
+
+ return 0;
+}
+
/**
* Dumps the attributes of a node n into the file F.
* Currently this is only the color of a node.
{
char buf[1024];
- if (__dbg_info_snprint) {
- buf[0] = '\0';
- if (__dbg_info_snprint(buf, sizeof(buf), dbg) > 0)
- fprintf(F, " info3: \"%s\"\n", buf);
+ ir_dbg_info_snprint(buf, sizeof(buf), dbg);
+ if (buf[0] != 0) {
+ fprintf(F, " info3: \"%s\"\n", buf);
}
}
+static void print_type_dbg_info(FILE *F, type_dbg_info *dbg)
+{
+ (void) F;
+ (void) dbg;
+ /* TODO */
+}
+
/**
* Dump a node
*/
ir_node *dep = get_irn_dep(n, i);
if (dep) {
- fprintf(F, "edge: {sourcename: \"");
+ print_node_edge_kind(F, n);
+ fprintf(F, "{sourcename: \"");
PRINT_NODEID(n);
fprintf(F, "\" targetname: ");
if ((get_opt_dump_const_local()) && is_constlike_node(dep)) {
if (dump_backedge_information_flag && is_backedge(n, i))
fprintf(F, "backedge: {sourcename: \"");
- else
- fprintf(F, "edge: {sourcename: \"");
+ else {
+ print_node_edge_kind(F, n);
+ fprintf(F, "{sourcename: \"");
+ }
PRINT_NODEID(n);
fprintf(F, "\" targetname: ");
if ((get_opt_dump_const_local()) && is_constlike_node(pred)) {
foreach_out_edge(n, edge) {
ir_node *succ = get_edge_src_irn(edge);
- fprintf(F, "edge: {sourcename: \"");
+ print_node_edge_kind(F, succ);
+ fprintf(F, "{sourcename: \"");
PRINT_NODEID(n);
fprintf(F, "\" targetname: \"");
PRINT_NODEID(succ);
static void print_typespecific_vcgattr(FILE *F, ir_type *tp) {
switch (get_type_tpop_code(tp)) {
case tpo_class:
- if (peculiarity_existent == get_class_peculiarity(tp))
- fprintf(F, " " TYPE_CLASS_NODE_ATTR);
- else
- fprintf(F, " " TYPE_DESCRIPTION_NODE_ATTR);
+ fprintf(F, " " TYPE_CLASS_NODE_ATTR);
break;
case tpo_struct:
fprintf(F, " " TYPE_METH_NODE_ATTR);
} /* switch type */
}
-
int dump_type_node(FILE *F, ir_type *tp)
{
int bad = 0;
fprintf(F, "node: {title: ");
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
+ ir_fprintf(F, " label: \"%s %+F\" info1: \"", get_type_tpop_name(tp), tp);
dump_type_to_file(F, tp, dump_verbosity_max);
-#endif
fprintf(F, "\"\n");
- print_dbg_info(F, get_type_dbg_info(tp));
+ print_type_dbg_info(F, get_type_dbg_info(tp));
print_typespecific_vcgattr(F, tp);
fprintf(F, "}\n");
{
char buf[1024];
ir_enum_const *ec = get_enumeration_const(tp, pos);
- ident *id = get_enumeration_nameid(ec);
+ ident *id = get_enumeration_const_nameid(ec);
tarval *tv = get_enumeration_value(ec);
if (tv)
print_ent_ent_edge(F,ent, get_entity_overwrites(ent, i), 0, -1, ENT_OVERWRITES_EDGE_ATTR);
}
/* attached subgraphs */
- if (const_entities && (get_entity_variability(ent) != variability_uninitialized)) {
- if (is_atomic_entity(ent)) {
- value = get_atomic_ent_value(ent);
- if (value) {
- print_ent_node_edge(F, ent, value, ENT_VALUE_EDGE_ATTR, i);
- /* DDMN(value); $$$ */
- dump_const_expression(F, value);
- }
- }
- if (is_compound_entity(ent)) {
- if (has_entity_initializer(ent)) {
- /* new style initializers */
- dump_entity_initializer(F, ent);
- } else {
- /* old style compound entity values */
- for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i) {
- value = get_compound_ent_value(ent, i);
- if (value) {
- print_ent_node_edge(F, ent, value, ENT_VALUE_EDGE_ATTR, i);
- dump_const_expression(F, value);
- print_ent_ent_edge(F, ent, get_compound_ent_value_member(ent, i), 0, -1, 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);
- */
- }
+ if (const_entities) {
+ if (ent->initializer != NULL) {
+ /* new style initializers */
+ dump_entity_initializer(F, ent);
+ } else if (entity_has_compound_ent_values(ent)) {
+ /* old style compound entity values */
+ for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i) {
+ value = get_compound_ent_value(ent, i);
+ if (value) {
+ print_ent_node_edge(F, ent, value, ENT_VALUE_EDGE_ATTR, i);
+ dump_const_expression(F, value);
+ print_ent_ent_edge(F, ent, get_compound_ent_value_member(ent, i), 0, -1, 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);
+ */
}
}
}
for (i = get_irn_n_outs(n) - 1; i >= 0; --i) {
ir_node *succ = get_irn_out(n, i);
assert(succ);
- fprintf(F, "edge: {sourcename: \"");
+ print_node_edge_kind(F, succ);
+ fprintf(F, "{sourcename: \"");
PRINT_NODEID(n);
fprintf(F, "\" targetname: \"");
PRINT_NODEID(succ);
* @param suffix1 first filename suffix
* @param suffix2 second filename suffix
*/
-FILE *vcg_open(ir_graph *irg, const char *suffix1, const char *suffix2) {
+FILE *vcg_open(const ir_graph *irg, const char *suffix1, const char *suffix2) {
FILE *F;
const char *nm = get_irg_dump_name(irg);
int len = strlen(nm), i, j;
dmp_grph(get_irp_irg(i), suffix);
}
+struct pass_t {
+ ir_prog_pass_t pass;
+ dump_graph_func *dump_graph;
+ char suffix[1];
+};
+
+/**
+ * Wrapper around dump_all_ir_graphs().
+ */
+static int dump_all_ir_graphs_wrapper(ir_prog *irp, void *context) {
+ struct pass_t *pass = context;
+
+ (void)irp;
+ dump_all_ir_graphs(pass->dump_graph, pass->suffix);
+ return 0;
+}
+
+ir_prog_pass_t *dump_all_ir_graph_pass(
+ const char *name, dump_graph_func *dump_graph, const char *suffix) {
+ size_t len = strlen(suffix);
+ struct pass_t *pass = xmalloc(sizeof(*pass) + len);
+ ir_prog_pass_t *res = def_prog_pass_constructor(
+ &pass->pass, name ? name : "dump_all_graphs", dump_all_ir_graphs_wrapper);
+
+ /* this pass does not change anything, so neither dump nor verify is needed. */
+ res->dump_irprog = ir_prog_no_dump;
+ res->verify_irprog = ir_prog_no_verify;
+
+ pass->dump_graph = dump_graph;
+ strcpy(pass->suffix, suffix);
+
+ return res;
+}
/*--------------------------------------------------------------------------------*
* Dumps a stand alone loop graph with firm nodes which belong to one loop node *