2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Code for dumping backend datastructures (i.e. interference graphs)
23 * @author Matthias Braun
31 #include "becopyopt_t.h"
33 static void dump_ifg_nodes(FILE *F, const be_ifg_t *ifg)
35 nodes_iter_t ifg_iter;
37 be_ifg_foreach_node(ifg, &ifg_iter, node) {
42 static void dump_ifg_edges(FILE *F, const be_ifg_t *ifg)
44 nodes_iter_t ifg_iter;
47 be_ifg_foreach_node(ifg, &ifg_iter, node) {
48 neighbours_iter_t neigh_iter;
51 be_ifg_foreach_neighbour(ifg, &neigh_iter, node, neighbour) {
52 /* interference is bidirectional, but it's enough to dump 1
54 if (get_irn_node_nr(node) >= get_irn_node_nr(neighbour))
57 fprintf(F, "edge: {sourcename: \"");
59 fprintf(F, "\" targetname: \"");
60 PRINT_NODEID(neighbour);
61 fprintf(F, "\" arrowstyle:none class:1}\n");
66 void be_dump_ifg(FILE *F, ir_graph *irg, const be_ifg_t *ifg)
69 "graph: { title: \"interference graph of %+F\"\n"
70 "layoutalgorithm: mindepth //$ \"circular\"\n"
71 "classname 1: \"interference\"\n"
73 dump_vcg_infonames(F);
74 dump_vcg_header_colors(F);
76 dump_ifg_nodes(F, ifg);
77 dump_ifg_edges(F, ifg);
82 static void dump_affinity_edges(FILE *F, const copy_opt_t *co,
83 bool dump_costs, bool dump_colors)
86 co_gs_foreach_aff_node(co, a) {
89 co_gs_foreach_neighb(a, n) {
90 /* edges are bidirection, dumping one direction is enough */
91 if (get_irn_node_nr(a->irn) >= get_irn_node_nr(n->irn))
94 fprintf(F, "edge: {sourcename: \"");
96 fprintf(F, "\" targetname: \"");
98 fprintf(F, "\" arrowstyle:none");
101 fprintf(F, " label:\"%d\"", n->costs);
103 const arch_register_t *ar = arch_get_irn_register(a->irn);
104 const arch_register_t *nr = arch_get_irn_register(n->irn);
105 const char *color = nr == ar ? "blue" : "red";
106 fprintf(F, " color:%s", color);
108 fprintf(F, " linestyle:dashed class:2");
114 void be_dump_ifg_co(FILE *F, const copy_opt_t *co, bool dump_costs,
117 ir_graph *irg = co->irg;
118 be_ifg_t *ifg = co->cenv->ifg;
121 "graph: { title: \"interference graph of %+F\"\n"
122 "layoutalgorithm: mindepth //$ \"circular\"\n"
123 "classname 1: \"interference\"\n"
124 "classname 2: \"affinity\"\n"
126 dump_vcg_infonames(F);
127 dump_vcg_header_colors(F);
129 dump_ifg_nodes(F, ifg);
130 dump_ifg_edges(F, ifg);
131 dump_affinity_edges(F, co, dump_costs, dump_colors);