/*
- * 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.
*/
/**
* @file
* @brief modifies schedule so flags dependencies are respected.
* @author Matthias Braun, Christoph Mallon
- * @version $Id: besched.h 14693 2007-06-21 15:35:49Z beck $
*
* Fixup schedule to respect flag constraints by moving and rematerialisation of
* nodes.
*/
static bool can_move(ir_node *node, ir_node *after)
{
- const ir_edge_t *edge;
ir_node *node_block = get_nodes_block(node);
assert(node_block == get_nodes_block(after));
foreach_out_edge(node, edge) {
ir_node *out = get_edge_src_irn(edge);
if (is_Proj(out)) {
- const ir_edge_t *edge2;
assert(get_irn_n_edges_kind(out, EDGE_KIND_DEP) == 0);
foreach_out_edge(out, edge2) {
ir_node *out2 = get_edge_src_irn(edge2);
if (is_Phi(out2) || is_End(out2))
continue;
if (is_Sync(out2)) {
- const ir_edge_t *edge3;
foreach_out_edge(out2, edge3) {
ir_node *out3 = get_edge_src_irn(edge3);
/* Phi or End represents a usage at block end. */
*/
static void fix_flags_walker(ir_node *block, void *env)
{
- ir_node *node;
ir_node *flags_needed = NULL;
ir_node *flag_consumers = NULL;
int pn = -1;
(void) env;
+ ir_node *place = block;
sched_foreach_reverse(block, node) {
int i, arity;
ir_node *new_flags_needed = NULL;
ir_node *test;
- if (is_Phi(node))
+ if (is_Phi(node)) {
+ place = node;
break;
+ }
if (node == flags_needed) {
/* all ok */
if (flags_needed != NULL) {
assert(get_nodes_block(flags_needed) != block);
- rematerialize_or_move(flags_needed, node, flag_consumers, pn);
+ rematerialize_or_move(flags_needed, place, flag_consumers, pn);
flags_needed = NULL;
flag_consumers = NULL;
}