+/**
+ * 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;
+
+ if (opt_dump_analysed_type_info) {
+ 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
+ fprintf(F, "[] ");
+ }
+ }
+ return bad;
+}
+
+typedef struct _pns_lookup {
+ long nr; /**< the proj number */
+ const char *name; /**< the name of the Proj */
+} pns_lookup_t;
+
+typedef struct _proj_lookup {
+ ir_opcode code; /**< the opcode of the Proj predecessor */
+ unsigned num_data; /**< number of data entries */
+ const pns_lookup_t *data; /**< the data */
+} proj_lookup_t;
+
+#define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+/** the lookup table for Proj(Start) names */
+static const pns_lookup_t start_lut[] = {
+#define X(a) { pn_Start_##a, #a }
+ X(X_initial_exec),
+ X(P_frame_base),
+ X(P_globals),
+ X(P_tls),
+ X(T_args),
+ X(P_value_arg_base)
+#undef X
+};
+
+/** the lookup table for Proj(Cond) names */
+static const pns_lookup_t cond_lut[] = {
+#define X(a) { pn_Cond_##a, #a }
+ X(false),
+ X(true)
+#undef X
+};
+
+/** 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(X_regular),
+ X(X_except),
+ X(T_result),
+ X(M_except),
+ X(P_value_res_base)
+#undef X
+};
+
+/** the lookup table for Proj(Quot) names */
+static const pns_lookup_t quot_lut[] = {
+#define X(a) { pn_Quot_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res)
+#undef X
+};
+
+/** the lookup table for Proj(DivMod) names */
+static const pns_lookup_t divmod_lut[] = {
+#define X(a) { pn_DivMod_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res_div),
+ X(res_mod)
+#undef X
+};
+
+/** the lookup table for Proj(Div) names */
+static const pns_lookup_t div_lut[] = {
+#define X(a) { pn_Div_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res)
+#undef X
+};
+
+/** the lookup table for Proj(Mod) names */
+static const pns_lookup_t mod_lut[] = {
+#define X(a) { pn_Mod_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res)
+#undef X
+};
+
+/** the lookup table for Proj(Load) names */
+static const pns_lookup_t load_lut[] = {
+#define X(a) { pn_Load_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res)
+#undef X
+};
+
+/** the lookup table for Proj(Store) names */
+static const pns_lookup_t store_lut[] = {
+#define X(a) { pn_Store_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except)
+#undef X
+};
+
+/** the lookup table for Proj(Alloc) names */
+static const pns_lookup_t alloc_lut[] = {
+#define X(a) { pn_Alloc_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res)
+#undef X
+};
+
+/** the lookup table for Proj(CopyB) names */
+static const pns_lookup_t copyb_lut[] = {
+#define X(a) { pn_CopyB_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(M_except)
+#undef X
+};
+
+/** the lookup table for Proj(InstOf) names */
+static const pns_lookup_t instof_lut[] = {
+#define X(a) { pn_InstOf_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res),
+ X(M_except),
+#undef X
+};
+
+/** the lookup table for Proj(Raise) names */
+static const pns_lookup_t raise_lut[] = {
+#define X(a) { pn_Raise_##a, #a }
+ X(M),
+ X(X),
+#undef X
+};
+
+/** the lookup table for Proj(Bound) names */
+static const pns_lookup_t bound_lut[] = {
+#define X(a) { pn_Bound_##a, #a }
+ X(M),
+ X(X_regular),
+ X(X_except),
+ X(res),
+#undef X
+};
+
+/** the Proj lookup table */
+static const proj_lookup_t proj_lut[] = {
+#define E(a) ARR_SIZE(a), a
+ { iro_Start, E(start_lut) },
+ { iro_Cond, E(cond_lut) },
+ { iro_Call, E(call_lut) },
+ { iro_Quot, E(quot_lut) },
+ { iro_DivMod, E(divmod_lut) },
+ { iro_Div, E(div_lut) },
+ { iro_Mod, E(mod_lut) },
+ { iro_Load, E(load_lut) },
+ { iro_Store, E(store_lut) },
+ { iro_Alloc, E(alloc_lut) },
+ { iro_CopyB, E(copyb_lut) },
+ { iro_InstOf, E(instof_lut) },
+ { iro_Raise, E(raise_lut) },
+ { iro_Bound, E(bound_lut) }
+#undef E
+};
+
+/**
+ * Dump additional node attributes of some nodes to a file F.
+ */
+static int
+dump_node_nodeattr(FILE *F, ir_node *n)
+{
+ int bad = 0;
+ ir_node *pred;
+ ir_opcode code;
+ long proj_nr;
+ const ir_op_ops *ops = get_op_ops(get_irn_op(n));
+
+ /* call the dump_node operation if available */
+ if (ops->dump_node)
+ return ops->dump_node(n, F, dump_node_nodeattr_txt);
+
+ switch (get_irn_opcode(n)) {
+ case iro_Start:
+ if (0 && get_interprocedural_view()) {
+ fprintf(F, "%s ", get_ent_dump_name(get_irg_entity(current_ir_graph)));
+ }
+ break;
+
+ case iro_Proj:
+ pred = get_Proj_pred(n);
+ proj_nr = get_Proj_proj(n);
+handle_lut:
+ code = get_irn_opcode(pred);
+
+ if (code == iro_Cmp)
+ fprintf(F, "%s ", get_pnc_string(get_Proj_proj(n)));
+ else if (code == iro_Proj && get_irn_opcode(get_Proj_pred(pred)) == iro_Start)
+ fprintf(F, "Arg %ld ", proj_nr);
+ else if (code == iro_Cond && get_irn_mode(get_Cond_selector(pred)) != mode_b)
+ fprintf(F, "%ld ", proj_nr);
+ else {
+ unsigned i, j, f = 0;
+
+ for (i = 0; i < ARR_SIZE(proj_lut); ++i) {
+ if (code == proj_lut[i].code) {
+ for (j = 0; j < proj_lut[i].num_data; ++j) {
+ if (proj_nr == proj_lut[i].data[j].nr) {
+ fprintf(F, "%s ", proj_lut[i].data[j].name);
+ f = 1;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ if (! f)
+ fprintf(F, "%ld ", proj_nr);
+ if (code == iro_Cond && get_Cond_jmp_pred(pred) != COND_JMP_PRED_NONE) {
+ if (proj_nr == pn_Cond_false && get_Cond_jmp_pred(pred) == COND_JMP_PRED_FALSE)
+ fprintf(F, "PRED ");
+ if (proj_nr == pn_Cond_true && get_Cond_jmp_pred(pred) == COND_JMP_PRED_TRUE)
+ fprintf(F, "PRED ");
+ }
+ }
+ break;
+ case iro_Filter:
+ proj_nr = get_Filter_proj(n);
+ if (! get_interprocedural_view()) {
+ /* it's a Proj' */
+ pred = get_Filter_pred(n);
+ goto handle_lut;
+ } else
+ fprintf(F, "%ld ", proj_nr);
+ break;
+ case iro_Sel:
+ 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));
+ 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));
+ break;
+
+ default:
+ ;
+ } /* end switch */
+
+ return bad;
+}
+
+#include <math.h>
+#include "execution_frequency.h"
+
+static 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);
+ bad |= dump_node_mode(F, n);
+ fprintf(F, " ");
+ bad |= dump_node_typeinfo(F, n);
+ bad |= dump_node_nodeattr(F, n);
+ if(dump_node_idx_labels) {
+ fprintf(F, "%ld:%d", get_irn_node_nr(n), get_irn_idx(n));
+ } else {
+ fprintf(F, "%ld", get_irn_node_nr(n));
+ }
+
+ return bad;