[rtems commit] SPARC: optimize window underflow trap

Daniel Hellstrom danielh at rtems.org
Tue Dec 2 13:04:27 UTC 2014


Module:    rtems
Branch:    master
Commit:    0d3b5d47429effb350448d9e9123a67db722109f
Changeset: http://git.rtems.org/rtems/commit/?id=0d3b5d47429effb350448d9e9123a67db722109f

Author:    Daniel Hellstrom <daniel at gaisler.com>
Date:      Tue Nov 11 15:18:01 2014 +0100

SPARC: optimize window underflow trap

Save five instructions on underflow handling.

By using an optimized trap entry we can move instructions from
the window underflow function into the trap entry vector. By
setting WIM=0 and using RESTORE it is possible to move the
new WIM register content from the trapped window into the
to-be-restored register window. It is then possible to avoid
the WIM write delay.

---

 c/src/lib/libbsp/sparc/shared/start/start.S | 11 ++++++++++-
 c/src/lib/libcpu/sparc/reg_win/window.S     | 14 ++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
index b7067b3..3e0e42e 100644
--- a/c/src/lib/libbsp/sparc/shared/start/start.S
+++ b/c/src/lib/libbsp/sparc/shared/start/start.S
@@ -51,6 +51,15 @@
   nop
 
 /*
+ * Window Underflow optimized trap table entry
+ */
+#define WUTRAP(_vector, _handler)  \
+  mov   %wim, %l3 ; \
+  sethi %hi(_handler), %l4 ; \
+  jmp   %l4+%lo(_handler); \
+   mov  %g0, %wim ! WIM = 0, so that we can restore regardless of WIM
+
+/*
  *  Software trap. Treat as BAD_TRAP for the time being...
  */
 
@@ -82,7 +91,7 @@ SYM(trap_table):
   BAD_TRAP;                                     ! 03 privileged instruction
   BAD_TRAP;                                     ! 04 fp disabled
   WOTRAP(5, SYM(window_overflow_trap_handler)); ! 05 window overflow
-  TRAP( 6, SYM(window_underflow_trap_handler) );! 06 window underflow
+  WUTRAP(6, SYM(window_underflow_trap_handler));! 06 window underflow
   BAD_TRAP;                                     ! 07 memory address not aligned
   BAD_TRAP;                                     ! 08 fp exception
   BAD_TRAP;                                     ! 09 data access exception
diff --git a/c/src/lib/libcpu/sparc/reg_win/window.S b/c/src/lib/libcpu/sparc/reg_win/window.S
index a7d6910..06a7056 100644
--- a/c/src/lib/libcpu/sparc/reg_win/window.S
+++ b/c/src/lib/libcpu/sparc/reg_win/window.S
@@ -74,9 +74,9 @@ SYM(window_overflow_trap_handler):
          *
          *  On entry:
          *
-         *    l0 = psr (from trap table)
          *    l1 = pc
          *    l2 = npc
+         *    l3 = wim (from trap table)
          */
 
         PUBLIC(window_underflow_trap_handler)
@@ -96,17 +96,15 @@ SYM(window_underflow_trap_handler):
          *        register will result in the local register set changing.
          */
 
-        mov  %wim, %l3                  ! Calculate new WIM
+        ! In WIM 3 write instruction delay. since WIM<=0 from trap entry
         sll  %l3, 1, %l4                ! l4 = WIM << 1
         srl  %l3, SPARC_NUMBER_OF_REGISTER_WINDOWS-1, %l5
-                                        ! l5 = WIM >> (Number Windows-1)
-        or   %l5, %l4, %l5              ! l5 = (WIM << 1) |
+        or   %l5, %l4, %i5              ! %i5= (WIM << 1) |
                                         !      (WIM >> (Number Windows-1))
-        mov  %l5, %wim                  ! load the new WIM
-        nop; nop; nop
         restore                         ! Two restores to get into the
-        restore                         ! window to restore
+        restore %o5, %g0, %l7           ! window to restore. Carry along new WIM
         ldd  [%sp + 0x00], %l0          ! First the local register set
+        mov   %l7, %wim                 ! load the new WIM
         ldd  [%sp + 0x08], %l2
         ldd  [%sp + 0x10], %l4
         ldd  [%sp + 0x18], %l6
@@ -117,7 +115,7 @@ SYM(window_underflow_trap_handler):
         save                            ! Get back to the trap window.
         save
         jmp  %l1                        ! Re-execute restore.
-        rett  %l2
+         rett  %l2
 
         /*
          *  Flush All Windows trap handler.




More information about the vc mailing list