X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespilldaemel.c;h=047fab5cef31b313bcc76c0ae873817b643b9ff7;hb=f2c2e45eb4e677fef5bf6a8e418b2a22441172d5;hp=92c095198d2681d180d4e0b47b1b75e32eb15bcc;hpb=5c9f29e77650c9d6f0be472a3bd338924568f89a;p=libfirm diff --git a/ir/be/bespilldaemel.c b/ir/be/bespilldaemel.c index 92c095198..047fab5ce 100644 --- a/ir/be/bespilldaemel.c +++ b/ir/be/bespilldaemel.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -19,12 +19,12 @@ /** * @file - * @brief Naiv spilling algorithm + * @brief Naive spilling algorithm * @author Matthias Braun * @date 20.09.2005 * @version $Id: bespillbelady.c 13913 2007-05-18 12:48:56Z matze $ * @summary - * This implements a naiv spilling algorithm. It is design to produce similar + * This implements a naive spilling algorithm. It is designed to produce similar * effects to the spill decisions produced by traditional graph coloring * register allocators that spill while they are coloring the graph. * @@ -33,9 +33,7 @@ * Spilling in this context means placing a spill instruction behind the * definition of the value and a reload before each usage. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include "debug.h" @@ -59,7 +57,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) static spill_env_t *spill_env; static int n_regs; -static const arch_env_t *arch_env; static const arch_register_class_t *cls; static const be_lv_t *lv; static bitset_t *spilled_nodes; @@ -94,8 +91,8 @@ static double get_spill_costs(ir_node *node) } if(is_Phi(use)) { - int in = get_edge_src_pos(edge); - ir_node *block = get_nodes_block(use); + int in = get_edge_src_pos(edge); + ir_node *block = get_nodes_block(use); costs += be_get_reload_costs_on_edge(spill_env, node, block, in); } else { @@ -160,11 +157,11 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node) foreach_out_edge(node, edge) { const ir_node *proj = get_edge_src_irn(edge); - if(arch_irn_consider_in_reg_alloc(arch_env, cls, proj)) { + if (arch_irn_consider_in_reg_alloc(cls, proj)) { ++values_defined; } } - } else if(arch_irn_consider_in_reg_alloc(arch_env, cls, node)) { + } else if (arch_irn_consider_in_reg_alloc(cls, node)) { ++values_defined; } @@ -172,7 +169,7 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node) arity = get_irn_arity(node); for(i = 0; i < arity; ++i) { ir_node *pred = get_irn_n(node, i); - if(arch_irn_consider_in_reg_alloc(arch_env, cls, pred) + if (arch_irn_consider_in_reg_alloc(cls, pred) && !ir_nodeset_contains(live_nodes, pred)) { ++free_regs_needed; } @@ -188,7 +185,7 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node) return; DBG((dbg, LEVEL_2, "\tspills needed after %+F: %d\n", node, spills_needed)); - candidates = alloca(n_live_nodes * sizeof(candidates[0])); + candidates = ALLOCAN(spill_candidate_t, n_live_nodes); /* construct array with spill candidates and calculate their costs */ i = 0; @@ -215,7 +212,7 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node) int is_use; if (cand_idx >= n_live_nodes) { - panic("can't spill enough values for node %+F\n", node); + panic("can't spill enough values for node %+F", node); } @@ -223,7 +220,7 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node) cand_node = candidate->node; ++cand_idx; - if(arch_irn_is(arch_env, cand_node, dont_spill)) + if (arch_irn_is(cand_node, dont_spill)) continue; /* make sure the node is not an argument of the instruction */ @@ -260,30 +257,30 @@ static void remove_defs(ir_node *node, ir_nodeset_t *nodeset) foreach_out_edge(node, edge) { const ir_node *proj = get_edge_src_irn(edge); - if (arch_irn_consider_in_reg_alloc(arch_env, cls, proj)) { + if (arch_irn_consider_in_reg_alloc(cls, proj)) { ir_nodeset_remove(nodeset, proj); } } } - if(arch_irn_consider_in_reg_alloc(arch_env, cls, node)) { - ir_nodeset_remove(nodeset, node); - } + if (arch_irn_consider_in_reg_alloc(cls, node)) { + ir_nodeset_remove(nodeset, node); + } } static void add_uses(ir_node *node, ir_nodeset_t *nodeset) { int i, arity; - arity = get_irn_arity(node); - for(i = 0; i < arity; ++i) { - ir_node *op = get_irn_n(node, i); + arity = get_irn_arity(node); + for(i = 0; i < arity; ++i) { + ir_node *op = get_irn_n(node, i); - if(arch_irn_consider_in_reg_alloc(arch_env, cls, op) - && !bitset_is_set(spilled_nodes, get_irn_idx(op))) { - ir_nodeset_insert(nodeset, op); + if (arch_irn_consider_in_reg_alloc(cls, op) && + !bitset_is_set(spilled_nodes, get_irn_idx(op))) { + ir_nodeset_insert(nodeset, op); } - } + } } static __attribute__((unused)) @@ -304,19 +301,19 @@ void print_nodeset(ir_nodeset_t *nodeset) */ static void spill_block(ir_node *block, void *data) { - ir_nodeset_t live_nodes; - ir_nodeset_iterator_t iter; - ir_node *node; - int n_phi_values_spilled; - int regpressure; - int phi_spills_needed; + ir_nodeset_t live_nodes; + ir_nodeset_iterator_t iter; + ir_node *node; + int n_phi_values_spilled; + int regpressure; + int phi_spills_needed; (void) data; DBG((dbg, LEVEL_1, "spilling block %+F\n", block)); /* construct set of live nodes at end of block */ ir_nodeset_init(&live_nodes); - be_liveness_end_of_block(lv, arch_env, cls, block, &live_nodes); + be_liveness_end_of_block(lv, cls, block, &live_nodes); /* remove already spilled nodes from liveset */ foreach_ir_nodeset(&live_nodes, node, iter) { @@ -390,7 +387,6 @@ void be_spill_daemel(be_irg_t *birg, const arch_register_class_t *new_cls) be_liveness_assure_sets(be_assure_liveness(birg)); spill_env = be_new_spill_env(birg); - arch_env = be_get_birg_arch_env(birg); cls = new_cls; lv = be_get_birg_liveness(birg); spilled_nodes = bitset_malloc(get_irg_last_idx(irg)); @@ -415,7 +411,7 @@ void be_init_daemelspill(void) }; be_register_spiller("daemel", &daemel_spiller); - FIRM_DBG_REGISTER(dbg, "ir.be.spilldaemel"); + FIRM_DBG_REGISTER(dbg, "firm.be.spilldaemel"); } -BE_REGISTER_MODULE_CONSTRUCTOR(be_init_doedelspill); +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_daemelspill);