X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fscalar_replace.c;h=09e70986ce7c40f4893705aa2a2313f4d143b8fd;hb=e997eedfb605aa149004122d63c7c54a8e384132;hp=d3536f13732046e6a81b75feeabbfc61d57b6842;hpb=a6888dd0c74a74aa5ec89d4542e402bda7cd61cb;p=libfirm diff --git a/ir/opt/scalar_replace.c b/ir/opt/scalar_replace.c index d3536f137..09e70986c 100644 --- a/ir/opt/scalar_replace.c +++ b/ir/opt/scalar_replace.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2011 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. */ /** @@ -185,7 +171,7 @@ static bool check_load_store_mode(ir_mode *mode, ir_mode *ent_mode) */ bool is_address_taken(ir_node *sel) { - int i, input_nr, k; + int input_nr; ir_mode *emode, *mode; ir_node *value; ir_entity *ent; @@ -193,7 +179,7 @@ bool is_address_taken(ir_node *sel) if (! is_const_sel(sel)) return true; - for (i = get_irn_n_outs(sel) - 1; i >= 0; --i) { + for (unsigned i = get_irn_n_outs(sel); i-- > 0; ) { ir_node *succ = get_irn_out(sel, i); switch (get_irn_opcode(succ)) { @@ -262,7 +248,7 @@ bool is_address_taken(ir_node *sel) if (pred == sel) { /* we found one input */ - for (k = get_irn_n_outs(succ) - 1; k >= 0; --k) { + for (unsigned k = get_irn_n_outs(succ); k-- > 0; ) { ir_node *proj = get_irn_out(succ, k); if (is_Proj(proj) && get_Proj_proj(proj) == input_nr) { @@ -291,10 +277,9 @@ bool is_address_taken(ir_node *sel) */ static bool link_all_leave_sels(ir_entity *ent, ir_node *sel) { - int i; bool is_leave = true; - for (i = get_irn_n_outs(sel) - 1; i >= 0; --i) { + for (unsigned i = get_irn_n_outs(sel); i-- > 0; ) { ir_node *succ = get_irn_out(sel, i); if (is_Sel(succ)) { @@ -343,7 +328,6 @@ static int find_possible_replacements(ir_graph *irg) ir_node *irg_frame; ir_type *frame_tp; size_t mem_idx; - int i; long static_link_arg; int res = 0; @@ -364,16 +348,14 @@ static int find_possible_replacements(ir_graph *irg) if (is_method_entity(ent)) { ir_graph *inner_irg = get_entity_irg(ent); ir_node *args; - int j; assure_irg_properties(inner_irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS); args = get_irg_args(inner_irg); - for (j = get_irn_n_outs(args) - 1; j >= 0; --j) { + for (unsigned j = get_irn_n_outs(args); j-- > 0; ) { ir_node *arg = get_irn_out(args, j); if (get_Proj_proj(arg) == static_link_arg) { - int k; - for (k = get_irn_n_outs(arg) - 1; k >= 0; --k) { + for (unsigned k = get_irn_n_outs(arg); k-- > 0; ) { ir_node *succ = get_irn_out(arg, k); if (is_Sel(succ)) { @@ -396,7 +378,7 @@ static int find_possible_replacements(ir_graph *irg) * equal ADDRESS_TAKEN. */ irg_frame = get_irg_frame(irg); - for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) { + for (unsigned i = get_irn_n_outs(irg_frame); i-- > 0; ) { ir_node *succ = get_irn_out(irg_frame, i); if (is_Sel(succ)) { @@ -497,7 +479,7 @@ static unsigned allocate_value_numbers(pset *sels, ir_entity *ent, unsigned vnum pset_insert_ptr(sels, sel); key = find_path(sel, 0); - path = (path_t*)set_find(pathes, key, path_size(key), path_hash(key)); + path = set_find(path_t, pathes, key, path_size(key), path_hash(key)); if (path) { set_vnum(sel, path->vnum); @@ -505,7 +487,7 @@ static unsigned allocate_value_numbers(pset *sels, ir_entity *ent, unsigned vnum } else { key->vnum = vnum++; - set_insert(pathes, key, path_size(key), path_hash(key)); + (void)set_insert(path_t, pathes, key, path_size(key), path_hash(key)); set_vnum(sel, key->vnum); DB((dbg, SET_LEVEL_3, " %+F represents value %u\n", sel, key->vnum)); @@ -598,11 +580,13 @@ static void walker(ir_node *node, void *ctx) val = new_rd_Conv(get_irn_dbg_info(node), block, val, mode); mem = get_Load_mem(node); - turn_into_tuple(node, pn_Load_max+1); - set_Tuple_pred(node, pn_Load_M, mem); - set_Tuple_pred(node, pn_Load_res, val); - set_Tuple_pred(node, pn_Load_X_regular, new_r_Jmp(block)); - set_Tuple_pred(node, pn_Load_X_except, new_r_Bad(irg, mode_X)); + ir_node *const in[] = { + [pn_Load_M] = mem, + [pn_Load_res] = val, + [pn_Load_X_regular] = new_r_Jmp(block), + [pn_Load_X_except] = new_r_Bad(irg, mode_X), + }; + turn_into_tuple(node, ARRAY_SIZE(in), in); } else if (is_Store(node)) { DB((dbg, SET_LEVEL_3, " checking %+F for replacement ", node)); @@ -635,10 +619,12 @@ static void walker(ir_node *node, void *ctx) set_value(vnum, val); mem = get_Store_mem(node); - turn_into_tuple(node, pn_Store_max+1); - set_Tuple_pred(node, pn_Store_M, mem); - set_Tuple_pred(node, pn_Store_X_regular, new_r_Jmp(block)); - set_Tuple_pred(node, pn_Store_X_except, new_r_Bad(irg, mode_X)); + ir_node *const in[] = { + [pn_Store_M] = mem, + [pn_Store_X_regular] = new_r_Jmp(block), + [pn_Store_X_except] = new_r_Bad(irg, mode_X), + }; + turn_into_tuple(node, ARRAY_SIZE(in), in); } } @@ -679,8 +665,7 @@ static void do_scalar_replacements(ir_graph *irg, pset *sels, unsigned nvals, void scalar_replacement_opt(ir_graph *irg) { unsigned nvals; - int i; - scalars_t key, *value; + scalars_t key; ir_node *irg_frame; ir_mode **modes; set *set_ent; @@ -707,7 +692,7 @@ void scalar_replacement_opt(ir_graph *irg) sels = pset_new_ptr(8); frame_tp = get_irg_frame_type(irg); - for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) { + for (unsigned i = get_irn_n_outs(irg_frame); i-- > 0; ) { ir_node *succ = get_irn_out(irg_frame, i); if (is_Sel(succ)) { @@ -725,7 +710,7 @@ void scalar_replacement_opt(ir_graph *irg) ent_type = get_entity_type(ent); key.ent = ent; - set_insert(set_ent, &key, sizeof(key), hash_ptr(key.ent)); + (void)set_insert(scalars_t, set_ent, &key, sizeof(key), hash_ptr(key.ent)); #ifdef DEBUG_libfirm if (is_Array_type(ent_type)) {