From 394753cd92422f79630db1f296cac5bcf797e8fc Mon Sep 17 00:00:00 2001
From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>
Date: Thu, 13 Nov 2008 00:15:08 +0000
Subject: [PATCH] No need to restore r8-r14 on return from int if no context
 switch

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1213 42af7a65-404d-4744-a932-0658087f49c3
---
 arch/sh/src/sh1/sh1_vector.S | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/sh/src/sh1/sh1_vector.S b/arch/sh/src/sh1/sh1_vector.S
index 3e6a32029c..9e7ef50752 100644
--- a/arch/sh/src/sh1/sh1_vector.S
+++ b/arch/sh/src/sh1/sh1_vector.S
@@ -345,7 +345,7 @@ _up_vector:
 
         mov.l   .Ldoirq, r0
         jsr     @r0
-        mov     r15, r14
+        nop
 
 	/* Recover the user stack point */
 
@@ -355,7 +355,7 @@ _up_vector:
 
         mov.l   .Ldoirq, r0
         jsr     @r0
-        mov     r15, r14
+        nop
 #endif
 	/* On return, R0 holds the address of the base of the XCPTCONTEXT
 	 * structure to use for the return -- may not be the same as the
@@ -368,17 +368,28 @@ _up_vector:
 	bf	.Lcontextswitch
 	mov	r0, r15
 
-	/* Restore registers from the stack. */
+	/* Restore registers from the stack. NOTE: We coudl improve interrupt
+         * performance by skipping the restore of r8-r14.  These will not
+         * be modified by the called C code
+         */
 
-	mov.l	@r15+, r8	/* 0-8: r8-r14, pr, and gbr */
+#if 1
+	/* Skip over static registers -- these will not be modified by the
+	 * called C code (r8-r14)
+         */
+
+	add	#(7*4), r15	/* 0-6: Skip over r8-r14 */
+#else
+	mov.l	@r15+, r8	/* 0-6: r8-r14 */
 	mov.l	@r15+, r9
 	mov.l	@r15+, r10
 	mov.l	@r15+, r11
 	mov.l	@r15+, r12
 	mov.l	@r15+, r13
 	mov.l	@r15+, r14
+#endif
 
-	lds.l	@r15+, pr
+	lds.l	@r15+, pr	/* 7-8: pr and gbr */
 	ldc.l	@r15+, gbr
 
 	add	#4, r15		/* 9: Skip SP restore */
-- 
GitLab