OSDN Git Service

* expr.c (highest_pow2_factor_for_type): Rename into
[pf3gnuchains/gcc-fork.git] / gcc / integrate.c
index 6c5fdf4..f30e3b9 100644 (file)
@@ -1,6 +1,6 @@
 /* Procedure integration for GCC.
    Copyright (C) 1988, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
 This file is part of GCC.
@@ -172,6 +172,9 @@ function_cannot_inline_p (tree fndecl)
   if (current_function_calls_alloca)
     return N_("function using alloca cannot be inline");
 
+  if (current_function_calls_longjmp)
+    return N_("function using longjmp cannot be inline");
+  
   if (current_function_calls_setjmp)
     return N_("function using setjmp cannot be inline");
 
@@ -188,7 +191,7 @@ function_cannot_inline_p (tree fndecl)
   if (current_function_cannot_inline)
     return current_function_cannot_inline;
 
-  /* If its not even close, don't even look.  */
+  /* If it's not even close, don't even look.  */
   if (get_max_uid () > 3 * max_insns)
     return N_("function too large to be inline");
 
@@ -283,7 +286,7 @@ initialize_for_inline (tree fndecl)
   tree parms;
 
   /* Clear out PARMDECL_MAP.  It was allocated in the caller's frame.  */
-  memset ((char *) parmdecl_map, 0, max_parm_reg * sizeof (tree));
+  memset (parmdecl_map, 0, max_parm_reg * sizeof (tree));
   arg_vector = rtvec_alloc (list_length (DECL_ARGUMENTS (fndecl)));
 
   for (parms = DECL_ARGUMENTS (fndecl), i = 0;
@@ -368,6 +371,8 @@ copy_decl_for_inlining (tree decl, tree from_fn, tree to_fn)
   else
     {
       copy = copy_node (decl);
+      /* The COPY is not abstract; it will be generated in TO_FN.  */
+      DECL_ABSTRACT (copy) = 0;
       (*lang_hooks.dup_lang_specific_decl) (copy);
 
       /* TREE_ADDRESSABLE isn't used to indicate that a label's
@@ -409,8 +414,8 @@ copy_decl_for_inlining (tree decl, tree from_fn, tree to_fn)
 }
 
 /* Make the insns and PARM_DECLs of the current function permanent
-   and record other information in DECL_SAVED_INSNS to allow inlining
-   of this function in subsequent calls.
+   and record other information in DECL_STRUCT_FUNCTION to allow
+   inlining of this function in subsequent calls.
 
    This routine need not copy any insns because we are not going
    to immediately compile the insns in the insn chain.  There
@@ -440,7 +445,7 @@ save_for_inline (tree fndecl)
      for the parms, prior to elimination of virtual registers.
      These values are needed for substituting parms properly.  */
   if (! flag_no_inline)
-    parmdecl_map = (tree *) xmalloc (max_parm_reg * sizeof (tree));
+    parmdecl_map = xmalloc (max_parm_reg * sizeof (tree));
 
   /* Make and emit a return-label if we have not already done so.  */
 
@@ -490,7 +495,7 @@ save_for_inline (tree fndecl)
     }
   cfun->original_decl_initial = DECL_INITIAL (fndecl);
   cfun->no_debugging_symbols = (write_symbols == NO_DEBUG);
-  DECL_SAVED_INSNS (fndecl) = cfun;
+  cfun->saved_for_inline = 1;
 
   /* Clean up.  */
   if (! flag_no_inline)
@@ -637,7 +642,7 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
                        tree type, rtx structure_value_addr)
 {
   struct function *inlining_previous;
-  struct function *inl_f = DECL_SAVED_INSNS (fndecl);
+  struct function *inl_f = DECL_STRUCT_FUNCTION (fndecl);
   tree formal, actual, block;
   rtx parm_insns = inl_f->emit->x_first_insn;
   rtx insns = (inl_f->inl_last_parm_insn
@@ -722,8 +727,8 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
   /* Expand the function arguments.  Do this first so that any
      new registers get created before we allocate the maps.  */
 
-  arg_vals = (rtx *) xmalloc (nargs * sizeof (rtx));
-  arg_trees = (tree *) xmalloc (nargs * sizeof (tree));
+  arg_vals = xmalloc (nargs * sizeof (rtx));
+  arg_trees = xmalloc (nargs * sizeof (tree));
 
   for (formal = DECL_ARGUMENTS (fndecl), actual = parms, i = 0;
        formal;
@@ -766,7 +771,7 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
                abort ();
 
              /* The mode if LOC and ARG can differ if LOC was a variable
-                that had its mode promoted via PROMOTED_MODE.  */
+                that had its mode promoted.  */
              arg_vals[i] = convert_modes (pmode,
                                           TYPE_MODE (TREE_TYPE (arg)),
                                           expand_expr (arg, NULL_RTX, mode,
@@ -818,22 +823,21 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
 
   /* Allocate the structures we use to remap things.  */
 
-  map = (struct inline_remap *) xcalloc (1, sizeof (struct inline_remap));
+  map = xcalloc (1, sizeof (struct inline_remap));
   map->fndecl = fndecl;
 
   VARRAY_TREE_INIT (map->block_map, 10, "block_map");
-  map->reg_map = (rtx *) xcalloc (max_regno, sizeof (rtx));
+  map->reg_map = xcalloc (max_regno, sizeof (rtx));
 
   /* We used to use alloca here, but the size of what it would try to
      allocate would occasionally cause it to exceed the stack limit and
      cause unpredictable core dumps.  */
-  real_label_map
-    = (rtx *) xmalloc ((max_labelno) * sizeof (rtx));
+  real_label_map = xmalloc ((max_labelno) * sizeof (rtx));
   map->label_map = real_label_map;
   map->local_return_label = NULL_RTX;
 
   inl_max_uid = (inl_f->emit->x_cur_insn_uid + 1);
-  map->insn_map = (rtx *) xcalloc (inl_max_uid, sizeof (rtx));
+  map->insn_map = xcalloc (inl_max_uid, sizeof (rtx));
   map->min_insnno = 0;
   map->max_insnno = inl_max_uid;
 
@@ -949,7 +953,7 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
             incoming arg rtx values are expanded now so that we can be
             sure we have enough slots in the const equiv map since the
             store_expr call can easily blow the size estimate.  */
-         if (DECL_SAVED_INSNS (fndecl)->args_size != 0)
+         if (DECL_STRUCT_FUNCTION (fndecl)->args_size != 0)
            copy_rtx_and_substitute (virtual_incoming_args_rtx, map, 0);
        }
       else if (GET_CODE (loc) == REG)
@@ -1027,7 +1031,7 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
       else
        {
          if (! structure_value_addr
-             || ! aggregate_value_p (DECL_RESULT (fndecl)))
+             || ! aggregate_value_p (DECL_RESULT (fndecl), fndecl))
            abort ();
 
          /* Pass the function the address in which to return a structure
@@ -1183,8 +1187,8 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
 
   /* Initialize label_map.  get_label_from_map will actually make
      the labels.  */
-  memset ((char *) &map->label_map[min_labelno], 0,
-        (max_labelno - min_labelno) * sizeof (rtx));
+  memset (&map->label_map[min_labelno], 0,
+         (max_labelno - min_labelno) * sizeof (rtx));
 
   /* Make copies of the decls of the symbols in the inline function, so that
      the copies of the variables get declared in the current function.  Set
@@ -1282,7 +1286,7 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore,
      out of the temp register into a BLKmode memory object.  */
   if (target
       && TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == BLKmode
-      && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl))))
+      && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl)), fndecl))
     target = copy_blkmode_from_reg (0, target, TREE_TYPE (TREE_TYPE (fndecl)));
 
   if (structure_value_addr)
@@ -1417,7 +1421,7 @@ copy_insn_list (rtx insns, struct inline_remap *map, rtx static_chain_value)
                  gen_rtx_MEM (GET_MODE (static_chain_incoming_rtx),
                               SET_DEST (set));
 
-             /* emit the instruction in case it is used for something
+             /* Emit the instruction in case it is used for something
                 other than setting the static chain; if it's not used,
                 it can always be removed as dead code */
              copy = emit_insn (copy_rtx_and_substitute (pattern, map, 0));
@@ -1882,7 +1886,8 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
       regno = REGNO (orig);
       if (regno <= LAST_VIRTUAL_REGISTER
          || (map->integrating
-             && DECL_SAVED_INSNS (map->fndecl)->internal_arg_pointer == orig))
+             && DECL_STRUCT_FUNCTION (map->fndecl)->internal_arg_pointer
+                == orig))
        {
          /* Some hard registers are also mapped,
             but others are not translated.  */
@@ -1900,10 +1905,11 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
          else if (regno == VIRTUAL_STACK_VARS_REGNUM)
            {
              rtx loc, seq;
-             int size = get_func_frame_size (DECL_SAVED_INSNS (map->fndecl));
+             int size
+               = get_func_frame_size (DECL_STRUCT_FUNCTION (map->fndecl));
 #ifdef FRAME_GROWS_DOWNWARD
              int alignment
-               = (DECL_SAVED_INSNS (map->fndecl)->stack_alignment_needed
+               = (DECL_STRUCT_FUNCTION (map->fndecl)->stack_alignment_needed
                   / BITS_PER_UNIT);
 
              /* In this case, virtual_stack_vars_rtx points to one byte
@@ -1938,13 +1944,13 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
            }
          else if (regno == VIRTUAL_INCOMING_ARGS_REGNUM
                   || (map->integrating
-                      && (DECL_SAVED_INSNS (map->fndecl)->internal_arg_pointer
+                      && (DECL_STRUCT_FUNCTION (map->fndecl)->internal_arg_pointer
                           == orig)))
            {
              /* Do the same for a block to contain any arguments referenced
                 in memory.  */
              rtx loc, seq;
-             int size = DECL_SAVED_INSNS (map->fndecl)->args_size;
+             int size = DECL_STRUCT_FUNCTION (map->fndecl)->args_size;
 
              start_sequence ();
              loc = assign_stack_temp (BLKmode, size, 1);
@@ -2086,7 +2092,7 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
       if (NOTE_LINE_NUMBER (orig) != NOTE_INSN_DELETED_LABEL)
        break;
 
-      /* ... FALLTHRU ...  */
+      /* Fall through.  */
     case CODE_LABEL:
       LABEL_PRESERVE_P (get_label_from_map (map, CODE_LABEL_NUMBER (orig)))
        = LABEL_PRESERVE_P (orig);
@@ -2156,11 +2162,7 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
 #endif
 
              temp = XEXP (temp, 0);
-
-#ifdef POINTERS_EXTEND_UNSIGNED
-             if (GET_MODE (temp) != GET_MODE (orig))
-               temp = convert_memory_address (GET_MODE (orig), temp);
-#endif
+             temp = convert_memory_address (GET_MODE (orig), temp);
              return temp;
            }
          else if (GET_CODE (constant) == LABEL_REF)
@@ -2341,8 +2343,7 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
       switch (*format_ptr++)
        {
        case '0':
-         /* Copy this through the wide int field; that's safest.  */
-         X0WINT (copy, i) = X0WINT (orig, i);
+         X0ANY (copy, i) = X0ANY (orig, i);
          break;
 
        case 'e':
@@ -2710,7 +2711,8 @@ subst_constants (rtx *loc, rtx insn, struct inline_remap *map, int memonly)
   /* If this is a commutative operation, move a constant to the second
      operand unless the second operand is already a CONST_INT.  */
   if (! memonly
-      && (GET_RTX_CLASS (code) == 'c' || code == NE || code == EQ)
+      && (GET_RTX_CLASS (code) == RTX_COMM_ARITH
+         || GET_RTX_CLASS (code) == RTX_COMM_COMPARE)
       && CONSTANT_P (XEXP (x, 0)) && GET_CODE (XEXP (x, 1)) != CONST_INT)
     {
       rtx tem = XEXP (x, 0);
@@ -2722,14 +2724,15 @@ subst_constants (rtx *loc, rtx insn, struct inline_remap *map, int memonly)
   if (! memonly)
     switch (GET_RTX_CLASS (code))
       {
-      case '1':
+      case RTX_UNARY:
        if (op0_mode == MAX_MACHINE_MODE)
          abort ();
        new = simplify_unary_operation (code, GET_MODE (x),
                                        XEXP (x, 0), op0_mode);
        break;
 
-      case '<':
+      case RTX_COMPARE:
+      case RTX_COMM_COMPARE:
        {
          enum machine_mode op_mode = GET_MODE (XEXP (x, 0));
 
@@ -2756,14 +2759,14 @@ subst_constants (rtx *loc, rtx insn, struct inline_remap *map, int memonly)
          break;
        }
 
-      case '2':
-      case 'c':
+      case RTX_BIN_ARITH:
+      case RTX_COMM_ARITH:
        new = simplify_binary_operation (code, GET_MODE (x),
                                         XEXP (x, 0), XEXP (x, 1));
        break;
 
-      case 'b':
-      case '3':
+      case RTX_BITFIELD_OPS:
+      case RTX_TERNARY:
        if (op0_mode == MAX_MACHINE_MODE)
          abort ();
 
@@ -2771,7 +2774,7 @@ subst_constants (rtx *loc, rtx insn, struct inline_remap *map, int memonly)
          {
            rtx op0 = XEXP (x, 0);
 
-           if (GET_RTX_CLASS (GET_CODE (op0)) == '<'
+           if (COMPARISON_P (op0)
                && GET_MODE (op0) == VOIDmode
                && ! side_effects_p (op0)
                && XEXP (op0, 0) == map->compare_src
@@ -2796,6 +2799,9 @@ subst_constants (rtx *loc, rtx insn, struct inline_remap *map, int memonly)
                                            XEXP (x, 0), XEXP (x, 1),
                                            XEXP (x, 2));
        break;
+
+      default:
+       break;
       }
 
   if (new)
@@ -2831,7 +2837,7 @@ mark_stores (rtx dest, rtx x ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED)
     {
       unsigned int uregno = regno;
       unsigned int last_reg = (uregno >= FIRST_PSEUDO_REGISTER ? uregno
-                              : uregno + HARD_REGNO_NREGS (uregno, mode) - 1);
+                              : uregno + hard_regno_nregs[uregno][mode] - 1);
       unsigned int i;
 
       /* Ignore virtual stack var or virtual arg register since those
@@ -2957,8 +2963,8 @@ set_decl_abstract_flags (tree decl, int setting)
     }
 }
 \f
-/* Output the assembly language code for the function FNDECL
-   from its DECL_SAVED_INSNS.  Used for inline functions that are output
+/* Output the assembly language code for the function FNDECL from
+   its DECL_STRUCT_FUNCTION.  Used for inline functions that are output
    at end of compilation instead of where they came in the source.  */
 
 static GTY(()) struct function *old_cfun;
@@ -2968,7 +2974,7 @@ output_inline_function (tree fndecl)
 {
   enum debug_info_type old_write_symbols = write_symbols;
   const struct gcc_debug_hooks *const old_debug_hooks = debug_hooks;
-  struct function *f = DECL_SAVED_INSNS (fndecl);
+  struct function *f = DECL_STRUCT_FUNCTION (fndecl);
 
   old_cfun = cfun;
   cfun = f;
@@ -3049,20 +3055,19 @@ get_func_hard_reg_initial_val (struct function *fun, rtx reg)
 
   if (ivs == 0)
     {
-      fun->hard_reg_initial_vals = (void *) ggc_alloc (sizeof (initial_value_struct));
+      fun->hard_reg_initial_vals = ggc_alloc (sizeof (initial_value_struct));
       ivs = fun->hard_reg_initial_vals;
       ivs->num_entries = 0;
       ivs->max_entries = 5;
-      ivs->entries = (initial_value_pair *) ggc_alloc (5 * sizeof (initial_value_pair));
+      ivs->entries = ggc_alloc (5 * sizeof (initial_value_pair));
     }
 
   if (ivs->num_entries >= ivs->max_entries)
     {
       ivs->max_entries += 5;
-      ivs->entries =
-       (initial_value_pair *) ggc_realloc (ivs->entries,
-                                           ivs->max_entries
-                                           * sizeof (initial_value_pair));
+      ivs->entries = ggc_realloc (ivs->entries,
+                                 ivs->max_entries
+                                 * sizeof (initial_value_pair));
     }
 
   ivs->entries[ivs->num_entries].hard_reg = reg;