OSDN Git Service

H
[pf3gnuchains/gcc-fork.git] / gcc / calls.c
index 86dc28b..d46973a 100644 (file)
@@ -19,18 +19,15 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 #include "config.h"
-#include <stdio.h>
+#include "system.h"
 #include "rtl.h"
 #include "tree.h"
 #include "flags.h"
 #include "expr.h"
 #include "regs.h"
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include "insn-flags.h"
+#include "toplev.h"
+#include "output.h"
 
 /* Decide whether a function's arguments should be processed
    from first to last or from last to first.
@@ -125,10 +122,11 @@ int stack_arg_under_construction;
 
 static int calls_function      PROTO((tree, int));
 static int calls_function_1    PROTO((tree, int));
-static void emit_call_1                PROTO((rtx, tree, tree, int, int, rtx, rtx,
+static void emit_call_1                PROTO((rtx, tree, tree, HOST_WIDE_INT,
+                                      HOST_WIDE_INT, rtx, rtx,
                                       int, rtx, int));
 static void store_one_arg      PROTO ((struct arg_data *, rtx, int, int,
-                                       tree, int));
+                                       int));
 \f
 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
    `alloca'.
@@ -345,10 +343,10 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, struct_value_size,
              next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
             is_const)
      rtx funexp;
-     tree fndecl;
-     tree funtype;
-     int stack_size;
-     int struct_value_size;
+     tree fndecl ATTRIBUTE_UNUSED;
+     tree funtype ATTRIBUTE_UNUSED;
+     HOST_WIDE_INT stack_size;
+     HOST_WIDE_INT struct_value_size;
      rtx next_arg_reg;
      rtx valreg;
      int old_inhibit_defer_pop;
@@ -509,7 +507,7 @@ expand_call (exp, target, ignore)
   /* Size of aggregate value wanted, or zero if none wanted
      or if we are using the non-reentrant PCC calling convention
      or expecting the value in registers.  */
-  int struct_value_size = 0;
+  HOST_WIDE_INT struct_value_size = 0;
   /* Nonzero if called function returns an aggregate in memory PCC style,
      by returning the address of where to find it.  */
   int pcc_struct_value = 0;
@@ -543,15 +541,11 @@ expand_call (exp, target, ignore)
      So the entire argument block must then be preallocated (i.e., we
      ignore PUSH_ROUNDING in that case).  */
 
-#if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
-  int must_preallocate = 1;
-#else
 #ifdef PUSH_ROUNDING
   int must_preallocate = 0;
 #else
   int must_preallocate = 1;
 #endif
-#endif
 
   /* Size of the stack reserved for parameter registers.  */
   int reg_parm_stack_space = 0;
@@ -601,7 +595,7 @@ expand_call (exp, target, ignore)
      if -fcheck-memory-usage, code which invokes functions (and thus
      damages some hard registers) can be inserted before using the value.
      So, target is always a pseudo-register in that case.  */
-  if (flag_check_memory_usage)
+  if (current_function_check_memory_usage)
     target = 0;
 
   /* See if we can find a DECL-node for the actual function.
@@ -662,6 +656,11 @@ expand_call (exp, target, ignore)
 #endif
 #endif
 
+#if defined(PUSH_ROUNDING) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
+  if (reg_parm_stack_space > 0)
+    must_preallocate = 1;
+#endif
+
   /* Warn if this value is an aggregate type,
      regardless of which calling convention we are using for it.  */
   if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (exp)))
@@ -712,8 +711,7 @@ expand_call (exp, target, ignore)
            DECL_RTL (d) = assign_temp (TREE_TYPE (exp), 1, 0, 1);
            mark_addressable (d);
            structure_value_addr = XEXP (DECL_RTL (d), 0);
-           MEM_IN_STRUCT_P (structure_value_addr)
-             = AGGREGATE_TYPE_P (TREE_TYPE (exp));
+           TREE_USED (d) = 1;
            target = 0;
          }
       }
@@ -771,18 +769,18 @@ expand_call (exp, target, ignore)
                     outgoing argument list in addition to the requested
                     space, but there is no way to ask for stack space such
                     that an argument list of a certain length can be
-                    safely constructed.  */
+                    safely constructed. 
 
-                 int adjust = OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl));
-#ifdef REG_PARM_STACK_SPACE
-                 /* Add the stack space reserved for register arguments
-                    in the inline function.  What is really needed is the
+                    Add the stack space reserved for register arguments, if
+                    any, in the inline function.  What is really needed is the
                     largest value of reg_parm_stack_space in the inline
                     function, but that is not available.  Using the current
                     value of reg_parm_stack_space is wrong, but gives
                     correct results on all supported machines.  */
-                 adjust += reg_parm_stack_space;
-#endif
+
+                 int adjust = (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl))
+                               + reg_parm_stack_space);
+
                  start_sequence ();
                  emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
                  allocate_dynamic_stack_space (GEN_INT (adjust),
@@ -853,7 +851,7 @@ expand_call (exp, target, ignore)
   is_longjmp = 0;
   is_malloc = 0;
 
-  if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15
+  if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 17
       /* Exclude functions not at the file scope, or not `extern',
         since they are not the magic functions we would otherwise
         think they are.  */
@@ -900,8 +898,12 @@ expand_call (exp, target, ignore)
       else if (! strcmp (tname, "malloc")
               || ! strcmp (tname, "calloc")
               || ! strcmp (tname, "realloc")
-              || ! strcmp (tname, "__builtin_new")
-              || ! strcmp (tname, "__builtin_vec_new"))
+              /* Note use of NAME rather than TNAME here.  These functions
+                 are only reserved when preceded with __.  */
+              || ! strcmp (name, "__vn")       /* mangled __builtin_vec_new */
+              || ! strcmp (name, "__nw")       /* mangled __builtin_new */
+              || ! strcmp (name, "__builtin_new")
+              || ! strcmp (name, "__builtin_vec_new"))
        is_malloc = 1;
     }
 
@@ -965,11 +967,11 @@ expand_call (exp, target, ignore)
 
   /* Compute number of named args.
      Normally, don't include the last named arg if anonymous args follow.
-     We do include the last named arg if STRICT_ARGUMENT_NAMING is defined.
+     We do include the last named arg if STRICT_ARGUMENT_NAMING is nonzero.
      (If no anonymous args follow, the result of list_length is actually
      one too large.  This is harmless.)
 
-     If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is not,
+     If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is zero,
      this machine will be able to place unnamed args that were passed in
      registers into the stack.  So treat all args as named.  This allows the
      insns emitting for a specific argument list to be independent of the
@@ -978,18 +980,20 @@ expand_call (exp, target, ignore)
      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
      way to pass unnamed args in registers, so we must force them into
      memory.  */
-#if !defined(SETUP_INCOMING_VARARGS) || defined(STRICT_ARGUMENT_NAMING)
-  if (TYPE_ARG_TYPES (funtype) != 0)
+
+  if ((STRICT_ARGUMENT_NAMING
+#ifndef SETUP_INCOMING_VARARGS
+       || 1
+#endif
+       )
+      && TYPE_ARG_TYPES (funtype) != 0)
     n_named_args
       = (list_length (TYPE_ARG_TYPES (funtype))
-#ifndef STRICT_ARGUMENT_NAMING
         /* Don't include the last named arg.  */
-        - 1
-#endif
+        - (STRICT_ARGUMENT_NAMING ? 0 : 1)
         /* Count the struct value address, if it is passed as a parm.  */
         + structure_value_addr_parm);
   else
-#endif
     /* If we know nothing, treat all args as named.  */
     n_named_args = num_actuals;
 
@@ -1164,9 +1168,7 @@ expand_call (exp, target, ignore)
 
       /* Compute the stack-size of this argument.  */
       if (args[i].reg == 0 || args[i].partial != 0
-#ifdef REG_PARM_STACK_SPACE
          || reg_parm_stack_space > 0
-#endif
          || args[i].pass_on_stack)
        locate_and_pad_parm (mode, type,
 #ifdef STACK_PARMS_IN_REG_PARM_AREA
@@ -1181,14 +1183,12 @@ expand_call (exp, target, ignore)
       args[i].slot_offset = args_size;
 #endif
 
-#ifndef REG_PARM_STACK_SPACE
       /* If a part of the arg was put into registers,
         don't include that part in the amount pushed.  */
-      if (! args[i].pass_on_stack)
+      if (reg_parm_stack_space == 0 && ! args[i].pass_on_stack)
        args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
                                  / (PARM_BOUNDARY / BITS_PER_UNIT)
                                  * (PARM_BOUNDARY / BITS_PER_UNIT));
-#endif
       
       /* Update ARGS_SIZE, the total stack space for args so far.  */
 
@@ -1245,12 +1245,11 @@ expand_call (exp, target, ignore)
        args_size.var = round_up (args_size.var, STACK_BYTES);
 #endif
 
-#ifdef REG_PARM_STACK_SPACE
       if (reg_parm_stack_space > 0)
        {
          args_size.var
            = size_binop (MAX_EXPR, args_size.var,
-                         size_int (REG_PARM_STACK_SPACE (fndecl)));
+                         size_int (reg_parm_stack_space));
 
 #ifndef OUTGOING_REG_PARM_STACK_SPACE
          /* The area corresponding to register parameters is not to count in
@@ -1260,7 +1259,6 @@ expand_call (exp, target, ignore)
                          size_int (reg_parm_stack_space));
 #endif
        }
-#endif
     }
   else
     {
@@ -1269,17 +1267,17 @@ expand_call (exp, target, ignore)
                             / STACK_BYTES) * STACK_BYTES);
 #endif
 
-#ifdef REG_PARM_STACK_SPACE
       args_size.constant = MAX (args_size.constant,
                                reg_parm_stack_space);
+
 #ifdef MAYBE_REG_PARM_STACK_SPACE
       if (reg_parm_stack_space == 0)
        args_size.constant = 0;
 #endif
+
 #ifndef OUTGOING_REG_PARM_STACK_SPACE
       args_size.constant -= reg_parm_stack_space;
 #endif
-#endif
     }
 
   /* See if we have or want to preallocate stack space.
@@ -1444,7 +1442,7 @@ expand_call (exp, target, ignore)
             Another approach might be to try to reorder the argument
             evaluations to avoid this conflicting stack usage.  */
 
-#if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
+#ifndef OUTGOING_REG_PARM_STACK_SPACE
          /* Since we will be writing into the entire argument area, the
             map must be allocated for its entire size, not just the part that
             is the responsibility of the caller.  */
@@ -1516,7 +1514,7 @@ expand_call (exp, target, ignore)
      to initialize an argument.  */
   if (stack_arg_under_construction)
     {
-#if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
+#ifndef OUTGOING_REG_PARM_STACK_SPACE
       rtx push_size = GEN_INT (reg_parm_stack_space + args_size.constant);
 #else
       rtx push_size = GEN_INT (args_size.constant);
@@ -1627,7 +1625,7 @@ expand_call (exp, target, ignore)
       pop_temp_slots ();       /* FUNEXP can't be BLKmode */
 
       /* Check the function is executable.  */
-      if (flag_check_memory_usage)
+      if (current_function_check_memory_usage)
        emit_library_call (chkr_check_exec_libfunc, 1,
                           VOIDmode, 1,
                           funexp, ptr_mode);
@@ -1695,6 +1693,7 @@ expand_call (exp, target, ignore)
       }
 
 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
+
   /* The argument list is the property of the called routine and it
      may clobber it.  If the fixed area has been used for previous
      parameters, we must save and restore it.
@@ -1766,7 +1765,7 @@ expand_call (exp, target, ignore)
   for (i = 0; i < num_actuals; i++)
     if (args[i].reg == 0 || args[i].pass_on_stack)
       store_one_arg (&args[i], argblock, may_be_alloca,
-                    args_size.var != 0, fndecl, reg_parm_stack_space);
+                    args_size.var != 0, reg_parm_stack_space);
 
   /* If we have a parm that is passed in registers but not in memory
      and whose alignment does not permit a direct copy into registers,
@@ -1778,7 +1777,7 @@ expand_call (exp, target, ignore)
       if (args[i].reg != 0 && ! args[i].pass_on_stack
        && args[i].mode == BLKmode
          && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
-             < MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
+             < (unsigned int) MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
        {
          int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
          int big_endian_correction = 0;
@@ -1801,16 +1800,16 @@ expand_call (exp, target, ignore)
            {
              rtx reg = gen_reg_rtx (word_mode);
              rtx word = operand_subword_force (args[i].value, j, BLKmode);
-             int bitsize = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
-             int bitpos;
+             int bitsize = MIN (bytes * BITS_PER_UNIT, BITS_PER_WORD);
+             int bitalign = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
 
              args[i].aligned_regs[j] = reg;
 
-             /* Clobber REG and move each partword into it.  Ensure we don't
-                go past the end of the structure.  Note that the loop below
-                works because we've already verified that padding
-                and endianness are compatible.
+             /* There is no need to restrict this code to loading items
+                in TYPE_ALIGN sized hunks.  The bitfield instructions can
+                load up entire word sized registers efficiently.
 
+                ??? This may not be needed anymore.
                 We use to emit a clobber here but that doesn't let later
                 passes optimize the instructions we emit.  By storing 0 into
                 the register later passes know the first AND to zero out the
@@ -1819,20 +1818,14 @@ expand_call (exp, target, ignore)
 
              emit_move_insn (reg, const0_rtx);
 
-             for (bitpos = 0;
-                  bitpos < BITS_PER_WORD && bytes > 0;
-                  bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
-               {
-                 int xbitpos = bitpos + big_endian_correction;
-
-                 store_bit_field (reg, bitsize, xbitpos, word_mode,
-                                  extract_bit_field (word, bitsize, bitpos, 1,
-                                                     NULL_RTX, word_mode,
-                                                     word_mode,
-                                                     bitsize / BITS_PER_UNIT,
-                                                     BITS_PER_WORD),
-                                  bitsize / BITS_PER_UNIT, BITS_PER_WORD);
-               }
+             bytes -= bitsize / BITS_PER_UNIT;
+             store_bit_field (reg, bitsize, big_endian_correction, word_mode,
+                              extract_bit_field (word, bitsize, 0, 1,
+                                                 NULL_RTX, word_mode,
+                                                 word_mode,
+                                                 bitalign / BITS_PER_UNIT,
+                                                 BITS_PER_WORD),
+                              bitalign / BITS_PER_UNIT, BITS_PER_WORD);
            }
        }
 
@@ -1842,7 +1835,7 @@ expand_call (exp, target, ignore)
     for (i = 0; i < num_actuals; i++)
       if (args[i].partial != 0 && ! args[i].pass_on_stack)
        store_one_arg (&args[i], argblock, may_be_alloca,
-                      args_size.var != 0, fndecl, reg_parm_stack_space);
+                      args_size.var != 0, reg_parm_stack_space);
 
 #ifndef PUSH_ARGS_REVERSED
 #ifdef STACK_BOUNDARY
@@ -1871,7 +1864,7 @@ expand_call (exp, target, ignore)
                                                NULL_RTX)));
 
       /* Mark the memory for the aggregate as write-only.  */
-      if (flag_check_memory_usage)
+      if (current_function_check_memory_usage)
        emit_library_call (chkr_set_right_libfunc, 1,
                           VOIDmode, 3,
                           structure_value_addr, ptr_mode, 
@@ -1918,7 +1911,12 @@ expand_call (exp, target, ignore)
             locations.  The Irix 6 ABI has examples of this.  */
 
          if (GET_CODE (reg) == PARALLEL)
-           emit_group_load (reg, args[i].value);
+           {
+             emit_group_load (reg, args[i].value,
+                              int_size_in_bytes (TREE_TYPE (args[i].tree_value)),
+                              (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
+                               / BITS_PER_UNIT));
+           }
 
          /* If simple case, just do move.  If normal partial, store_one_arg
             has already loaded the register for us.  In all other cases,
@@ -2085,15 +2083,17 @@ expand_call (exp, target, ignore)
      The Irix 6 ABI has examples of this.  */
   else if (GET_CODE (valreg) == PARALLEL)
     {
+      int bytes = int_size_in_bytes (TREE_TYPE (exp));
+
       if (target == 0)
        {
-         int bytes = int_size_in_bytes (TREE_TYPE (exp));
          target = assign_stack_temp (TYPE_MODE (TREE_TYPE (exp)), bytes, 0);
          MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
          preserve_temp_slots (target);
        }
 
-      emit_group_store (target, valreg);
+      emit_group_store (target, valreg, bytes,
+                       TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
     }
   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
           && GET_MODE (target) == GET_MODE (valreg))
@@ -2105,75 +2105,7 @@ expand_call (exp, target, ignore)
        when function inlining is being done.  */
     emit_move_insn (target, valreg);
   else if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
-    {
-      /* Some machines (the PA for example) want to return all small
-        structures in registers regardless of the structure's alignment.
-        
-        Deal with them explicitly by copying from the return registers
-        into the target MEM locations.  */
-      int bytes = int_size_in_bytes (TREE_TYPE (exp));
-      rtx src, dst;
-      int bitsize = MIN (TYPE_ALIGN (TREE_TYPE (exp)), BITS_PER_WORD);
-      int bitpos, xbitpos, big_endian_correction = 0;
-      
-      if (target == 0)
-       {
-         target = assign_stack_temp (BLKmode, bytes, 0);
-         MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
-         preserve_temp_slots (target);
-       }
-
-      /* This code assumes valreg is at least a full word.  If it isn't,
-        copy it into a new pseudo which is a full word.  */
-      if (GET_MODE (valreg) != BLKmode
-         && GET_MODE_SIZE (GET_MODE (valreg)) < UNITS_PER_WORD)
-       valreg = convert_to_mode (word_mode, valreg,
-                                 TREE_UNSIGNED (TREE_TYPE (exp)));
-
-      /* Structures whose size is not a multiple of a word are aligned
-        to the least significant byte (to the right).  On a BYTES_BIG_ENDIAN
-        machine, this means we must skip the empty high order bytes when
-        calculating the bit offset.  */
-      if (BYTES_BIG_ENDIAN && bytes % UNITS_PER_WORD)
-       big_endian_correction = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD)
-                                                 * BITS_PER_UNIT));
-
-      /* Copy the structure BITSIZE bites at a time.
-
-        We could probably emit more efficient code for machines
-        which do not use strict alignment, but it doesn't seem
-        worth the effort at the current time.  */
-      for (bitpos = 0, xbitpos = big_endian_correction;
-          bitpos < bytes * BITS_PER_UNIT;
-          bitpos += bitsize, xbitpos += bitsize)
-       {
-
-         /* We need a new source operand each time xbitpos is on a 
-            word boundary and when xbitpos == big_endian_correction
-            (the first time through).  */
-         if (xbitpos % BITS_PER_WORD == 0
-             || xbitpos == big_endian_correction)
-           src = operand_subword_force (valreg,
-                                        xbitpos / BITS_PER_WORD, 
-                                        BLKmode);
-
-         /* We need a new destination operand each time bitpos is on
-            a word boundary.  */
-         if (bitpos % BITS_PER_WORD == 0)
-           dst = operand_subword (target, bitpos / BITS_PER_WORD, 1, BLKmode);
-             
-         /* Use xbitpos for the source extraction (right justified) and
-            xbitpos for the destination store (left justified).  */
-         store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, word_mode,
-                          extract_bit_field (src, bitsize,
-                                             xbitpos % BITS_PER_WORD, 1,
-                                             NULL_RTX, word_mode,
-                                             word_mode,
-                                             bitsize / BITS_PER_UNIT,
-                                             BITS_PER_WORD),
-                          bitsize / BITS_PER_UNIT, BITS_PER_WORD);
-       }
-    }
+    target = copy_blkmode_from_reg (target, valreg, TREE_TYPE (exp));
   else
     target = copy_to_reg (valreg);
 
@@ -2322,6 +2254,7 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
   struct arg *argvec;
   int old_inhibit_defer_pop = inhibit_defer_pop;
   rtx call_fusage = 0;
+  int reg_parm_stack_space = 0;
 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
   /* Define the boundary of the register parm stack space that needs to be
      save, if any.  */
@@ -2337,7 +2270,6 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
 
 #ifdef REG_PARM_STACK_SPACE
   /* Size of the stack reserved for parameter registers.  */
-  int reg_parm_stack_space = 0;
 #ifdef MAYBE_REG_PARM_STACK_SPACE
   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
 #else
@@ -2433,16 +2365,11 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
       if (argvec[count].size.var)
        abort ();
 
-#ifndef REG_PARM_STACK_SPACE
-      if (argvec[count].partial)
+      if (reg_parm_stack_space == 0 && argvec[count].partial)
        argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
-#endif
 
       if (argvec[count].reg == 0 || argvec[count].partial != 0
-#ifdef REG_PARM_STACK_SPACE
-         || 1
-#endif
-         )
+         || reg_parm_stack_space > 0)
        args_size.constant += argvec[count].size.constant;
 
       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
@@ -2464,13 +2391,12 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
                         / STACK_BYTES) * STACK_BYTES);
 #endif
 
-#ifdef REG_PARM_STACK_SPACE
   args_size.constant = MAX (args_size.constant,
                            reg_parm_stack_space);
+
 #ifndef OUTGOING_REG_PARM_STACK_SPACE
   args_size.constant -= reg_parm_stack_space;
 #endif
-#endif
 
   if (args_size.constant > current_function_outgoing_args_size)
     current_function_outgoing_args_size = args_size.constant;
@@ -2489,7 +2415,8 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
      evaluations to avoid this conflicting stack usage.  */
 
   needed = args_size.constant;
-#if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
+
+#ifndef OUTGOING_REG_PARM_STACK_SPACE
   /* Since we will be writing into the entire argument area, the
      map must be allocated for its entire size, not just the part that
      is the responsibility of the caller.  */
@@ -2638,17 +2565,14 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
 
          for (i = lower_bound; i < upper_bound; i++)
            if (stack_usage_map[i]
-#ifdef REG_PARM_STACK_SPACE
                /* Don't store things in the fixed argument area at this point;
                   it has already been saved.  */
-               && i > reg_parm_stack_space
-#endif
-               )
+               && i > reg_parm_stack_space)
              break;
 
          if (i != upper_bound)
            {
-             /* We need to make a save area.  See what mode we can make it.  */
+             /* We need to make a save area.  See what mode we can make it. */
              enum machine_mode save_mode
                = mode_for_size (argvec[argnum].size.constant * BITS_PER_UNIT,
                                 MODE_INT, 1);
@@ -2661,7 +2585,8 @@ emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
            }
 #endif
          emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
-                         argblock, GEN_INT (argvec[argnum].offset.constant));
+                         argblock, GEN_INT (argvec[argnum].offset.constant),
+                         reg_parm_stack_space);
 
 #ifdef ACCUMULATE_OUTGOING_ARGS
          /* Now mark the segment we just used.  */
@@ -2825,6 +2750,7 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
   int pcc_struct_value = 0;
   int struct_value_size = 0;
   int is_const;
+  int reg_parm_stack_space = 0;
 #ifdef ACCUMULATE_OUTGOING_ARGS
   int needed;
 #endif
@@ -2838,7 +2764,6 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
 
 #ifdef ACCUMULATE_OUTGOING_ARGS
   /* Size of the stack reserved for parameter registers.  */
-  int reg_parm_stack_space = 0;
   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
   char *initial_stack_usage_map = stack_usage_map;
 #endif
@@ -2938,10 +2863,7 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
 
 
       if (argvec[count].reg == 0 || argvec[count].partial != 0
-#ifdef REG_PARM_STACK_SPACE
-         || 1
-#endif
-         )
+         || reg_parm_stack_space > 0)
        args_size.constant += argvec[count].size.constant;
 
       FUNCTION_ARG_ADVANCE (args_so_far, Pmode, (tree) 0, 1);
@@ -3008,16 +2930,11 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
       if (argvec[count].size.var)
        abort ();
 
-#ifndef REG_PARM_STACK_SPACE
-      if (argvec[count].partial)
+      if (reg_parm_stack_space == 0 && argvec[count].partial)
        argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
-#endif
 
       if (argvec[count].reg == 0 || argvec[count].partial != 0
-#ifdef REG_PARM_STACK_SPACE
-         || 1
-#endif
-         )
+         || reg_parm_stack_space > 0)
        args_size.constant += argvec[count].size.constant;
 
       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree) 0, 1);
@@ -3038,13 +2955,12 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
                         / STACK_BYTES) * STACK_BYTES);
 #endif
 
-#ifdef REG_PARM_STACK_SPACE
   args_size.constant = MAX (args_size.constant,
                            reg_parm_stack_space);
+
 #ifndef OUTGOING_REG_PARM_STACK_SPACE
   args_size.constant -= reg_parm_stack_space;
 #endif
-#endif
 
   if (args_size.constant > current_function_outgoing_args_size)
     current_function_outgoing_args_size = args_size.constant;
@@ -3063,7 +2979,8 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
      evaluations to avoid this conflicting stack usage.  */
 
   needed = args_size.constant;
-#if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
+
+#ifndef OUTGOING_REG_PARM_STACK_SPACE
   /* Since we will be writing into the entire argument area, the
      map must be allocated for its entire size, not just the part that
      is the responsibility of the caller.  */
@@ -3212,17 +3129,14 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
 
          for (i = lower_bound; i < upper_bound; i++)
            if (stack_usage_map[i]
-#ifdef REG_PARM_STACK_SPACE
                /* Don't store things in the fixed argument area at this point;
                   it has already been saved.  */
-               && i > reg_parm_stack_space
-#endif
-               )
+               && i > reg_parm_stack_space)
              break;
 
          if (i != upper_bound)
            {
-             /* We need to make a save area.  See what mode we can make it.  */
+             /* We need to make a save area.  See what mode we can make it. */
              enum machine_mode save_mode
                = mode_for_size (argvec[argnum].size.constant * BITS_PER_UNIT,
                                 MODE_INT, 1);
@@ -3236,7 +3150,8 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
            }
 #endif
          emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
-                         argblock, GEN_INT (argvec[argnum].offset.constant));
+                         argblock, GEN_INT (argvec[argnum].offset.constant),
+                         reg_parm_stack_space);
 
 #ifdef ACCUMULATE_OUTGOING_ARGS
          /* Now mark the segment we just used.  */
@@ -3442,13 +3357,12 @@ target_for_arg (type, size, args_addr, offset)
    FNDECL is the declaration of the function we are calling.  */
 
 static void
-store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
+store_one_arg (arg, argblock, may_be_alloca, variable_size,
               reg_parm_stack_space)
      struct arg_data *arg;
      rtx argblock;
      int may_be_alloca;
      int variable_size;
-     tree fndecl;
      int reg_parm_stack_space;
 {
   register tree pval = arg->tree_value;
@@ -3491,12 +3405,9 @@ store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
 
       for (i = lower_bound; i < upper_bound; i++)
        if (stack_usage_map[i]
-#ifdef REG_PARM_STACK_SPACE
            /* Don't store things in the fixed argument area at this point;
               it has already been saved.  */
-           && i > reg_parm_stack_space
-#endif
-           )
+           && i > reg_parm_stack_space)
          break;
 
       if (i != upper_bound)
@@ -3596,15 +3507,13 @@ store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
 
   if (arg->value == arg->stack)
     {
-      /* If the value is already in the stack slot, we are done.  */
-      if (flag_check_memory_usage && GET_CODE (arg->stack) == MEM)
+      /* If the value is already in the stack slot, we are done moving
+        data.  */
+      if (current_function_check_memory_usage && GET_CODE (arg->stack) == MEM)
        {
-         if (arg->mode == BLKmode)
-           abort ();
-
          emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
                             XEXP (arg->stack, 0), ptr_mode, 
-                            GEN_INT (GET_MODE_SIZE (arg->mode)),
+                            ARGS_SIZE_RTX (arg->size),
                             TYPE_MODE (sizetype),
                             GEN_INT (MEMORY_USE_RW),
                             TYPE_MODE (integer_type_node));
@@ -3642,9 +3551,9 @@ store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
 
       /* This isn't already where we want it on the stack, so put it there.
         This can either be done with push or copy insns.  */
-      emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX,
-                     0, partial, reg, used - size,
-                     argblock, ARGS_SIZE_RTX (arg->offset));
+      emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX, 0,
+                     partial, reg, used - size, argblock,
+                     ARGS_SIZE_RTX (arg->offset), reg_parm_stack_space);
     }
   else
     {
@@ -3676,7 +3585,8 @@ store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
 
       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
                      TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
-                     reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
+                     reg, excess, argblock, ARGS_SIZE_RTX (arg->offset),
+                     reg_parm_stack_space);
     }