OSDN Git Service

Cast pointer operands to bzero, bcopy, and bcmp to (char *).
[pf3gnuchains/gcc-fork.git] / gcc / explow.c
index 86726c9..7f1e196 100644 (file)
@@ -1,5 +1,5 @@
 /* Subroutines for manipulating rtx's in semantically interesting ways.
-   Copyright (C) 1987, 1991 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1991, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -274,19 +274,17 @@ break_out_memory_refs (x)
   if (GET_CODE (x) == MEM
       || (CONSTANT_P (x) && CONSTANT_ADDRESS_P (x)
          && GET_MODE (x) != VOIDmode))
-    {
-      register rtx temp = force_reg (GET_MODE (x), x);
-      mark_reg_pointer (temp);
-      x = temp;
-    }
+    x = force_reg (GET_MODE (x), x);
   else if (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS
           || GET_CODE (x) == MULT)
     {
       register rtx op0 = break_out_memory_refs (XEXP (x, 0));
       register rtx op1 = break_out_memory_refs (XEXP (x, 1));
+
       if (op0 != XEXP (x, 0) || op1 != XEXP (x, 1))
        x = gen_rtx (GET_CODE (x), Pmode, op0, op1);
     }
+
   return x;
 }
 
@@ -338,91 +336,118 @@ memory_address (mode, x)
      enum machine_mode mode;
      register rtx x;
 {
-  register rtx oldx;
+  register rtx oldx = x;
 
   /* By passing constant addresses thru registers
      we get a chance to cse them.  */
   if (! cse_not_expected && CONSTANT_P (x) && CONSTANT_ADDRESS_P (x))
-    return force_reg (Pmode, x);
+    x = force_reg (Pmode, x);
 
   /* Accept a QUEUED that refers to a REG
      even though that isn't a valid address.
      On attempting to put this in an insn we will call protect_from_queue
      which will turn it into a REG, which is valid.  */
-  if (GET_CODE (x) == QUEUED
+  else if (GET_CODE (x) == QUEUED
       && GET_CODE (QUEUED_VAR (x)) == REG)
-    return x;
+    ;
 
   /* We get better cse by rejecting indirect addressing at this stage.
      Let the combiner create indirect addresses where appropriate.
      For now, generate the code so that the subexpressions useful to share
      are visible.  But not if cse won't be done!  */
-  oldx = x;
-  if (! cse_not_expected && GET_CODE (x) != REG)
-    x = break_out_memory_refs (x);
-
-  /* At this point, any valid address is accepted.  */
-  GO_IF_LEGITIMATE_ADDRESS (mode, x, win);
-
-  /* If it was valid before but breaking out memory refs invalidated it,
-     use it the old way.  */
-  if (memory_address_p (mode, oldx))
-    goto win2;
-
-  /* Perform machine-dependent transformations on X
-     in certain cases.  This is not necessary since the code
-     below can handle all possible cases, but machine-dependent
-     transformations can make better code.  */
-  LEGITIMIZE_ADDRESS (x, oldx, mode, win);
-
-  /* PLUS and MULT can appear in special ways
-     as the result of attempts to make an address usable for indexing.
-     Usually they are dealt with by calling force_operand, below.
-     But a sum containing constant terms is special
-     if removing them makes the sum a valid address:
-     then we generate that address in a register
-     and index off of it.  We do this because it often makes
-     shorter code, and because the addresses thus generated
-     in registers often become common subexpressions.  */
-  if (GET_CODE (x) == PLUS)
+  else
     {
-      rtx constant_term = const0_rtx;
-      rtx y = eliminate_constant_term (x, &constant_term);
-      if (constant_term == const0_rtx
-         || ! memory_address_p (mode, y))
-       return force_operand (x, NULL_RTX);
-
-      y = gen_rtx (PLUS, GET_MODE (x), copy_to_reg (y), constant_term);
-      if (! memory_address_p (mode, y))
-       return force_operand (x, NULL_RTX);
-      return y;
-    }
-  if (GET_CODE (x) == MULT || GET_CODE (x) == MINUS)
-    return force_operand (x, NULL_RTX);
+      if (! cse_not_expected && GET_CODE (x) != REG)
+       x = break_out_memory_refs (x);
+
+      /* At this point, any valid address is accepted.  */
+      GO_IF_LEGITIMATE_ADDRESS (mode, x, win);
+
+      /* If it was valid before but breaking out memory refs invalidated it,
+        use it the old way.  */
+      if (memory_address_p (mode, oldx))
+       goto win2;
+
+      /* Perform machine-dependent transformations on X
+        in certain cases.  This is not necessary since the code
+        below can handle all possible cases, but machine-dependent
+        transformations can make better code.  */
+      LEGITIMIZE_ADDRESS (x, oldx, mode, win);
+
+      /* PLUS and MULT can appear in special ways
+        as the result of attempts to make an address usable for indexing.
+        Usually they are dealt with by calling force_operand, below.
+        But a sum containing constant terms is special
+        if removing them makes the sum a valid address:
+        then we generate that address in a register
+        and index off of it.  We do this because it often makes
+        shorter code, and because the addresses thus generated
+        in registers often become common subexpressions.  */
+      if (GET_CODE (x) == PLUS)
+       {
+         rtx constant_term = const0_rtx;
+         rtx y = eliminate_constant_term (x, &constant_term);
+         if (constant_term == const0_rtx
+             || ! memory_address_p (mode, y))
+           x = force_operand (x, NULL_RTX);
+         else
+           {
+             y = gen_rtx (PLUS, GET_MODE (x), copy_to_reg (y), constant_term);
+             if (! memory_address_p (mode, y))
+               x = force_operand (x, NULL_RTX);
+             else
+               x = y;
+           }
+       }
 
-  /* If we have a register that's an invalid address,
-     it must be a hard reg of the wrong class.  Copy it to a pseudo.  */
-  if (GET_CODE (x) == REG)
-    return copy_to_reg (x);
-
-  /* Last resort: copy the value to a register, since
-     the register is a valid address.  */
-  return force_reg (Pmode, x);
-
- win2:
-  x = oldx;
- win:
-  if (flag_force_addr && ! cse_not_expected && GET_CODE (x) != REG
-      /* Don't copy an addr via a reg if it is one of our stack slots.  */
-      && ! (GET_CODE (x) == PLUS
-           && (XEXP (x, 0) == virtual_stack_vars_rtx
-               || XEXP (x, 0) == virtual_incoming_args_rtx)))
-    {
-      if (general_operand (x, Pmode))
-       return force_reg (Pmode, x);
+      if (GET_CODE (x) == MULT || GET_CODE (x) == MINUS)
+       x = force_operand (x, NULL_RTX);
+
+      /* If we have a register that's an invalid address,
+        it must be a hard reg of the wrong class.  Copy it to a pseudo.  */
+      else if (GET_CODE (x) == REG)
+       x = copy_to_reg (x);
+
+      /* Last resort: copy the value to a register, since
+        the register is a valid address.  */
       else
-       return force_operand (x, NULL_RTX);
+       x = force_reg (Pmode, x);
+
+      goto done;
+
+    win2:
+      x = oldx;
+    win:
+      if (flag_force_addr && ! cse_not_expected && GET_CODE (x) != REG
+         /* Don't copy an addr via a reg if it is one of our stack slots.  */
+         && ! (GET_CODE (x) == PLUS
+               && (XEXP (x, 0) == virtual_stack_vars_rtx
+                   || XEXP (x, 0) == virtual_incoming_args_rtx)))
+       {
+         if (general_operand (x, Pmode))
+           x = force_reg (Pmode, x);
+         else
+           x = force_operand (x, NULL_RTX);
+       }
     }
+
+ done:
+
+  /* If we didn't change the address, we are done.  Otherwise, mark
+     a reg as a pointer if we have REG or REG + CONST_INT.  */
+  if (oldx == x)
+    return x;
+  else if (GET_CODE (x) == REG)
+    mark_reg_pointer (x);
+  else if (GET_CODE (x) == PLUS
+          && GET_CODE (XEXP (x, 0)) == REG
+          && GET_CODE (XEXP (x, 1)) == CONST_INT)
+    mark_reg_pointer (XEXP (x, 0));
+
+  /* OLDX may have been the address on a temporary.  Update the address
+     to indicate that X is now used.  */
+  update_temp_slot_address (oldx, x);
+
   return x;
 }
 
@@ -608,6 +633,44 @@ copy_to_suggested_reg (x, target, mode)
   return temp;
 }
 \f
+/* Return the mode to use to store a scalar of TYPE and MODE.
+   PUNSIGNEDP points to the signedness of the type and may be adjusted
+   to show what signedness to use on extension operations.
+
+   FOR_CALL is non-zero if this call is promoting args for a call.  */
+
+enum machine_mode
+promote_mode (type, mode, punsignedp, for_call)
+     tree type;
+     enum machine_mode mode;
+     int *punsignedp;
+     int for_call;
+{
+  enum tree_code code = TREE_CODE (type);
+  int unsignedp = *punsignedp;
+
+#ifdef PROMOTE_FOR_CALL_ONLY
+  if (! for_call)
+    return mode;
+#endif
+
+  switch (code)
+    {
+#ifdef PROMOTE_MODE
+    case INTEGER_TYPE:   case ENUMERAL_TYPE:   case BOOLEAN_TYPE:
+    case CHAR_TYPE:      case REAL_TYPE:       case OFFSET_TYPE:
+      PROMOTE_MODE (mode, unsignedp, type);
+      break;
+#endif
+
+    case POINTER_TYPE:
+      break;
+    }
+
+  *punsignedp = unsignedp;
+  return mode;
+}
+\f
 /* Adjust the stack pointer by ADJUST (an rtx for a number of bytes).
    This pops when ADJUST is positive.  ADJUST need not be constant.  */
 
@@ -732,7 +795,7 @@ emit_stack_save (save_level, psave, after)
       if (HAVE_save_stack_nonlocal)
        {
          fcn = gen_save_stack_nonlocal;
-         mode = insn_operand_mode[CODE_FOR_save_stack_nonlocal][0];
+         mode = insn_operand_mode[(int) CODE_FOR_save_stack_nonlocal][0];
        }
       break;
 #endif
@@ -852,6 +915,15 @@ allocate_dynamic_stack_space (size, target, known_align)
      rtx target;
      int known_align;
 {
+  /* If we're asking for zero bytes, it doesn't matter what we point
+     to since we can't derefference it.  But return a reasonable
+     address anyway.  */
+  if (size == const0_rtx)
+    return virtual_stack_dynamic_rtx;
+
+  /* Otherwise, show we're calling alloca or equivalent.  */
+  current_function_calls_alloca = 1;
+
   /* Ensure the size is in the proper mode.  */
   if (GET_MODE (size) != VOIDmode && GET_MODE (size) != Pmode)
     size = convert_to_mode (Pmode, size, 1);
@@ -998,6 +1070,10 @@ allocate_dynamic_stack_space (size, target, known_align)
     emit_insn (gen_probe ());
 #endif
 
+  /* Record the new stack level for nonlocal gotos.  */
+  if (nonlocal_goto_handler_slot != 0)
+    emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
+
   return target;
 }
 \f