OSDN Git Service

2010-02-03 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / tree-switch-conversion.c
index eade177..1fd9094 100644 (file)
@@ -443,7 +443,7 @@ build_constructors (gimple swtch)
          tree low = CASE_LOW (cs);
          pos = CASE_LOW (cs);
 
-         do 
+         do
            {
              constructor_elt *elt;
 
@@ -473,7 +473,7 @@ constructor_contains_same_values_p (VEC (constructor_elt, gc) *vec)
   for (i = 0; i < len; i++)
     {
       constructor_elt *elt = VEC_index (constructor_elt, vec, i);
-      
+
       if (!prev)
        prev = elt->value;
       else if (!operand_equal_p (elt->value, prev, OEP_ONLY_CONST))
@@ -499,6 +499,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
   tree name, cst;
   gimple load;
   gimple_stmt_iterator gsi = gsi_for_stmt (swtch);
+  location_t loc = gimple_location (swtch);
 
   gcc_assert (info.default_values[num]);
 
@@ -517,7 +518,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
       ctor = build_constructor (array_type, info.constructors[num]);
       TREE_CONSTANT (ctor) = true;
 
-      decl = build_decl (VAR_DECL, NULL_TREE, array_type);
+      decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type);
       TREE_STATIC (decl) = 1;
       DECL_INITIAL (decl) = ctor;
 
@@ -547,19 +548,23 @@ static void
 build_arrays (gimple swtch)
 {
   tree arr_index_type;
-  tree tidx, sub;
+  tree tidx, sub, tmp;
   gimple stmt;
   gimple_stmt_iterator gsi;
   int i;
+  location_t loc = gimple_location (swtch);
 
   gsi = gsi_for_stmt (swtch);
 
   arr_index_type = build_index_type (info.range_size);
-  tidx = make_ssa_name (create_tmp_var (arr_index_type, "csti"), NULL);
-  sub = fold_build2 (MINUS_EXPR, TREE_TYPE (info.index_expr), info.index_expr,
-                    fold_convert (TREE_TYPE (info.index_expr),
-                                  info.range_min));
-  sub = force_gimple_operand_gsi (&gsi, fold_convert (arr_index_type, sub),
+  tmp = create_tmp_var (TREE_TYPE (info.index_expr), "csti");
+  add_referenced_var (tmp);
+  tidx = make_ssa_name (tmp, NULL);
+  sub = fold_build2_loc (loc, MINUS_EXPR,
+                    TREE_TYPE (info.index_expr), info.index_expr,
+                    fold_convert_loc (loc, TREE_TYPE (info.index_expr),
+                                      info.range_min));
+  sub = force_gimple_operand_gsi (&gsi, sub,
                                  false, NULL, true, GSI_SAME_STMT);
   stmt = gimple_build_assign (tidx, sub);
   SSA_NAME_DEF_STMT (tidx) = stmt;
@@ -633,8 +638,8 @@ fix_phi_nodes (edge e1f, edge e2f, basic_block bbf)
        !gsi_end_p (gsi); gsi_next (&gsi), i++)
     {
       gimple phi = gsi_stmt (gsi);
-      add_phi_arg (phi, info.target_inbound_names[i], e1f);
-      add_phi_arg (phi, info.target_outbound_names[i], e2f);
+      add_phi_arg (phi, info.target_inbound_names[i], e1f, UNKNOWN_LOCATION);
+      add_phi_arg (phi, info.target_outbound_names[i], e2f, UNKNOWN_LOCATION);
     }
 
 }
@@ -663,9 +668,9 @@ fix_phi_nodes (edge e1f, edge e2f, basic_block bbf)
 static void
 gen_inbound_check (gimple swtch)
 {
-  tree label_decl1 = create_artificial_label ();
-  tree label_decl2 = create_artificial_label ();
-  tree label_decl3 = create_artificial_label ();
+  tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
+  tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
+  tree label_decl3 = create_artificial_label (UNKNOWN_LOCATION);
   gimple label1, label2, label3;
 
   tree utype;
@@ -681,6 +686,7 @@ gen_inbound_check (gimple swtch)
   gimple_stmt_iterator gsi;
   basic_block bb0, bb1, bb2, bbf, bbd;
   edge e01, e02, e21, e1d, e1f, e2f;
+  location_t loc = gimple_location (swtch);
 
   gcc_assert (info.default_values);
   bb0 = gimple_bb (swtch);
@@ -694,16 +700,17 @@ gen_inbound_check (gimple swtch)
   /* (end of) block 0 */
   gsi = gsi_for_stmt (info.arr_ref_first);
   tmp_u_var = create_tmp_var (utype, "csui");
+  add_referenced_var (tmp_u_var);
   tmp_u_1 = make_ssa_name (tmp_u_var, NULL);
 
-  cast = fold_convert (utype, info.index_expr);
+  cast = fold_convert_loc (loc, utype, info.index_expr);
   cast_assign = gimple_build_assign (tmp_u_1, cast);
   SSA_NAME_DEF_STMT (tmp_u_1) = cast_assign;
   gsi_insert_before (&gsi, cast_assign, GSI_SAME_STMT);
   update_stmt (cast_assign);
 
-  ulb = fold_convert (utype, info.range_min);
-  minus = fold_build2 (MINUS_EXPR, utype, tmp_u_1, ulb);
+  ulb = fold_convert_loc (loc, utype, info.range_min);
+  minus = fold_build2_loc (loc, MINUS_EXPR, utype, tmp_u_1, ulb);
   minus = force_gimple_operand_gsi (&gsi, minus, false, NULL, true,
                                    GSI_SAME_STMT);
   tmp_u_2 = make_ssa_name (tmp_u_var, NULL);
@@ -712,7 +719,7 @@ gen_inbound_check (gimple swtch)
   gsi_insert_before (&gsi, minus_assign, GSI_SAME_STMT);
   update_stmt (minus_assign);
 
-  bound = fold_convert (utype, info.range_size);
+  bound = fold_convert_loc (loc, utype, info.range_size);
   cond_stmt = gimple_build_cond (LE_EXPR, tmp_u_2, bound, NULL_TREE, NULL_TREE);
   gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT);
   update_stmt (cond_stmt);
@@ -868,7 +875,7 @@ do_switchconv (void)
                     "SWITCH statement (%s:%d) : ------- \n",
                     loc.file, loc.line);
            print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
-           fprintf (dump_file, "\n");
+           putc ('\n', dump_file);
          }
 
        info.reason = NULL;
@@ -876,8 +883,8 @@ do_switchconv (void)
          {
            if (dump_file)
              {
-               fprintf (dump_file, "Switch converted\n");
-               fprintf (dump_file, "--------------------------------\n");
+               fputs ("Switch converted\n", dump_file);
+               fputs ("--------------------------------\n", dump_file);
              }
          }
        else
@@ -885,9 +892,9 @@ do_switchconv (void)
            if (dump_file)
              {
                gcc_assert (info.reason);
-               fprintf (dump_file, "Bailing out - ");
-               fprintf (dump_file, info.reason);
-               fprintf (dump_file, "--------------------------------\n");
+               fputs ("Bailing out - ", dump_file);
+               fputs (info.reason, dump_file);
+               fputs ("--------------------------------\n", dump_file);
              }
          }
       }