sparc: implement omit-fp mode
[libfirm] / ir / be / beverify.c
index db35228..3f56903 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2010 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -119,15 +119,15 @@ static void verify_liveness_walker(ir_node *block, void *data)
 /**
  * Start a walk over the irg and check the register pressure.
  */
-int be_verify_register_pressure(const be_irg_t *birg,
-                                const arch_register_class_t *cls, ir_graph *irg)
+int be_verify_register_pressure(ir_graph *irg, const arch_register_class_t *cls)
 {
        be_verify_register_pressure_env_t env;
 
        env.lv                  = be_liveness(irg);
        env.irg                 = irg;
        env.cls                 = cls;
-       env.registers_available = env.cls->n_regs - be_put_ignore_regs(birg, env.cls, NULL);
+       env.registers_available
+               = env.cls->n_regs - be_put_ignore_regs(irg, env.cls, NULL);
        env.problem_found       = 0;
 
        be_liveness_assure_sets(env.lv);
@@ -144,9 +144,9 @@ int be_verify_register_pressure(const be_irg_t *birg,
 
 
 typedef struct be_verify_schedule_env_t_ {
-       int      problem_found;     /**< flags indicating if there was a problem */
-       bitset_t *scheduled;        /**< bitset of scheduled nodes */
-       ir_graph *irg;              /**< the irg to check */
+       int       problem_found; /**< flags indicating a problem */
+       bitset_t *scheduled;     /**< bitset of scheduled nodes */
+       ir_graph *irg;           /**< the irg to check */
 } be_verify_schedule_env_t;
 
 /**
@@ -285,50 +285,12 @@ static void verify_schedule_walker(ir_node *block, void *data)
        }
 }
 
-static int should_be_scheduled(ir_node *node)
-{
-       switch (get_irn_opcode(node)) {
-       case iro_Bad:
-       case iro_Block:
-       case iro_End:
-       case iro_NoMem:
-       case iro_Pin:
-       case iro_Proj:
-       case iro_Sync:
-       case iro_Unknown:
-               return 0;
-       case iro_Phi:
-               if (get_irn_mode(node) == mode_M)
-                       return 0;
-               break;
-       case iro_Start:
-       case iro_Jmp:
-       case beo_Return:
-               return 1;
-       default:
-               break;
-       }
-
-       if (get_irn_mode(node) != mode_T) {
-               if (arch_irn_is_ignore(node))
-                       return -1;
-       }
-
-       return 1;
-}
-
 static void check_schedule(ir_node *node, void *data)
 {
        be_verify_schedule_env_t *env = data;
-       int should_be;
-       int scheduled;
-
-       should_be = should_be_scheduled(node);
-       if (should_be == -1)
-               return;
+       bool should_be = to_appear_in_schedule(node);
+       bool scheduled = bitset_is_set(env->scheduled, get_irn_idx(node));
 
-       scheduled = bitset_is_set(env->scheduled, get_irn_idx(node)) ? 1 : 0;
-       should_be = should_be ? 1 : 0;
        if (should_be != scheduled) {
                ir_fprintf(stderr, "Verify warning: Node %+F in block %+F(%s) should%s be scheduled\n",
                        node, get_nodes_block(node), get_irg_dump_name(env->irg), should_be ? "" : " not");
@@ -339,17 +301,17 @@ static void check_schedule(ir_node *node, void *data)
 /**
  * Start a walk over the irg and check schedule.
  */
-int be_verify_schedule(const be_irg_t *birg)
+int be_verify_schedule(ir_graph *irg)
 {
        be_verify_schedule_env_t env;
 
        env.problem_found = 0;
-       env.irg           = be_get_birg_irg(birg);
+       env.irg           = irg;
        env.scheduled     = bitset_alloca(get_irg_last_idx(env.irg));
 
-       irg_block_walk_graph(env.irg, verify_schedule_walker, NULL, &env);
+       irg_block_walk_graph(irg, verify_schedule_walker, NULL, &env);
        /* check if all nodes are scheduled */
-       irg_walk_graph(env.irg, check_schedule, NULL, &env);
+       irg_walk_graph(irg, check_schedule, NULL, &env);
 
        return ! env.problem_found;
 }
@@ -360,7 +322,7 @@ int be_verify_schedule(const be_irg_t *birg)
 
 
 
-typedef struct _spill_t {
+typedef struct spill_t {
        ir_node *spill;
        ir_entity *ent;
 } spill_t;
@@ -727,10 +689,9 @@ static void check_input_constraints(ir_node *node)
        /* verify input register */
        arity = get_irn_arity(node);
        for (i = 0; i < arity; ++i) {
-               ir_node *pred = get_irn_n(node, i);
-
-               if (is_Unknown(pred))
-                       continue;
+               const arch_register_req_t *req      = arch_get_in_register_req(node, i);
+               ir_node                   *pred     = get_irn_n(node, i);
+               const arch_register_req_t *pred_req = arch_get_register_req_out(pred);
 
                if (is_Bad(pred)) {
                        ir_fprintf(stderr, "Verify warning: %+F in block %+F(%s) has Bad as input %d\n",
@@ -738,11 +699,24 @@ static void check_input_constraints(ir_node *node)
                        problem_found = 1;
                        continue;
                }
-
-               if (arch_get_irn_reg_class(node, i) == NULL)
+               if (req->cls == NULL)
                        continue;
 
+               if (req->width > pred_req->width) {
+                       ir_fprintf(stderr, "Verify warning: %+F in block %+F(%s) register width of value at input %d too small\n",
+                                  node, get_nodes_block(node), get_irg_dump_name(irg), i);
+                       problem_found = 1;
+               }
+
                reg = arch_get_irn_register(pred);
+               if (req->type & arch_register_req_type_aligned) {
+                       if (reg->index % req->width != 0) {
+                               ir_fprintf(stderr, "Verify warning: %+F in block %+F(%s) register allignment not fulfilled\n",
+                                          node, get_nodes_block(node), get_irg_dump_name(irg), i);
+                               problem_found = 1;
+                       }
+               }
+
                if (reg == NULL) {
                        ir_fprintf(stderr, "Verify warning: Node %+F in block %+F(%s) should have a register assigned (%+F input constraint)\n",
                                   pred, get_nodes_block(pred), get_irg_dump_name(irg), node);
@@ -829,12 +803,12 @@ static void verify_block_register_allocation(ir_node *block, void *data)
        int i, nregclasses;
        (void) data;
 
-       nregclasses = arch_env_get_n_reg_class(arch_env);
+       nregclasses = arch_env->n_register_classes;
        for (i = 0; i < nregclasses; ++i) {
                ir_node *node;
                int      idx, i2, n_regs;
 
-               regclass = arch_env_get_reg_class(arch_env, i);
+               regclass = &arch_env->register_classes[i];
 
                assert(lv->nodes && "live sets must be computed");
 
@@ -890,9 +864,9 @@ static void verify_block_register_allocation(ir_node *block, void *data)
        }
 }
 
-int be_verify_register_allocation(const be_irg_t *birg)
+int be_verify_register_allocation(ir_graph *new_irg)
 {
-       irg           = be_get_birg_irg(birg);
+       irg           = new_irg;
        arch_env      = be_get_irg_arch_env(irg);
        lv            = be_liveness(irg);
        problem_found = 0;