
From: Paul Mundt <lethal@Linux-SH.ORG>

This provides a port of checkstack for sh64 for the simple frames
allocated as an immediate with a single instruction.

Stack frame creation on sh64 happens in a couple of different ways,
when the frame size is less than 511 bytes an addi or addi.l is
typically used, generally along the lines of something like:

	addi{,.l}	r15, -IMM_FRAME_SIZE, r15

For larger frames, this ends up getting split up into a
movi/sub pair:

	movi	IMM_FRAME_SIZE, rX
	sub	r15, rX, r15

We currently don't handle the split pair case, as basically
any register can be used, and there is no easy way to determine
what happens without scanning the prologue multiple times and
using some sort of register cache (we already do something
similar for the sh64 stack unwinder, but it would be preferable
not to do this in perl..).

This does have limited usefulness in that we are not easily able
to check for huge frames without manual inspection, but this is
still useful enough in the general case to be worth doing for
the addi/addi.l case as long as people are aware of this caveat.

It may be worth revisiting at a later point to try and catch the
larger users though.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/scripts/checkstack.pl |    7 +++++++
 1 files changed, 7 insertions(+)

diff -puN scripts/checkstack.pl~sh64-initial-checkstack-port scripts/checkstack.pl
--- 25/scripts/checkstack.pl~sh64-initial-checkstack-port	2005-03-07 20:41:26.000000000 -0800
+++ 25-akpm/scripts/checkstack.pl	2005-03-07 20:41:26.000000000 -0800
@@ -9,6 +9,7 @@
 #	Mips port by Juan Quintela <quintela@mandrakesoft.com>
 #	IA64 port via Andreas Dilger
 #	Arm port by Holger Schurig
+#	sh64 port by Paul Mundt
 #	Random bits by Matt Mackall <mpm@selenic.com>
 #	M68k port by Geert Uytterhoeven and Andreas Schwab
 #
@@ -64,6 +65,12 @@ my (@stack, $re, $x, $xs);
 	} elsif ($arch =~ /^s390x?$/) {
 		#   11160:       a7 fb ff 60             aghi   %r15,-160
 		$re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+	} elsif ($arch =~ /^sh64$/) {
+		#XXX: we only check for the immediate case presently,
+		#     though we will want to check for the movi/sub
+		#     pair for larger users. -- PFM.
+		#a00048e0:       d4fc40f0        addi.l  r15,-240,r15
+		$re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
 	} else {
 		print("wrong or unknown architecture\n");
 		exit
_
