+
+/*
+ ___ _____ ____ ____ ___ _____ ____ _
+ |_ _| ___/ ___| | _ \ / _ \_ _| | _ \ _ _ _ __ ___ _ __ (_)_ __ __ _
+ | || |_ | | _ | | | | | | || | | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` |
+ | || _|| |_| | | |_| | |_| || | | |_| | |_| | | | | | | |_) | | | | | (_| |
+ |___|_| \____| |____/ \___/ |_| |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, |
+ |_| |___/
+*/
+
+static const char *get_dot_color_name(int col)
+{
+ static const char *names[] = {
+ "blue",
+ "red",
+ "green",
+ "yellow",
+ "cyan",
+ "magenta",
+ "orange",
+ "chocolate",
+ "beige",
+ "navy",
+ "darkgreen",
+ "darkred",
+ "lightPink",
+ "chartreuse",
+ "lightskyblue",
+ "linen",
+ "pink",
+ "lightslateblue",
+ "mintcream",
+ "red",
+ "darkolivegreen",
+ "mediumblue",
+ "mistyrose",
+ "salmon",
+ "darkseagreen",
+ "mediumslateblue"
+ "moccasin",
+ "tomato",
+ "forestgreen",
+ "darkturquoise",
+ "palevioletred"
+ };
+
+ return col < sizeof(names)/sizeof(names[0]) ? names[col] : "white";
+}
+
+static const char *get_dot_shape_name(co2_t *env, co2_irn_t *ci)
+{
+ arch_register_req_t req;
+
+ arch_get_register_req(env->co->aenv, &req, ci->irn, BE_OUT_POS(0));
+ if(arch_register_req_is(&req, limited))
+ return "diamond";
+
+ if(ci->fixed)
+ return "rectangle";
+
+ if(ci->tmp_fixed)
+ return "hexagon";
+
+ return "ellipse";
+}
+
+static void ifg_dump_graph_attr(FILE *f, void *self)
+{
+ fprintf(f, "overlay=false");
+}
+
+static int ifg_is_dump_node(void *self, ir_node *irn)
+{
+ co2_t *env = self;
+ return !arch_irn_is(env->co->aenv, irn, ignore);
+}
+
+static void ifg_dump_node_attr(FILE *f, void *self, ir_node *irn)
+{
+ co2_t *env = self;
+ co2_irn_t *ci = get_co2_irn(env, irn);
+ int peri = 1;
+
+ char buf[128] = "";
+
+ if(ci->aff) {
+ co2_cloud_irn_t *cci = (void *) ci;
+ if (cci->cloud && cci->cloud->mst_root == cci)
+ peri = 2;
+
+ if(cci->cloud && cci->cloud->mst_root)
+ snprintf(buf, sizeof(buf), "%+F", cci->cloud->mst_root->inh.irn);
+ }
+
+ ir_fprintf(f, "label=\"%+F%s\" style=filled peripheries=%d color=%s shape=%s", irn, buf, peri,
+ get_dot_color_name(get_col(env, irn)), get_dot_shape_name(env, ci));
+}
+
+static void ifg_dump_at_end(FILE *file, void *self)
+{
+ co2_t *env = self;
+ affinity_node_t *a;
+
+ co_gs_foreach_aff_node(env->co, a) {
+ co2_cloud_irn_t *ai = get_co2_cloud_irn(env, a->irn);
+ int idx = get_irn_idx(a->irn);
+ neighb_t *n;
+
+ if(ai->mst_parent != ai)
+ fprintf(file, "\tn%d -- n%d [style=dotted color=blue arrowhead=normal];\n", idx, get_irn_idx(ai->mst_parent->inh.irn));
+
+ co_gs_foreach_neighb(a, n) {
+ int nidx = get_irn_idx(n->irn);
+ co2_cloud_irn_t *ci = get_co2_cloud_irn(env, n->irn);
+
+ if(idx < nidx) {
+ const char *color = get_col(env, a->irn) == get_col(env, n->irn) ? "black" : "red";
+ const char *arr = "arrowhead=dot arrowtail=dot";
+
+ if(ci->mst_parent == ai)
+ arr = "arrowtail=normal";
+ else if(ai->mst_parent == ci)
+ arr = "arrowhead=normal";
+
+ fprintf(file, "\tn%d -- n%d [label=\"%d\" %s style=dashed color=%s weight=0.01];\n", idx, nidx, n->costs, arr, color);
+ }
+ }
+ }
+}
+
+
+static be_ifg_dump_dot_cb_t ifg_dot_cb = {
+ ifg_is_dump_node,
+ ifg_dump_graph_attr,
+ ifg_dump_node_attr,
+ NULL,
+ NULL,
+ ifg_dump_at_end
+};
+
+