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]

Re: [patch] Improve stack checking on PowerPC


> Okay, but would you mind using the value "4" for the UNSPEC at the
> beginning of the list?  I would like to fill in the empty values at
> the beginning of the list and this instruction seems particularly
> appropriate.

OK, thanks, installed with this change.  And I also took this opportunity to 
clarify/complete the docs.


2009-12-14  Eric Botcazou  <ebotcazou@adacore.com>

	* doc/tm.texi (STACK_CHECK_PROTECT): Document alternate default.
	* doc/md.texi (check_stack): Clarify.
	(probe_stack): Likewise.
        * config/rs6000/rs6000.md (UNSPEC_PROBE_STACK): New constant.
        (probe_stack): New insn.


-- 
Eric Botcazou
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 155206)
+++ doc/tm.texi	(working copy)
@@ -3574,9 +3574,11 @@ default value of this macro is zero.
 @end defmac
 
 @defmac STACK_CHECK_PROTECT
-The number of bytes of stack needed to recover from a stack overflow,
-for languages where such a recovery is supported.  The default value of
-75 words should be adequate for most machines.
+The number of bytes of stack needed to recover from a stack overflow, for
+languages where such a recovery is supported.  The default value of 75 words
+with the @code{setjmp}/@code{longjmp}-based exception handling mechanism and
+8192 bytes with other exception handling mechanisms should be adequate for
+most machines.
 @end defmac
 
 The following macros are relevant only if neither STACK_CHECK_BUILTIN
Index: doc/md.texi
===================================================================
--- doc/md.texi	(revision 155206)
+++ doc/md.texi	(working copy)
@@ -5035,21 +5035,20 @@ operations in addition to updating the s
 
 @cindex @code{check_stack} instruction pattern
 @item @samp{check_stack}
-If stack checking cannot be done on your system by probing the stack with
-a load or store instruction (@pxref{Stack Checking}), define this pattern
-to perform the needed check and signal an error if the stack has overflowed.
-The single operand is the address in the stack furthest from the current
-stack pointer that you need to validate.  Normally, on machines where this
-pattern is needed, you would obtain the stack limit from a global or
-thread-specific variable or register.
+If stack checking (@pxref{Stack Checking}) cannot be done on your system by
+probing the stack, define this pattern to perform the needed check and signal
+an error if the stack has overflowed.  The single operand is the address in
+the stack farthest from the current stack pointer that you need to validate.
+Normally, on platforms where this pattern is needed, you would obtain the
+stack limit from a global or thread-specific variable or register.
 
 @cindex @code{probe_stack} instruction pattern
 @item @samp{probe_stack}
-If stack checking can be done on your system by probing the stack but doing
-it with a load or store instruction is not optimal (@pxref{Stack Checking}),
-define this pattern to do the probing differently and signal an error if
-the stack has overflowed.  The single operand is the memory location in the
-stack that needs to be probed.
+If stack checking (@pxref{Stack Checking}) can be done on your system by
+probing the stack but doing it with a ``store zero'' instruction is not valid
+or optimal, define this pattern to do the probing differently and signal an
+error if the stack has overflowed.  The single operand is the memory reference
+in the stack that needs to be probed.
 
 @cindex @code{nonlocal_goto} instruction pattern
 @item @samp{nonlocal_goto}
Index: config/rs6000/rs6000.md
===================================================================
--- config/rs6000/rs6000.md	(revision 155206)
+++ config/rs6000/rs6000.md	(working copy)
@@ -55,6 +55,7 @@ (define_constants
 
 (define_constants
   [(UNSPEC_FRSP			0)	; frsp for POWER machines
+   (UNSPEC_PROBE_STACK		4)	; probe stack memory reference
    (UNSPEC_TIE			5)	; tie stack contents and stack pointer
    (UNSPEC_TOCPTR		6)	; address of a word pointing to the TOC
    (UNSPEC_TOC			7)	; address of the TOC (more-or-less)
@@ -12549,6 +12550,13 @@ (define_insn "blockage"
   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
   ""
   "")
+
+(define_insn "probe_stack"
+  [(unspec [(match_operand 0 "memory_operand" "=m")] UNSPEC_PROBE_STACK)]
+  ""
+  "{st%U0%X0|stw%U0%X0} 0,%0"
+  [(set_attr "type" "store")
+   (set_attr "length" "4")])
 
 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
 ;; signed & unsigned, and one type of branch.

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