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]

[patch] Clean up EXIT_IGNORE_STACK.


Hi,

Attached is a patch to clean up EXIT_IGNORE STACK by defining the
default value in defaults.h.

Tested on i686-pc-linux-gnu and h8300-hms, which have different
EXIT_IGNORE_STACK, namely 1 and 0, respectively.  OK to apply?

Kazu Hirata

2003-12-08  Kazu Hirata  <kazu@cs.umass.edu>

	* flow.c (EXIT_IGNORE_STACK): Move to ...
	* defaults.h (EXIT_IGNORE_STACK): ... here.
	* dojump.c (clear_pending_stack_adjust): Don't use #ifdef
	EXIT_IGNORE_STACK.
	* function.c (expand_function_end): Likewise.
	* global.c (global_alloc): Likewise.
	* ra.c (init_ra): Likewise.
	* reload1.c (init_elim_table): Likewise.
	* reorg.c (fill_simple_delay_slots): Likewise.
	* resource.c (init_resource_info): Likewise.
	* doc/tm.texi (EXIT_IGNORE_STACK): Document that the default
	is 0.

Index: defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.119
diff -c -5 -r1.119 defaults.h
*** defaults.h	9 Dec 2003 03:34:06 -0000	1.119
--- defaults.h	9 Dec 2003 03:48:55 -0000
***************
*** 687,692 ****
--- 687,699 ----
  
  #ifndef LOCAL_REGNO
  #define LOCAL_REGNO(REGNO)  0
  #endif
  
+ /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
+    the stack pointer does not matter.  The value is tested only in
+    functions that have frame pointers.  */
+ #ifndef EXIT_IGNORE_STACK
+ #define EXIT_IGNORE_STACK 0
+ #endif
+ 
  #endif  /* ! GCC_DEFAULTS_H */
Index: dojump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dojump.c,v
retrieving revision 1.7
diff -c -5 -r1.7 dojump.c
*** dojump.c	5 Dec 2003 14:06:46 -0000	1.7
--- dojump.c	9 Dec 2003 03:48:56 -0000
***************
*** 55,75 ****
     frame pointer regardless of the value of flag_omit_frame_pointer.  */
  
  void
  clear_pending_stack_adjust (void)
  {
- #ifdef EXIT_IGNORE_STACK
    if (optimize > 0
        && (! flag_omit_frame_pointer || current_function_calls_alloca)
        && EXIT_IGNORE_STACK
        && ! (DECL_INLINE (current_function_decl) && ! flag_no_inline)
        && ! flag_inline_functions)
      {
        stack_pointer_delta -= pending_stack_adjust,
        pending_stack_adjust = 0;
      }
- #endif
  }
  
  /* Pop any previously-pushed arguments that have not been popped yet.  */
  
  void
--- 55,73 ----
Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.568
diff -c -5 -r1.568 flow.c
*** flow.c	9 Dec 2003 03:34:06 -0000	1.568
--- flow.c	9 Dec 2003 03:48:58 -0000
***************
*** 139,156 ****
  #include "timevar.h"
  
  #include "obstack.h"
  #include "splay-tree.h"
  
- /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
-    the stack pointer does not matter.  The value is tested only in
-    functions that have frame pointers.
-    No definition is equivalent to always zero.  */
- #ifndef EXIT_IGNORE_STACK
- #define EXIT_IGNORE_STACK 0
- #endif
- 
  #ifndef HAVE_epilogue
  #define HAVE_epilogue 0
  #endif
  #ifndef HAVE_prologue
  #define HAVE_prologue 0
--- 139,148 ----
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.474
diff -c -5 -r1.474 function.c
*** function.c	7 Dec 2003 12:51:56 -0000	1.474
--- function.c	9 Dec 2003 03:49:02 -0000
***************
*** 7026,7045 ****
      sjlj_emit_function_exit_after (get_last_insn ());
  
    /* If we had calls to alloca, and this machine needs
       an accurate stack pointer to exit the function,
       insert some code to save and restore the stack pointer.  */
! #ifdef EXIT_IGNORE_STACK
!   if (! EXIT_IGNORE_STACK)
! #endif
!     if (current_function_calls_alloca)
!       {
! 	rtx tem = 0;
  
! 	emit_stack_save (SAVE_FUNCTION, &tem, parm_birth_insn);
! 	emit_stack_restore (SAVE_FUNCTION, tem, NULL_RTX);
!       }
  
    /* If scalar return value was computed in a pseudo-reg, or was a named
       return value that got dumped to the stack, copy that to the hard
       return register.  */
    if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl)))
--- 7026,7043 ----
      sjlj_emit_function_exit_after (get_last_insn ());
  
    /* If we had calls to alloca, and this machine needs
       an accurate stack pointer to exit the function,
       insert some code to save and restore the stack pointer.  */
!   if (! EXIT_IGNORE_STACK
!       && current_function_calls_alloca)
!     {
!       rtx tem = 0;
  
!       emit_stack_save (SAVE_FUNCTION, &tem, parm_birth_insn);
!       emit_stack_restore (SAVE_FUNCTION, tem, NULL_RTX);
!     }
  
    /* If scalar return value was computed in a pseudo-reg, or was a named
       return value that got dumped to the stack, copy that to the hard
       return register.  */
    if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl)))
Index: global.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.95
diff -c -5 -r1.95 global.c
*** global.c	6 Dec 2003 12:22:31 -0000	1.95
--- global.c	9 Dec 2003 03:49:03 -0000
***************
*** 321,333 ****
  #ifdef ELIMINABLE_REGS
    static const struct {const int from, to; } eliminables[] = ELIMINABLE_REGS;
  #endif
    int need_fp
      = (! flag_omit_frame_pointer
- #ifdef EXIT_IGNORE_STACK
         || (current_function_calls_alloca && EXIT_IGNORE_STACK)
- #endif
         || FRAME_POINTER_REQUIRED);
  
    size_t i;
    rtx x;
  
--- 321,331 ----
Index: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.10
diff -c -5 -r1.10 ra.c
*** ra.c	14 Sep 2003 13:42:33 -0000	1.10
--- ra.c	9 Dec 2003 03:49:03 -0000
***************
*** 453,465 ****
    static const struct {const int from, to; } eliminables[] = ELIMINABLE_REGS;
    unsigned int j;
  #endif
    int need_fp
      = (! flag_omit_frame_pointer
- #ifdef EXIT_IGNORE_STACK
         || (current_function_calls_alloca && EXIT_IGNORE_STACK)
- #endif
         || FRAME_POINTER_REQUIRED);
  
    ra_colorize_init ();
  
    /* We can't ever use any of the fixed regs.  */
--- 453,463 ----
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.416
diff -c -5 -r1.416 reload1.c
*** reload1.c	9 Dec 2003 03:34:07 -0000	1.416
--- reload1.c	9 Dec 2003 03:49:07 -0000
***************
*** 3441,3459 ****
      reg_eliminate = xcalloc (sizeof (struct elim_table), NUM_ELIMINABLE_REGS);
  
    /* Does this function require a frame pointer?  */
  
    frame_pointer_needed = (! flag_omit_frame_pointer
- #ifdef EXIT_IGNORE_STACK
  			  /* ?? If EXIT_IGNORE_STACK is set, we will not save
  			     and restore sp for alloca.  So we can't eliminate
  			     the frame pointer in that case.  At some point,
  			     we should improve this by emitting the
  			     sp-adjusting insns for this case.  */
  			  || (current_function_calls_alloca
  			      && EXIT_IGNORE_STACK)
- #endif
  			  || FRAME_POINTER_REQUIRED);
  
    num_eliminable = 0;
  
  #ifdef ELIMINABLE_REGS
--- 3441,3457 ----
Index: reorg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reorg.c,v
retrieving revision 1.88
diff -c -5 -r1.88 reorg.c
*** reorg.c	21 Sep 2003 08:17:47 -0000	1.88
--- reorg.c	9 Dec 2003 03:49:09 -0000
***************
*** 2425,2438 ****
      {
        SET_HARD_REG_BIT (needed.regs, FRAME_POINTER_REGNUM);
  #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
        SET_HARD_REG_BIT (needed.regs, HARD_FRAME_POINTER_REGNUM);
  #endif
- #ifdef EXIT_IGNORE_STACK
        if (! EXIT_IGNORE_STACK
  	  || current_function_sp_is_unchanging)
- #endif
  	SET_HARD_REG_BIT (needed.regs, STACK_POINTER_REGNUM);
      }
    else
      SET_HARD_REG_BIT (needed.regs, STACK_POINTER_REGNUM);
  
--- 2425,2436 ----
Index: resource.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/resource.c,v
retrieving revision 1.64
diff -c -5 -r1.64 resource.c
*** resource.c	5 Dec 2003 11:53:56 -0000	1.64
--- resource.c	9 Dec 2003 03:49:10 -0000
***************
*** 1165,1178 ****
      {
        SET_HARD_REG_BIT (end_of_function_needs.regs, FRAME_POINTER_REGNUM);
  #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
        SET_HARD_REG_BIT (end_of_function_needs.regs, HARD_FRAME_POINTER_REGNUM);
  #endif
- #ifdef EXIT_IGNORE_STACK
        if (! EXIT_IGNORE_STACK
  	  || current_function_sp_is_unchanging)
- #endif
  	SET_HARD_REG_BIT (end_of_function_needs.regs, STACK_POINTER_REGNUM);
      }
    else
      SET_HARD_REG_BIT (end_of_function_needs.regs, STACK_POINTER_REGNUM);
  
--- 1165,1176 ----
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.269
diff -c -5 -r1.269 tm.texi
*** doc/tm.texi	8 Dec 2003 04:09:15 -0000	1.269
--- doc/tm.texi	9 Dec 2003 03:50:03 -0000
***************
*** 4181,4191 ****
  
  @defmac EXIT_IGNORE_STACK
  Define this macro as a C expression that is nonzero if the return
  instruction or the function epilogue ignores the value of the stack
  pointer; in other words, if it is safe to delete an instruction to
! adjust the stack pointer before a return from the function.
  
  Note that this macro's value is relevant only for functions for which
  frame pointers are maintained.  It is never safe to delete a final
  stack adjustment in a function that has no frame pointer, and the
  compiler knows this regardless of @code{EXIT_IGNORE_STACK}.
--- 4181,4192 ----
  
  @defmac EXIT_IGNORE_STACK
  Define this macro as a C expression that is nonzero if the return
  instruction or the function epilogue ignores the value of the stack
  pointer; in other words, if it is safe to delete an instruction to
! adjust the stack pointer before a return from the function.  The
! default is 0.
  
  Note that this macro's value is relevant only for functions for which
  frame pointers are maintained.  It is never safe to delete a final
  stack adjustment in a function that has no frame pointer, and the
  compiler knows this regardless of @code{EXIT_IGNORE_STACK}.


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