From 79ffe731543f1863e65714e997b91374519d3cc7 Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Tue, 2 May 2006 12:01:04 +0000 Subject: [PATCH] Added Appel dumping --- ir/be/becopyopt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ ir/be/becopyopt.h | 14 +++++++++++++- ir/be/becopyopt_t.h | 5 +++-- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/ir/be/becopyopt.c b/ir/be/becopyopt.c index 8b0f6d000..0c58262e3 100644 --- a/ir/be/becopyopt.c +++ b/ir/be/becopyopt.c @@ -637,3 +637,45 @@ int co_gs_is_optimizable(copy_opt_t *co, ir_node *irn) { } else return 0; } + +void co_dump_appel_graph(const copy_opt_t *co, FILE *f) +{ + be_ifg_t *ifg = co->cenv->ifg; + + ir_node *irn; + void *it, *nit; + int n; + + it = be_ifg_nodes_iter_alloca(ifg); + nit = be_ifg_neighbours_iter_alloca(ifg); + + n = 0; + be_ifg_foreach_node(ifg, it, irn) { + set_irn_link(irn, INT_TO_PTR(n++)); + } + + fprintf(f, "%d %d\n", n, co->cls->n_regs); + + be_ifg_foreach_node(ifg, it, irn) { + int idx = PTR_TO_INT(get_irn_link(irn)); + affinity_node_t *a = get_affinity_info(co, irn); + + ir_node *adj; + + be_ifg_foreach_neighbour(ifg, nit, irn, adj) { + int adj_idx = PTR_TO_INT(get_irn_link(adj)); + if(idx < adj_idx) + fprintf(f, "%d %d -1\n", idx, adj_idx); + } + + if(a) { + neighb_t *n; + + co_gs_foreach_neighb(a, n) { + int n_idx = PTR_TO_INT(get_irn_link(n->irn)); + if(idx < n_idx) + fprintf(f, "%d %d %d\n", idx, n_idx, n->costs); + } + } + } +} diff --git a/ir/be/becopyopt.h b/ir/be/becopyopt.h index b742af442..b8bc03189 100644 --- a/ir/be/becopyopt.h +++ b/ir/be/becopyopt.h @@ -13,6 +13,8 @@ #ifndef _BECOPYOPT_H #define _BECOPYOPT_H +#include + #include "firm_types.h" #include "bechordal.h" @@ -80,6 +82,9 @@ void co_free_ou_structure(copy_opt_t *co); */ int co_solve_heuristic(copy_opt_t *co); +void co_solve_heuristic_new(copy_opt_t *co); + + /** * Solves the copy minimization problem using another heuristic approach. * Uses the OU and the GRAPH data structure. @@ -116,7 +121,14 @@ int co_get_copy_costs(const copy_opt_t *co); */ int co_get_lower_bound(const copy_opt_t *co); - +/** + * Dump the interference graph according to the Appel/George coalescing contest file format. + * See: http://www.cs.princeton.edu/~appel/coalesce/format.html + * @note Requires graph structure. + * @param co The copy opt object. + * @param f A file to dump to. + */ +void co_dump_appel_graph(const copy_opt_t *co, FILE *f); diff --git a/ir/be/becopyopt_t.h b/ir/be/becopyopt_t.h index 3fcb0f791..be1a59872 100644 --- a/ir/be/becopyopt_t.h +++ b/ir/be/becopyopt_t.h @@ -54,6 +54,7 @@ struct _copy_opt_t { #define is_2addr_code(arch_env, irn, req) (arch_get_register_req(arch_env, req, irn, -1)->type == arch_register_req_type_should_be_same) + /****************************************************************************** ____ _ _ _ _ _ _____ _ / __ \ | | | | | | (_) | / ____| | @@ -109,6 +110,7 @@ struct _affinity_node_t { ir_node *irn; /** a node with affinity edges */ int degree; /** number of affinity edges in the linked list below */ neighb_t *neighbours; /** a linked list of all affinity neighbours */ + void *data; /** stuff that is attachable. */ }; @@ -124,10 +126,9 @@ static INLINE affinity_node_t *get_affinity_info(const copy_opt_t *co, ir_node * #define co_gs_nodes_begin(co) set_first((co)->nodes) #define co_gs_nodes_next(co) set_next((co)->nodes) #define co_gs_nodes_break(co) set_break((co)->nodes) -#define co_gs_foreach_aff_node(co, aff_node) for (aff_node = co_gs_nodes_begin(co); aff_node; aff_node = co_gs_nodes_next(co)) +#define co_gs_foreach_aff_node(co, aff_node) for (aff_node = co_gs_nodes_begin(co); aff_node; aff_node = co_gs_nodes_next(co)) #define co_gs_foreach_neighb(aff_node, neighb) for (neighb = aff_node->neighbours; neighb; neighb = neighb->next) - #endif -- 2.20.1