X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbesched.c;h=21060592ec401aca5d2b5a9fc3cdd7deb48baf40;hb=dfc341ac6f54b4b0922d605e28333be76f487c68;hp=02bbe79343be25492346d480d7800f3393e88cd3;hpb=f75f88c18304f65ecbd103a4457c66407225bd73;p=libfirm diff --git a/ir/be/besched.c b/ir/be/besched.c index 02bbe7934..21060592e 100644 --- a/ir/be/besched.c +++ b/ir/be/besched.c @@ -1,5 +1,28 @@ -/* $Id$ */ +/* + * Copyright (C) 1995-2007 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. + */ +/** + * @file + * @brief Scheduling utilities for nodes in Blocks and Blocks. + * @author Sebastian Hack + * @version $Id$ + */ #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -19,7 +42,7 @@ #include "debug.h" #include "bemodule.h" -#include "bearch.h" +#include "bearch_t.h" #include "besched_t.h" #include "beutil.h" #include "belistsched.h" @@ -29,6 +52,7 @@ FIRM_IMPL1(sched_has_next, int, const ir_node *) FIRM_IMPL1(sched_has_prev, int, const ir_node *) FIRM_IMPL1(sched_next, ir_node *, const ir_node *) FIRM_IMPL1(sched_prev, ir_node *, const ir_node *) +FIRM_IMPL1(sched_is_scheduled, int, const ir_node *) FIRM_IMPL1(sched_first, ir_node *, const ir_node *) FIRM_IMPL1(sched_last, ir_node *, const ir_node *) FIRM_IMPL2(sched_add_after, ir_node *, ir_node *, ir_node *) @@ -79,115 +103,6 @@ void sched_renumber(const ir_node *block) } } -/* Verify a schedule. */ -int sched_verify(const ir_node *block) -{ - int res = 1; - const ir_node *irn; - int i, n; - int *save_time_step; - const ir_node **save_nodes; - const ir_edge_t *edge; - pset *scheduled_nodes = pset_new_ptr_default(); - FIRM_DBG_REGISTER(firm_dbg_module_t *dbg_sched, "firm.be.sched"); - - /* Count the number of nodes in the schedule. */ - n = 0; - sched_foreach(block, irn) - n++; - - if(n <= 0) - return 1; - - save_time_step = xmalloc(n * sizeof(save_time_step[0])); - save_nodes = xmalloc(n * sizeof(save_nodes[0])); - - i = 0; - sched_foreach(block, irn) { - sched_info_t *info = get_irn_sched_info(irn); - save_time_step[i] = info->time_step; - save_nodes[i] = (ir_node *)irn; - info->time_step = i; - pset_insert_ptr(scheduled_nodes, irn); - - i += 1; - } - - /* - * Check if each relevant operand of a node is scheduled before - * the node itself. - */ - sched_foreach(block, irn) { - int i, n; - int step = sched_get_time_step(irn); - - for(i = 0, n = get_irn_arity(irn); i < n; i++) { - ir_node *op = get_irn_n(irn, i); - - if(to_appear_in_schedule(op) - && !is_Phi(irn) - && get_nodes_block(op) == block - && sched_get_time_step(op) > step) { - - DBG((dbg_sched, LEVEL_DEFAULT, - "%+F: %+F is operand of %+F but scheduled after\n", block, op, irn)); - res = 0; - } - } - } - - /* Check, if the time steps are correct */ - for(i = 1; i < n; ++i) { - if(save_time_step[i] - save_time_step[i - 1] <= 0) { - DBG((dbg_sched, LEVEL_DEFAULT, - "%+F from %+F(%d) -> %+F(%d) step shrinks from %d -> %d\n", - block, save_nodes[i - 1], i - 1, save_nodes[i], i, - save_time_step[i - 1], save_time_step[i])); - res = 0; - } - } - - /* Restore the old time steps */ - i = 0; - sched_foreach(block, irn) { - sched_info_t *info = get_irn_sched_info(irn); - info->time_step = save_time_step[i++]; - } - - /* Check for all nodes in the block if they are scheduled. */ - foreach_out_edge(block, edge) { - ir_node *irn = get_edge_src_irn(edge); - if(to_appear_in_schedule(irn) && !pset_find_ptr(scheduled_nodes, irn)) { - DBG((dbg_sched, LEVEL_DEFAULT, - "%+F: %+F is in block but not scheduled\n", block, irn)); - res = 0; - } - } - - del_pset(scheduled_nodes); - free(save_time_step); - free((void *) save_nodes); - return res; -} - -/** - * Block-Walker: verify the current block and update the status - */ -static void sched_verify_walker(ir_node *block, void *data) -{ - int *res = data; - *res &= sched_verify(block); -} - -/* Verify the schedules in all blocks of the irg. */ -int sched_verify_irg(ir_graph *irg) -{ - int res = 1; - irg_block_walk_graph(irg, sched_verify_walker, NULL, &res); - - return res; -} - int sched_skip_cf_predicator(const ir_node *irn, void *data) { arch_env_t *ae = data; return arch_irn_class_is(ae, irn, branch); @@ -251,11 +166,6 @@ static void remove_dead_nodes_walker(ir_node *block, void *data) continue; sched_remove(node); - - /* when a node is exchanged, it is turned into Bad, do not set ins for those */ - if (is_Bad(node)) - continue; - be_kill_node(node); } }