X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeabihelper.c;h=0462d434aaaf2e387d9e4a9f4fa41dbd87d6e79c;hb=0caf8d864fd6185090402563beaac03aaee73d4d;hp=7d3efb5126b355d9640f3ec0e4b66680a72054b2;hpb=5c34afb830f4a9233b659c95a9f71643f8421f86;p=libfirm diff --git a/ir/be/beabihelper.c b/ir/be/beabihelper.c index 7d3efb512..0462d434a 100644 --- a/ir/be/beabihelper.c +++ b/ir/be/beabihelper.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -22,18 +8,19 @@ * @brief Helper functions for handling ABI constraints in the code * selection phase. * @author Matthias Braun - * @version $Id$ */ #include "config.h" #include "beabihelper.h" #include "bearch.h" +#include "beirg.h" #include "benode.h" #include "besched.h" #include "ircons.h" #include "iredges.h" #include "irgwalk.h" -#include "irphase_t.h" +#include "irnodemap.h" +#include "irtools.h" #include "heights.h" /** @@ -357,12 +344,10 @@ ir_node *be_epilog_create_return(beabi_helper_env_t *env, dbg_info *dbgi, int n_res = 1; /* TODO */ unsigned pop = 0; /* TODO */ size_t i; - ir_node *ret; assert(ARR_LEN(env->epilog.value_map) == n_return_in); - ret = be_new_Return(dbgi, get_irn_irg(block), block, n_res, pop, - n_return_in, in); + ir_node *const ret = be_new_Return(dbgi, block, n_res, pop, n_return_in, in); for (i = 0; i < n_return_in; ++i) { const reg_flag_t *regflag = &env->epilog.regs[i]; const arch_register_t *reg = regflag->reg; @@ -383,7 +368,6 @@ ir_node *be_epilog_create_return(beabi_helper_env_t *env, dbg_info *dbgi, */ static bool has_real_user(const ir_node *node) { - const ir_edge_t *edge; foreach_out_edge(node, edge) { ir_node *user = get_edge_src_irn(edge); if (!is_End(user) && !is_Anchor(user)) @@ -411,15 +395,12 @@ static ir_node *add_to_keep(ir_node *last_keep, return last_keep; } -static void add_missing_keep_walker(ir_node *node, void *data) +void be_add_missing_keeps_node(ir_node *node) { - int n_outs, i; - unsigned *found_projs; - const ir_edge_t *edge; - ir_mode *mode = get_irn_mode(node); - ir_node *last_keep; - ir_node **existing_projs; - (void) data; + int n_outs, i; + ir_mode *mode = get_irn_mode(node); + ir_node *last_keep; + if (mode != mode_T) { if (!has_real_user(node)) { const arch_register_req_t *req = arch_get_irn_register_req(node); @@ -438,8 +419,8 @@ static void add_missing_keep_walker(ir_node *node, void *data) if (n_outs <= 0) return; - rbitset_alloca(found_projs, n_outs); - existing_projs = ALLOCANZ(ir_node*, n_outs); + unsigned *const found_projs = rbitset_alloca(n_outs); + ir_node **const existing_projs = ALLOCANZ(ir_node*, n_outs); foreach_out_edge(node, edge) { ir_node *succ = get_edge_src_irn(edge); ir_mode *mode = get_irn_mode(succ); @@ -483,6 +464,12 @@ static void add_missing_keep_walker(ir_node *node, void *data) } } +static void add_missing_keep_walker(ir_node *node, void *data) +{ + (void)data; + be_add_missing_keeps_node(node); +} + void be_add_missing_keeps(ir_graph *irg) { irg_walk_graph(irg, add_missing_keep_walker, NULL, NULL); @@ -582,10 +569,10 @@ static int cmp_call_dependency(const void *c1, const void *c2) * We MUST NOT order c > a and b > c. */ h1 = get_irn_height(heights, n1); h2 = get_irn_height(heights, n2); - if (h1 < h2) return -1; - if (h1 > h2) return 1; + if (h1 < h2) return 1; + if (h1 > h2) return -1; /* Same height, so use a random (but stable) order */ - return get_irn_idx(n1) - get_irn_idx(n2); + return get_irn_idx(n2) - get_irn_idx(n1); } /** @@ -593,11 +580,11 @@ static int cmp_call_dependency(const void *c1, const void *c2) */ static void process_ops_in_block(ir_node *block, void *data) { - ir_phase *phase = (ir_phase*)data; - unsigned n; - unsigned n_nodes; - ir_node *node; - ir_node **nodes; + ir_nodemap *map = (ir_nodemap*)data; + unsigned n; + unsigned n_nodes; + ir_node *node; + ir_node **nodes; n_nodes = 0; for (node = (ir_node*)get_irn_link(block); node != NULL; @@ -624,7 +611,7 @@ static void process_ops_in_block(ir_node *block, void *data) ir_node *node = nodes[n]; ir_node *pred = nodes[n-1]; - phase_set_irn_data(phase, node, pred); + ir_nodemap_insert(map, node, pred); } xfree(nodes); } @@ -632,7 +619,7 @@ static void process_ops_in_block(ir_node *block, void *data) struct be_stackorder_t { - ir_phase *stack_order; /**< a phase to handle stack dependencies. */ + ir_nodemap stack_order; /**< a phase to handle stack dependencies. */ }; be_stackorder_t *be_collect_stacknodes(ir_graph *irg) @@ -644,13 +631,12 @@ be_stackorder_t *be_collect_stacknodes(ir_graph *irg) /* collect all potential^stack accessing nodes */ irg_walk_graph(irg, firm_clear_link, link_ops_in_block_walker, NULL); - assert(env->stack_order == NULL); - env->stack_order = new_phase(irg, phase_irn_init_default); + ir_nodemap_init(&env->stack_order, irg); /* use heights to create a total order for those nodes: this order is stored * in the created phase */ heights = heights_new(irg); - irg_block_walk_graph(irg, NULL, process_ops_in_block, env->stack_order); + irg_block_walk_graph(irg, NULL, process_ops_in_block, &env->stack_order); heights_free(heights); ir_free_resources(irg, IR_RESOURCE_IRN_LINK); @@ -660,12 +646,12 @@ be_stackorder_t *be_collect_stacknodes(ir_graph *irg) ir_node *be_get_stack_pred(const be_stackorder_t *env, const ir_node *node) { - return (ir_node*)phase_get_irn_data(env->stack_order, node); + return ir_nodemap_get(ir_node, &env->stack_order, node); } void be_free_stackorder(be_stackorder_t *env) { - phase_free(env->stack_order); + ir_nodemap_destroy(&env->stack_order); free(env); } @@ -712,7 +698,7 @@ static void create_stores_for_type(ir_graph *irg, ir_type *type) first_store = store0; } else { ir_type *tp = get_entity_type(entity); - ir_mode *mode = get_type_mode(tp); + ir_mode *mode = is_compound_type(tp) ? mode_P : get_type_mode(tp); ir_node *val = new_r_Proj(args, mode, arg); ir_node *store = new_r_Store(start_block, mem, addr, val, cons_none); mem = new_r_Proj(store, mode_M, pn_Store_M); @@ -721,10 +707,8 @@ static void create_stores_for_type(ir_graph *irg, ir_type *type) } } - if (mem != initial_mem) { - edges_reroute(initial_mem, mem); - set_Store_mem(first_store, initial_mem); - } + if (mem != initial_mem) + edges_reroute_except(initial_mem, mem, first_store); } void be_add_parameter_entity_stores(ir_graph *irg)