Fixed a lot of size_t related warnings, most of them due to array implementation...
[libfirm] / ir / ir / irssacons.c
index 4d653f7..9dd9e94 100644 (file)
  * @author  Michael Beck
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include "ircons_t.h"
 #include "irgraph_t.h"
 #include "irnode_t.h"
 #include "irgwalk.h"
 
-typedef struct walk_env_t {
-       int n_loc;   /**< Number of newly allocated locations. */
-} walk_env;
-
 /**
- * Post-walker: prepare the graph nodes for new SSA construction cycle by allocation
- * new arrays.
+ * Post-walker: prepare the graph nodes for new SSA construction cycle by
+ * allocation new arrays.
  */
-static void prepare_nodes(ir_node *irn, void *ctx) {
-       walk_env *env = ctx;
+static void prepare_nodes(ir_node *irn, void *env)
+{
+       (void)env;
 
-       switch (get_irn_opcode(irn)) {
-       case iro_Block:
+       if (is_Block(irn)) {
+               unsigned        n_loc = current_ir_graph->n_loc;
+               struct obstack *obst  = current_ir_graph->obst;
                /* reset mature flag */
                irn->attr.block.is_matured = 0;
-               irn->attr.block.graph_arr  = NEW_ARR_D(ir_node *, current_ir_graph->obst,
-                                                      current_ir_graph->n_loc);
-               memset(irn->attr.block.graph_arr, 0, sizeof(ir_node *) * current_ir_graph->n_loc);
+               irn->attr.block.graph_arr  = NEW_ARR_D(ir_node *, obst, n_loc);
+               memset(irn->attr.block.graph_arr, 0, sizeof(ir_node*) * n_loc);
                irn->attr.block.phis       = NULL;
-               break;
-#if PRECISE_EXC_CONTEXT
-       /* note that the frag array must be cleared first, else firm_alloc_frag_arr()
-          will not allocate new memory. */
-       case iro_Quot:
-               irn->attr.except.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Quot, &irn->attr.except.frag_arr);
-               break;
-       case iro_DivMod:
-               irn->attr.except.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_DivMod, &irn->attr.except.frag_arr);
-               break;
-       case iro_Div:
-               irn->attr.except.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Div, &irn->attr.except.frag_arr);
-               break;
-       case iro_Mod:
-               irn->attr.except.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Mod, &irn->attr.except.frag_arr);
-               break;
-       case iro_Call:
-               irn->attr.call.exc.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Call, &irn->attr.call.exc.frag_arr);
-               break;
-       case iro_Load:
-               irn->attr.load.exc.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Load, &irn->attr.load.exc.frag_arr);
-               break;
-       case iro_Store:
-               irn->attr.store.exc.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Store, &irn->attr.store.exc.frag_arr);
-               break;
-       case iro_Alloc:
-               irn->attr.alloc.exc.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Alloc, &irn->attr.alloc.exc.frag_arr);
-               break;
-       case iro_CopyB:
-               irn->attr.copyb.exc.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_CopyB, &irn->attr.copyb.exc.frag_arr);
-               break;
-       case iro_Raise:
-               irn->attr.bound.exc.frag_arr = NULL;
-               firm_alloc_frag_arr(irn, op_Bound, &irn->attr.bound.exc.frag_arr);
-               break;
-#endif
-       default:
-               ;
        }
 }
 
@@ -112,9 +60,8 @@ static void prepare_nodes(ir_node *irn, void *ctx) {
  * again and set_value()/get_value() and mature_block() can be used
  * to construct new values.
  */
-void ssa_cons_start(ir_graph *irg, int n_loc) {
-       walk_env env;
-
+void ssa_cons_start(ir_graph *irg, int n_loc)
+{
        /* for now we support only phase_high graphs */
        assert(irg->phase_state == phase_high);
 
@@ -128,13 +75,14 @@ void ssa_cons_start(ir_graph *irg, int n_loc) {
         * seems worth to do this.  First, we have to check if they really exists and
         * then clear them.  We do not expect SSA construction is used often.
         */
-       irg_walk_graph(irg, NULL, prepare_nodes, &env);
+       irg_walk_graph(irg, NULL, prepare_nodes, NULL);
 }
 
 /**
  * mature all immature Blocks.
  */
-static void finish_block(ir_node *block, void *env) {
+static void finish_block(ir_node *block, void *env)
+{
        (void)env;
 
        if (!get_Block_matured(block))
@@ -145,7 +93,8 @@ static void finish_block(ir_node *block, void *env) {
  * Finalize the (restarted) SSA construction. Matures all blocks that are
  * not matured yet and reset the graph state to phase_high.
  */
-void ssa_cons_finish(ir_graph *irg) {
+void ssa_cons_finish(ir_graph *irg)
+{
        irg_block_walk_graph(irg, NULL, finish_block, NULL);
        irg_finalize_cons(irg);
 }