/*
- * Author: Matthias Braun
- * Date: 05.05.2006
- * Copyright: (c) Universitaet Karlsruhe
- * License: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- * CVS-Id: $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 Various verify routines that check a scheduled graph for correctness.
+ * @author Matthias Braun
+ * @date 05.05.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "besched_t.h"
#include "benode_t.h"
#include "beirg_t.h"
+#include "beintlive_t.h"
static int my_values_interfere(const ir_node *a, const ir_node *b);
env.registers_available = env.cls->n_regs - be_put_ignore_regs(birg, env.cls, NULL);
env.problem_found = 0;
+ be_liveness_assure_sets(env.lv);
irg_block_walk_graph(irg, verify_liveness_walker, NULL, &env);
be_liveness_free(env.lv);
* 1. Make sure that all phi nodes are scheduled at the beginning of the block
* 2. There is 1 or no control flow changing node scheduled and exactly delay_branches operations after it.
* 3. No value is defined after it has been used
+ * 4. mode_T nodes have all projs scheduled behind them followed by Keeps
+ * (except mode_X projs)
*/
sched_foreach(block, node) {
int i, arity;
node, block, get_irg_dump_name(env->irg));
env->problem_found = 1;
}
+
+ // check that all projs/keeps are behind their nodes
+ if(is_Proj(node)) {
+ ir_node *prev = sched_prev(node);
+ while(is_Proj(prev))
+ prev = sched_prev(prev);
+ if(get_Proj_pred(node) != prev) {
+ ir_fprintf(stderr, "%+F not scheduled after its pred node in block %+F (%s)\n",
+ node, block, get_irg_dump_name(env->irg));
+ env->problem_found = 1;
+ }
+ }
+ if(be_is_Keep(node)) {
+ int arity = get_irn_arity(node);
+ int problem = 0;
+ for(i = 0; i < arity; ++i) {
+ ir_node *in = get_irn_n(node, i);
+ ir_node *succ = sched_next(in);
+ while(succ != node && !sched_is_end(succ)) {
+ /* the node in between has to be another input of the
+ * keep or a Proj */
+ int i2;
+ int found = 0;
+
+ if(is_Proj(succ)) {
+ succ = sched_next(succ);
+ continue;
+ }
+
+ for(i2 = 0; i2 < arity; ++i2) {
+ ir_node *in2 = get_irn_n(node, i2);
+ if(in2 == succ) {
+ found = 1;
+ break;
+ }
+ }
+ if(!found)
+ problem = 1;
+
+ succ = sched_next(succ);
+ }
+ }
+ if(problem) {
+ ir_fprintf(stderr, "%+F not scheduled after its pred node in block %+F (%s)\n",
+ node, block, get_irg_dump_name(env->irg));
+ env->problem_found = 1;
+ }
+ }
}
/* check that all delay branches are filled (at least with NOPs) */
if(get_irn_mode(node) == mode_M) {
if(is_Proj(node))
- return -1;
+ return 0;
if(is_Phi(node) || is_Sync(node) || is_Pin(node))
return 0;
}
- if(is_Proj(node) && get_irn_mode(node) == mode_X)
- return 0;
+ if(is_Proj(node)) {
+ if(get_irn_mode(node) == mode_X)
+ return 0;
+ return should_be_scheduled(env, get_Proj_pred(node));
+ }
if(be_is_Keep(node) && get_irn_opcode(get_nodes_block(node)) == iro_Bad)
return 0;
static int cmp_spill(const void* d1, const void* d2, size_t size) {
const spill_t* s1 = d1;
const spill_t* s2 = d2;
+ (void) size;
+
return s1->spill != s2->spill;
}
return result;
}
-static void collect(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent);
+static
+void collect(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent);
-static void check_entity(be_verify_spillslots_env_t *env, ir_node *node, ir_entity *ent) {
+static
+void be_check_entity(be_verify_spillslots_env_t *env, ir_node *node, ir_entity *ent) {
if(ent == NULL) {
ir_fprintf(stderr, "Verify warning: Node %+F in block %+F(%s) should have an entity assigned\n",
node, get_nodes_block(node), get_irg_dump_name(env->irg));
}
}
-static void collect_spill(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent) {
+static
+void collect_spill(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent) {
ir_entity *spillent = arch_get_frame_entity(env->arch_env, node);
- check_entity(env, node, spillent);
+ be_check_entity(env, node, spillent);
get_spill(env, node, ent);
if(spillent != ent) {
out = get_Proj_proj(node);
spillent = be_get_MemPerm_out_entity(memperm, out);
- check_entity(env, memperm, spillent);
+ be_check_entity(env, memperm, spillent);
if(spillent != ent) {
ir_fprintf(stderr, "Verify warning: MemPerm %+F has different entity than reload %+F in block %+F(%s)\n",
node, reload, get_nodes_block(node), get_irg_dump_name(env->irg));
return;
}
ent = arch_get_frame_entity(env->arch_env, node);
- check_entity(env, node, ent);
+ be_check_entity(env, node, ent);
collect(env, spill, node, ent);
ARR_APP1(ir_node*, env->reloads, node);
spill_t *spill = find_spill(env, node);
if(be_is_Spill(node)) {
ir_entity *ent = arch_get_frame_entity(env->arch_env, node);
- check_entity(env, node, ent);
+ be_check_entity(env, node, ent);
}
if(spill == NULL) {
env.lv = be_liveness(irg);
env.problem_found = 0;
+ be_liveness_assure_sets(env.lv);
irg_block_walk_graph(irg, verify_block_register_allocation, NULL, &env);
be_liveness_free(env.lv);