OSDN Git Service

* output.h (current_function_is_leaf,
authorwehle <wehle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Apr 1999 13:09:37 +0000 (13:09 +0000)
committerwehle <wehle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Apr 1999 13:09:37 +0000 (13:09 +0000)
current_function_uses_only_leaf_regs): Declare.
* function.c (current_function_is_leaf,
current_function_uses_only_leaf_regs): Define.
(init_function_start): Initialize current_function_is_leaf
and current_function_uses_only_leaf_regs.
* final.c (leaf_function): Don't define.
(final_start_function): Replace uses of leaf_function with
current_function_uses_only_leaf_regs.
* toplev.c (rest_of_compilation): Set current_function_is_leaf
prior to invoking local register allocation.
(rest_of_compilation): Replace uses of leaf_function with
current_function_uses_only_leaf_regs.
* dbxout.c (dbxout_symbol, dbxout_parms): Likewise.
* dwarf2out.c (add_location_or_const_vaule_attribute): Likewise.
* dwarfout.c (add_location_or_const_value_attribute): Likewise.
* sdbout.c (sdbout_symbol): Likewise.
* sparc.h (FUNCTION_PROLOGUE, FUNCTION_EPILOGUE): Likewise.
* sparc.c (eligible_for_epilogue_delay, output_return,
sparc_return_peephole_ok): Likewise.
* sparc.md (leaf_function attribute, untyped_return): Likewise.
* i386.c (ix86_compute_frame_size): Don't align the stack
for leaf functions which don't allocate any stack slots.
* tm.texi: Update documentation.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26538 138bc75d-0d04-0410-961f-82ee72b054a4

14 files changed:
gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.h
gcc/config/sparc/sparc.md
gcc/dbxout.c
gcc/dwarf2out.c
gcc/dwarfout.c
gcc/final.c
gcc/function.c
gcc/output.h
gcc/sdbout.c
gcc/tm.texi
gcc/toplev.c

index a092483..37cb3f0 100644 (file)
@@ -1,3 +1,30 @@
+Sun Apr 18 15:50:33 EDT 1999  John Wehle  (john@feith.com)
+
+       * output.h (current_function_is_leaf,
+       current_function_uses_only_leaf_regs): Declare.
+       * function.c (current_function_is_leaf,
+       current_function_uses_only_leaf_regs): Define.
+       (init_function_start): Initialize current_function_is_leaf
+       and current_function_uses_only_leaf_regs.
+       * final.c (leaf_function): Don't define.
+       (final_start_function): Replace uses of leaf_function with
+       current_function_uses_only_leaf_regs.
+       * toplev.c (rest_of_compilation): Set current_function_is_leaf
+       prior to invoking local register allocation.
+       (rest_of_compilation): Replace uses of leaf_function with
+       current_function_uses_only_leaf_regs.
+       * dbxout.c (dbxout_symbol, dbxout_parms): Likewise.
+       * dwarf2out.c (add_location_or_const_vaule_attribute): Likewise.
+       * dwarfout.c (add_location_or_const_value_attribute): Likewise.
+       * sdbout.c (sdbout_symbol): Likewise.
+       * sparc.h (FUNCTION_PROLOGUE, FUNCTION_EPILOGUE): Likewise.
+       * sparc.c (eligible_for_epilogue_delay, output_return,
+       sparc_return_peephole_ok): Likewise.
+       * sparc.md (leaf_function attribute, untyped_return): Likewise.
+       * i386.c (ix86_compute_frame_size): Don't align the stack
+       for leaf functions which don't allocate any stack slots.
+       * tm.texi: Update documentation.
+
 Sun Apr 18 02:15:09 PDT 1999 Jeff Law  (law@cygnus.com)
 
        * version.c: Bump for snapshot.
 Sun Apr 18 02:15:09 PDT 1999 Jeff Law  (law@cygnus.com)
 
        * version.c: Bump for snapshot.
@@ -1150,7 +1177,7 @@ Fri Apr  2 14:12:06 1999  John Wehle  (john@feith.com)
        * i386.md: Delete floating point compare, add, subtract,
        multiply, and divide patterns which allowed integer
        operands.
        * i386.md: Delete floating point compare, add, subtract,
        multiply, and divide patterns which allowed integer
        operands.
-       * i386.c (output_386_binary_op): Delete unused code.
+       * i386.c (output_387_binary_op): Delete unused code.
        (output_float_compare): Likewise.
 
 Fri Apr  2 11:53:37 1999  John Wehle  (john@feith.com)
        (output_float_compare): Likewise.
 
 Fri Apr  2 11:53:37 1999  John Wehle  (john@feith.com)
index dab0300..4faff7b 100644 (file)
@@ -1990,6 +1990,11 @@ ix86_compute_frame_size (size, nregs_on_stack)
     if (padding < (((offset + preferred_alignment - 1)
                    & -preferred_alignment) - offset))
       padding += preferred_alignment;
     if (padding < (((offset + preferred_alignment - 1)
                    & -preferred_alignment) - offset))
       padding += preferred_alignment;
+
+    /* Don't bother aligning the stack of a leaf function
+       which doesn't allocate any stack slots.  */
+    if (size == 0 && current_function_is_leaf)
+      padding = 0;
   }
 #endif
 
   }
 #endif
 
index 05affdd..4950242 100644 (file)
@@ -2230,7 +2230,7 @@ eligible_for_epilogue_delay (trial, slot)
   /* In the case of a true leaf function, anything can go into the delay slot.
      A delay slot only exists however if the frame size is zero, otherwise
      we will put an insn to adjust the stack after the return.  */
   /* In the case of a true leaf function, anything can go into the delay slot.
      A delay slot only exists however if the frame size is zero, otherwise
      we will put an insn to adjust the stack after the return.  */
-  if (leaf_function)
+  if (current_function_uses_only_leaf_regs)
     {
       if (leaf_return_peephole_ok ())
        return ((get_attr_in_uncond_branch_delay (trial)
     {
       if (leaf_return_peephole_ok ())
        return ((get_attr_in_uncond_branch_delay (trial)
@@ -4686,7 +4686,7 @@ output_return (operands)
       operands[0] = leaf_label;
       return "b%* %l0%(";
     }
       operands[0] = leaf_label;
       return "b%* %l0%(";
     }
-  else if (leaf_function)
+  else if (current_function_uses_only_leaf_regs)
     {
       /* No delay slot in a leaf function.  */
       if (delay)
     {
       /* No delay slot in a leaf function.  */
       if (delay)
@@ -7524,7 +7524,7 @@ sparc_return_peephole_ok (dest, src)
 {
   if (! TARGET_V9)
     return 0;
 {
   if (! TARGET_V9)
     return 0;
-  if (leaf_function)
+  if (current_function_uses_only_leaf_regs)
     return 0;
   if (GET_CODE (src) != CONST_INT
       && (GET_CODE (src) != REG || ! IN_OR_GLOBAL_P (src)))
     return 0;
   if (GET_CODE (src) != CONST_INT
       && (GET_CODE (src) != REG || ! IN_OR_GLOBAL_P (src)))
index b37b5e9..a220ce7 100644 (file)
@@ -1838,10 +1838,10 @@ do {                                                                    \
    to do a "save" insn.  The decision about whether or not
    to do this is made in regclass.c.  */
 
    to do a "save" insn.  The decision about whether or not
    to do this is made in regclass.c.  */
 
-extern int leaf_function;
 #define FUNCTION_PROLOGUE(FILE, SIZE) \
   (TARGET_FLAT ? sparc_flat_output_function_prologue (FILE, (int)SIZE) \
 #define FUNCTION_PROLOGUE(FILE, SIZE) \
   (TARGET_FLAT ? sparc_flat_output_function_prologue (FILE, (int)SIZE) \
-   : output_function_prologue (FILE, (int)SIZE, leaf_function))
+   : output_function_prologue (FILE, (int)SIZE, \
+                              current_function_uses_only_leaf_regs))
 \f
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.
 \f
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.
@@ -2216,7 +2216,8 @@ extern union tree_node *current_function_decl;
 
 #define FUNCTION_EPILOGUE(FILE, SIZE) \
   (TARGET_FLAT ? sparc_flat_output_function_epilogue (FILE, (int)SIZE) \
 
 #define FUNCTION_EPILOGUE(FILE, SIZE) \
   (TARGET_FLAT ? sparc_flat_output_function_epilogue (FILE, (int)SIZE) \
-   : output_function_epilogue (FILE, (int)SIZE, leaf_function))
+   : output_function_epilogue (FILE, (int)SIZE, \
+                              current_function_uses_only_leaf_regs))
 
 #define DELAY_SLOTS_FOR_EPILOGUE \
   (TARGET_FLAT ? sparc_flat_epilogue_delay_slots () : 1)
 
 #define DELAY_SLOTS_FOR_EPILOGUE \
   (TARGET_FLAT ? sparc_flat_epilogue_delay_slots () : 1)
index c1adf93..025992a 100644 (file)
   [(eq_attr "in_call_delay" "true") (nil) (nil)])
 
 (define_attr "leaf_function" "false,true"
   [(eq_attr "in_call_delay" "true") (nil) (nil)])
 
 (define_attr "leaf_function" "false,true"
-  (const (symbol_ref "leaf_function")))
+  (const (symbol_ref "current_function_uses_only_leaf_regs")))
 
 (define_attr "in_return_delay" "false,true"
   (if_then_else (and (and (and (eq_attr "type" "move,load,sload,store,binary,ialu")
 
 (define_attr "in_return_delay" "false,true"
   (if_then_else (and (and (and (eq_attr "type" "move,load,sload,store,binary,ialu")
 
   if (! TARGET_ARCH64)
     {
 
   if (! TARGET_ARCH64)
     {
-      rtx rtnreg = gen_rtx_REG (SImode, (leaf_function ? 15 : 31));
+      rtx rtnreg = gen_rtx_REG (SImode, (current_function_uses_only_leaf_regs
+                                        ? 15 : 31));
       rtx value = gen_reg_rtx (SImode);
 
       /* Fetch the instruction where we will return to and see if it's an unimp
       rtx value = gen_reg_rtx (SImode);
 
       /* Fetch the instruction where we will return to and see if it's an unimp
index 07122ec..bc15a4d 100644 (file)
@@ -1937,7 +1937,7 @@ dbxout_symbol (decl, local)
 
       DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
 
       DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-      if (leaf_function)
+      if (current_function_uses_only_leaf_regs)
        leaf_renumber_regs_insn (DECL_RTL (decl));
 #endif
 
        leaf_renumber_regs_insn (DECL_RTL (decl));
 #endif
 
@@ -2259,7 +2259,7 @@ dbxout_parms (parms)
          = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
        DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
          = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
        DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-       if (leaf_function)
+       if (current_function_uses_only_leaf_regs)
          {
            leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
            leaf_renumber_regs_insn (DECL_RTL (parms));
          {
            leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
            leaf_renumber_regs_insn (DECL_RTL (parms));
index 393dbc5..659b119 100644 (file)
@@ -7207,7 +7207,7 @@ add_location_or_const_value_attribute (die, decl)
 
   rtl = eliminate_regs (rtl, 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
 
   rtl = eliminate_regs (rtl, 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-  if (leaf_function)
+  if (current_function_uses_only_leaf_regs)
     leaf_renumber_regs_insn (rtl);
 #endif
 
     leaf_renumber_regs_insn (rtl);
 #endif
 
index 388c4a4..ac17f7f 100644 (file)
@@ -2421,7 +2421,7 @@ location_or_const_value_attribute (decl)
 
   rtl = eliminate_regs (rtl, 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
 
   rtl = eliminate_regs (rtl, 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-  if (leaf_function)
+  if (current_function_uses_only_leaf_regs)
     leaf_renumber_regs_insn (rtl);
 #endif
 
     leaf_renumber_regs_insn (rtl);
 #endif
 
index 3cd2e0c..bacc093 100644 (file)
@@ -131,11 +131,6 @@ Boston, MA 02111-1307, USA.  */
 #define JUMP_TABLES_IN_TEXT_SECTION 0
 #endif
 
 #define JUMP_TABLES_IN_TEXT_SECTION 0
 #endif
 
-/* Nonzero means this function is a leaf function, with no function calls. 
-   This variable exists to be examined in FUNCTION_PROLOGUE
-   and FUNCTION_EPILOGUE.  Always zero, unless set by some action.  */
-int leaf_function;
-
 /* Last insn processed by final_scan_insn.  */
 static rtx debug_insn = 0;
 
 /* Last insn processed by final_scan_insn.  */
 static rtx debug_insn = 0;
 
@@ -1634,7 +1629,7 @@ final_start_function (first, file, optimize)
        output_source_line (file, first);
 
 #ifdef LEAF_REG_REMAP
        output_source_line (file, first);
 
 #ifdef LEAF_REG_REMAP
-  if (leaf_function)
+  if (current_function_uses_only_leaf_regs)
     leaf_renumber_regs (first);
 #endif
 
     leaf_renumber_regs (first);
 #endif
 
index ac55f3a..3035786 100644 (file)
@@ -140,12 +140,25 @@ int current_function_has_nonlocal_goto;
 
 int current_function_contains_functions;
 
 
 int current_function_contains_functions;
 
+/* Nonzero if function being compiled doesn't contain any calls
+   (ignoring the prologue and epilogue).  This is set prior to
+   local register allocation and is valid for the remaining
+   compiler passes. */
+
+int current_function_is_leaf;
+
 /* Nonzero if function being compiled doesn't modify the stack pointer
    (ignoring the prologue and epilogue).  This is only valid after
    life_analysis has run. */
 
 int current_function_sp_is_unchanging;
 
 /* Nonzero if function being compiled doesn't modify the stack pointer
    (ignoring the prologue and epilogue).  This is only valid after
    life_analysis has run. */
 
 int current_function_sp_is_unchanging;
 
+/* Nonzero if the function being compiled is a leaf function which only
+   uses leaf registers.  This is valid after reload (specifically after
+   sched2) and is useful only if the port defines LEAF_REGISTERS.  */
+
+int current_function_uses_only_leaf_regs;
+
 /* Nonzero if the function being compiled issues a computed jump.  */
 
 int current_function_has_computed_jump;
 /* Nonzero if the function being compiled issues a computed jump.  */
 
 int current_function_has_computed_jump;
@@ -5897,7 +5910,9 @@ init_function_start (subr, filename, line)
   current_function_has_nonlocal_label = 0;
   current_function_has_nonlocal_goto = 0;
   current_function_contains_functions = 0;
   current_function_has_nonlocal_label = 0;
   current_function_has_nonlocal_goto = 0;
   current_function_contains_functions = 0;
+  current_function_is_leaf = 0;
   current_function_sp_is_unchanging = 0;
   current_function_sp_is_unchanging = 0;
+  current_function_uses_only_leaf_regs = 0;
   current_function_has_computed_jump = 0;
   current_function_is_thunk = 0;
 
   current_function_has_computed_jump = 0;
   current_function_is_thunk = 0;
 
index 7e1c28b..e1cf6d8 100644 (file)
@@ -383,12 +383,25 @@ extern int current_function_has_nonlocal_label;
 
 extern int current_function_contains_functions;
 
 
 extern int current_function_contains_functions;
 
+/* Nonzero if function being compiled doesn't contain any calls
+   (ignoring the prologue and epilogue).  This is set prior to
+   local register allocation and is valid for the remaining
+   compiler passes. */
+
+extern int current_function_is_leaf;
+
 /* Nonzero if function being compiled doesn't modify the stack pointer
    (ignoring the prologue and epilogue).  This is only valid after
    life_analysis has run. */
 
 extern int current_function_sp_is_unchanging;
 
 /* Nonzero if function being compiled doesn't modify the stack pointer
    (ignoring the prologue and epilogue).  This is only valid after
    life_analysis has run. */
 
 extern int current_function_sp_is_unchanging;
 
+/* Nonzero if the function being compiled is a leaf function which only
+   uses leaf registers.  This is valid after reload (specifically after
+   sched2) and is useful only if the port defines LEAF_REGISTERS.  */
+
+extern int current_function_uses_only_leaf_regs;
+
 /* Nonzero if the function being compiled issues a computed jump.  */
 
 extern int current_function_has_computed_jump;
 /* Nonzero if the function being compiled issues a computed jump.  */
 
 extern int current_function_has_computed_jump;
index 1f13899..0aebd83 100644 (file)
@@ -811,7 +811,7 @@ sdbout_symbol (decl, local)
 
       DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
 
       DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-      if (leaf_function)
+      if (current_function_uses_only_leaf_regs)
        leaf_renumber_regs_insn (DECL_RTL (decl));
 #endif
       value = DECL_RTL (decl);
        leaf_renumber_regs_insn (DECL_RTL (decl));
 #endif
       value = DECL_RTL (decl);
index 8e6797a..ac6e6be 100644 (file)
@@ -1642,12 +1642,17 @@ treatment of leaf functions, and registers need to be renumbered to do
 this.
 @end table
 
 this.
 @end table
 
-@findex leaf_function
+@findex current_function_is_leaf
+@findex current_function_uses_only_leaf_regs
 Normally, @code{FUNCTION_PROLOGUE} and @code{FUNCTION_EPILOGUE} must
 Normally, @code{FUNCTION_PROLOGUE} and @code{FUNCTION_EPILOGUE} must
-treat leaf functions specially.  It can test the C variable
-@code{leaf_function} which is nonzero for leaf functions.  (The variable
-@code{leaf_function} is defined only if @code{LEAF_REGISTERS} is
-defined.)
+treat leaf functions specially.  They can test the C variable
+@code{current_function_is_leaf} which is nonzero for leaf functions.
+@code{current_function_is_leaf} is set prior to local register allocation
+and is valid for the remaining compiler passes.  They can also test the C
+variable @code{current_function_uses_only_leaf_regs} which is nonzero for
+leaf functions which only use leaf registers.
+@code{current_function_uses_only_leaf_regs} is valid after reload and is
+only useful if @code{LEAF_REGISTERS} is defined.
 @c changed this to fix overfull.  ALSO:  why the "it" at the beginning
 @c of the next paragraph?!  --mew 2feb93
 
 @c changed this to fix overfull.  ALSO:  why the "it" at the beginning
 @c of the next paragraph?!  --mew 2feb93
 
@@ -3296,7 +3301,7 @@ argument lists of the function.  @xref{Stack Arguments}.
 
 Normally, it is necessary for the macros @code{FUNCTION_PROLOGUE} and
 @code{FUNCTION_EPILOGUE} to treat leaf functions specially.  The C
 
 Normally, it is necessary for the macros @code{FUNCTION_PROLOGUE} and
 @code{FUNCTION_EPILOGUE} to treat leaf functions specially.  The C
-variable @code{leaf_function} is nonzero for such a function.
+variable @code{current_function_is_leaf} is nonzero for such a function.
 
 @findex EXIT_IGNORE_STACK
 @item EXIT_IGNORE_STACK
 
 @findex EXIT_IGNORE_STACK
 @item EXIT_IGNORE_STACK
@@ -3346,8 +3351,8 @@ is wanted, the macro can refer to the variable
 a function that needs a frame pointer.
 
 Normally, @code{FUNCTION_PROLOGUE} and @code{FUNCTION_EPILOGUE} must
 a function that needs a frame pointer.
 
 Normally, @code{FUNCTION_PROLOGUE} and @code{FUNCTION_EPILOGUE} must
-treat leaf functions specially.  The C variable @code{leaf_function} is
-nonzero for such a function.  @xref{Leaf Functions}.
+treat leaf functions specially.  The C variable @code{current_function_is_leaf}
+is nonzero for such a function.  @xref{Leaf Functions}.
 
 On some machines, some functions pop their arguments on exit while
 others leave that for the caller to do.  For example, the 68020 when
 
 On some machines, some functions pop their arguments on exit while
 others leave that for the caller to do.  For example, the 68020 when
index 482b956..7b3c31c 100644 (file)
@@ -4089,6 +4089,11 @@ rest_of_compilation (decl)
        }
     }
 
        }
     }
 
+  /* Determine if the current function is a leaf before running reload
+     since this can impact optimizations done by the prologue and
+     epilogue thus changing register elimination offsets.  */
+  current_function_is_leaf = leaf_function_p ();
+
   /* Unless we did stupid register allocation,
      allocate pseudo-regs that are used only within 1 basic block. 
 
   /* Unless we did stupid register allocation,
      allocate pseudo-regs that are used only within 1 basic block. 
 
@@ -4235,9 +4240,8 @@ rest_of_compilation (decl)
     }
 
 #ifdef LEAF_REGISTERS
     }
 
 #ifdef LEAF_REGISTERS
-  leaf_function = 0;
   if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
   if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
-    leaf_function = 1;
+    current_function_uses_only_leaf_regs = 1;
 #endif
 
   /* One more attempt to remove jumps to .+1
 #endif
 
   /* One more attempt to remove jumps to .+1