-static void vcg_open (ir_graph *irg, char *suffix) {
- char *fname; /* filename to put the vcg information in */
- const char *cp;
- ident *id;
- int len;
- char label[4];
- entity *ent;
-
- /** open file for vcg graph */
- ent = get_irg_ent(irg);
- id = ent->ld_name ? ent->ld_name : ent->name;
- /* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */
- len = get_id_strlen (id);
- cp = get_id_str (id);
- 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 */
- strcat (fname, ".vcg"); /* append the .vcg suffix */
- F = fopen (fname, "w"); /* open file for writing */
- if (!F) {
- panic ("cannot open %s for writing (%m)", fname); /* not reached */
- }
-
- if (edge_label) {
- strcpy(label, "yes");
- } else {
- strcpy (label, "no");
- }
-
- /* print header */
- fprintf (F,
- "graph: { title: \"ir graph of %s\"\n"
- "display_edge_labels: %s\n"
- "layoutalgorithm: mindepth\n"
- "manhattan_edges: yes\n"
- "port_sharing: no\n"
- "orientation: bottom_to_top\n"
- "classname 1: \"Data\"\n"
- "classname 2: \"Block\"\n"
- "classname 3: \"Entity type\"\n"
- "classname 4: \"Entity owner\"\n"
- "classname 5: \"Method Param\"\n"
- "classname 6: \"Method Res\"\n"
- "classname 7: \"Super\"\n"
- "classname 8: \"Union\"\n"
- "classname 9: \"Points-to\"\n"
- "classname 10: \"Array Element Type\"\n"
- "classname 11: \"Overwrites\"\n"
- "classname 12: \"Member\"\n"
- , cp, label);
-
- fprintf (F, "\n"); /* a separator */
-}
-
-static void vcg_open_name (const char *name) {
- char *fname; /* filename to put the vcg information in */
- int len;
- char label[4];
-
- /** open file for vcg graph */
- len = strlen(name);
- fname = malloc (len + 5);
- if (dump_file_suffix)
- fname = malloc (len + 5 + strlen(dump_file_suffix));
- else
- fname = malloc (len + 5);
- strcpy (fname, name); /* copy the filename */
- if (dump_file_suffix) strcat (fname, dump_file_suffix);
- strcat (fname, ".vcg"); /* append the .vcg suffix */
- F = fopen (fname, "w"); /* open file for writing */
- if (!F) {
- panic ("cannot open %s for writing (%m)", fname); /* not reached */
- }
-
- if (edge_label) {
- strcpy(label, "yes");
- } else {
- strcpy (label, "no");
- }
-
- /* print header */
- fprintf (F,
- "graph: { title: \"ir graph of %s\"\n"
- "display_edge_labels: %s\n"
- "layoutalgorithm: mindepth\n"
- "manhattan_edges: yes\n"
- "port_sharing: no\n"
- "orientation: bottom_to_top\n"
- "classname 1: \"Data\"\n"
- "classname 2: \"Block\"\n"
- "classname 3: \"Entity type\"\n"
- "classname 4: \"Entity owner\"\n"
- "classname 5: \"Method Param\"\n"
- "classname 6: \"Method Res\"\n"
- "classname 7: \"Super\"\n"
- "classname 8: \"Union\"\n"
- "classname 9: \"Points-to\"\n"
- "classname 10: \"Array Element Type\"\n"
- "classname 11: \"Overwrites\"\n"
- "classname 12: \"Member\"\n"
- , name, label);
-
- fprintf (F, "\n"); /* a separator */
+/** 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;