2 * Author: Matthias Braun
4 * Copyright: (c) Universitaet Karlsruhe
5 * License: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
22 typedef struct be_verify_register_pressure_env_t_ {
23 const arch_env_t *arch_env;
24 const arch_register_class_t *cls;
25 int registers_available;
27 } be_verify_register_pressure_env_t;
29 static void verify_liveness_walker(ir_node *bl, void *data)
31 be_verify_register_pressure_env_t *env = (be_verify_register_pressure_env_t*) data;
33 pset *live_nodes = pset_new_ptr_default();
36 // collect register pressure info
37 be_liveness_end_of_block(env->arch_env, env->cls, bl, live_nodes);
38 pressure = pset_count(live_nodes);
39 if(pressure > env->registers_available) {
40 ir_printf("Verify Warning: Register pressure too high at end of block %+F (%d/%d).\n",
41 bl, pressure, env->registers_available);
42 env->problem_found = 1;
44 sched_foreach_reverse(bl, irn) {
50 be_liveness_transfer(env->arch_env, env->cls, irn, live_nodes);
51 pressure = pset_count(live_nodes);
53 if(pressure > env->registers_available) {
54 ir_printf("Verify Warning: Register pressure too high before %+F (in block %+F) (%d/%d).\n",
55 irn, bl, pressure, env->registers_available);
56 env->problem_found = 1;
62 void be_verify_register_pressure(const arch_env_t *arch_env, const arch_register_class_t *cls, ir_graph *irg)
64 be_verify_register_pressure_env_t env;
68 env.arch_env = arch_env;
70 env.registers_available = arch_count_non_ignore_regs(arch_env, cls);
71 env.problem_found = 0;
73 irg_block_walk_graph(irg, verify_liveness_walker, NULL, &env);
75 assert(env.problem_found == 0);
78 typedef struct be_verify_schedule_env_t_ {
81 } be_verify_schedule_env_t;
83 static void verify_schedule_walker(ir_node *bl, void *data)
85 be_verify_schedule_env_t *env = (be_verify_schedule_env_t*) data;
87 int non_phi_found = 0;
88 int first_cfchange_found = 0;
91 * Make sure that all phi nodes are scheduled at the beginning of the block, and that there
92 * are no nodes scheduled after a control flow changing node
94 sched_foreach(bl, irn) {
97 ir_printf("Verify Warning: Phi node %+F scheduled after non-Phi nodes in block %+F (%s)\n",
98 irn, bl, get_irg_dump_name(env->irg));
99 env->problem_found = 1;
105 if(is_cfop(irn) && get_irn_opcode(irn) != iro_Start) {
106 first_cfchange_found = 1;
108 if(first_cfchange_found) {
109 ir_printf("Verify Warning: Node %+F scheduled after control flow changing node in block %+F (%s)\n",
110 irn, bl, get_irg_dump_name(env->irg));
111 env->problem_found = 1;
118 void be_verify_schedule(ir_graph *irg)
120 be_verify_schedule_env_t env;
122 env.problem_found = 0;
125 irg_block_walk_graph(irg, verify_schedule_walker, NULL, &env);
127 assert(env.problem_found == 0);