This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[MIPS 9/30]


Various routines thought they needed to call compute_frame_size
if reload_completed.  That shouldn't be necessary (any more).
We need to compute the final frame layout during reload to verify
that the elimination offsets are final.

None of the remaining callers make use of the return value, so the
function might as well not return anything.  Also, it seems odd to force
every caller to compute "get_frame_size ()"; the function might as well
compute it itself.  (This probably made more sense when the code
first written.)

Finally, the patch makes compute_frame_size static and renames it to
mips_compute_frame_info.  The new name emphasises that this is a
port-local function and that we're computing the whole of the
mips_frame_info structure.

Richard


gcc/
	* config/mips/mips-protos.h (compute_frame_size): Delete.
	* config/mips/mips.h: Update comments.
	* config/mips/mips.c (mips_frame_info): Remove initialized.
	(compute_frame_size): Rename to...
	(mips_compute_frame_info): ...this and make static.  Remove the
	SIZE argument and return no value.  Remove the setting of initialized.
	Update rest of file accordingly.
	(mips_set_return_address): Don't call compute_frame_size.
	(mips_can_use_return_insn): Don't check df_regs_ever_live_p (31).
	Don't call compute_frame_size.

Index: gcc/config/mips/mips-protos.h
===================================================================
--- gcc/config/mips/mips-protos.h	2007-10-18 11:07:06.000000000 +0100
+++ gcc/config/mips/mips-protos.h	2007-10-18 11:07:07.000000000 +0100
@@ -256,7 +256,6 @@ extern void mips_finish_declare_object (
 extern bool mips_small_data_pattern_p (rtx);
 extern rtx mips_rewrite_small_data (rtx);
 extern bool mips_frame_pointer_required (void);
-extern HOST_WIDE_INT compute_frame_size (HOST_WIDE_INT);
 extern HOST_WIDE_INT mips_initial_elimination_offset (int, int);
 extern rtx mips_return_addr (int, rtx);
 extern enum mips_loadgp_style mips_current_loadgp_style (void);
Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h	2007-10-18 11:07:06.000000000 +0100
+++ gcc/config/mips/mips.h	2007-10-18 11:07:07.000000000 +0100
@@ -1881,7 +1881,7 @@ #define CANNOT_CHANGE_MODE_CLASS(FROM, T
 #define STACK_GROWS_DOWNWARD
 
 /* The offset of the first local variable from the beginning of the frame.
-   See compute_frame_size for details about the frame layout.  */
+   See mips_compute_frame_info for details about the frame layout.  */
 
 #define STARTING_FRAME_OFFSET						\
   (current_function_outgoing_args_size					\
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2007-10-18 11:07:06.000000000 +0100
+++ gcc/config/mips/mips.c	2007-10-18 11:07:07.000000000 +0100
@@ -297,9 +297,7 @@ static const char *const mips_fp_conditi
   MIPS_FP_CONDITIONS (STRINGIFY)
 };
 
-/* Structure to be filled in by compute_frame_size with register
-   save masks, and offsets for the current function.  */
-
+/* Information about a function's frame layout.  */
 struct mips_frame_info GTY(())
 {
   /* The size of the frame in bytes.  */
@@ -344,9 +342,6 @@ struct mips_frame_info GTY(())
 
   /* The offset of hard_frame_pointer_rtx from frame_pointer_rtx.  */
   HOST_WIDE_INT hard_frame_pointer_offset;
-
-  /* True if this structure has been initialized after reload.  */
-  bool initialized;
 };
 
 struct machine_function GTY(()) {
@@ -358,7 +353,7 @@ struct machine_function GTY(()) {
      This area is allocated by the callee at the very top of the frame.  */
   int varargs_size;
 
-  /* Current frame information, calculated by compute_frame_size.  */
+  /* Current frame information, calculated by mips_compute_frame_info.  */
   struct mips_frame_info frame;
 
   /* The register to use as the global pointer within this function.  */
@@ -7871,8 +7866,7 @@ mips_save_reg_p (unsigned int regno)
   return false;
 }
 
-/* Return the bytes needed to compute the frame pointer from the current
-   stack pointer.  SIZE is the size (in bytes) of the local variables.
+/* Populate the current function's mips_frame_info structure.
 
    MIPS stack frames look like:
 
@@ -7933,15 +7927,16 @@ mips_save_reg_p (unsigned int regno)
    They decrease stack_pointer_rtx but leave frame_pointer_rtx and
    hard_frame_pointer_rtx unchanged.  */
 
-HOST_WIDE_INT
-compute_frame_size (HOST_WIDE_INT size)
+static void
+mips_compute_frame_info (void)
 {
   struct mips_frame_info *frame;
-  HOST_WIDE_INT offset;
+  HOST_WIDE_INT offset, size;
   unsigned int regno, i;
 
   frame = &cfun->machine->frame;
   memset (frame, 0, sizeof (*frame));
+  size = get_frame_size ();
 
   cfun->machine->global_pointer = mips_global_pointer ();
 
@@ -8045,9 +8040,6 @@ compute_frame_size (HOST_WIDE_INT size)
      instructions for local variables and incoming arguments.  */
   if (TARGET_MIPS16)
     frame->hard_frame_pointer_offset = frame->args_size;
-
-  frame->initialized = reload_completed;
-  return frame->total_size;
 }
 
 /* Return the style of GP load sequence that is being used for the
@@ -8084,7 +8076,7 @@ mips_frame_pointer_required (void)
      without using a second temporary register.  */
   if (TARGET_MIPS16)
     {
-      compute_frame_size (get_frame_size ());
+      mips_compute_frame_info ();
       if (!SMALL_OPERAND (cfun->machine->frame.total_size))
 	return true;
     }
@@ -8101,7 +8093,7 @@ mips_initial_elimination_offset (int fro
 {
   HOST_WIDE_INT offset;
 
-  compute_frame_size (get_frame_size ());
+  mips_compute_frame_info ();
 
   /* Set OFFSET to the offset from the soft frame pointer, which is also
      the offset from the end-of-prologue stack pointer.  */
@@ -8156,7 +8148,6 @@ mips_set_return_address (rtx address, rt
 {
   rtx slot_address;
 
-  compute_frame_size (get_frame_size ());
   gcc_assert ((cfun->machine->frame.mask >> 31) & 1);
   slot_address = mips_add_offset (scratch, stack_pointer_rtx,
 				  cfun->machine->frame.gp_sp_offset);
@@ -8230,7 +8221,7 @@ mips_for_each_saved_reg (HOST_WIDE_INT s
       }
 
   /* This loop must iterate over the same space as its companion in
-     compute_frame_size.  */
+     mips_compute_frame_info.  */
   offset = cfun->machine->frame.fp_sp_offset - sp_offset;
   fpr_mode = (TARGET_SINGLE_FLOAT ? SFmode : DFmode);
   for (regno = (FP_REG_LAST - MAX_FPRS_PER_FMT + 1);
@@ -8485,7 +8476,7 @@ mips_expand_prologue (void)
   if (cfun->machine->global_pointer > 0)
     SET_REGNO (pic_offset_table_rtx, cfun->machine->global_pointer);
 
-  size = compute_frame_size (get_frame_size ());
+  size = cfun->machine->frame.total_size;
 
   /* Save the registers.  Allocate up to MIPS_MAX_FIRST_STACK_STEP
      bytes beforehand; this is enough to cover the register save area
@@ -8806,7 +8797,7 @@ mips_can_use_return_insn (void)
   if (! reload_completed)
     return 0;
 
-  if (df_regs_ever_live_p (31) || current_function_profile)
+  if (current_function_profile)
     return 0;
 
   /* In mips16 mode, a function that returns a floating point value
@@ -8815,10 +8806,7 @@ mips_can_use_return_insn (void)
   if (mips16_cfun_returns_in_fpr_p ())
     return 0;
 
-  if (cfun->machine->frame.initialized)
-    return cfun->machine->frame.total_size == 0;
-
-  return compute_frame_size (get_frame_size ()) == 0;
+  return cfun->machine->frame.total_size == 0;
 }
 
 /* Implement HARD_REGNO_NREGS.  The size of FP registers is controlled


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]