[rtems commit] SPARC: window overflow optimization

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


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

Author:    Daniel Hellstrom <daniel at gaisler.com>
Date:      Tue May 27 11:15:46 2014 +0200

SPARC: window overflow optimization

I see no need for waiting the 3 instruction delay for wim to be
written in this case, since the STD after does not depend on WIM

---

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

diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
index eb8e3c4..b7067b3 100644
--- a/c/src/lib/libbsp/sparc/shared/start/start.S
+++ b/c/src/lib/libbsp/sparc/shared/start/start.S
@@ -42,6 +42,15 @@
    subcc %g1, 3, %g0; ! prepare for syscall 3 check
 
 /*
+ * Window Overflow optimized trap table entry
+ */
+#define WOTRAP(_vector, _handler)  \
+  sethi %hi(_handler), %l4; \
+  jmp   %l4+%lo(_handler); \
+    save; \
+  nop
+
+/*
  *  Software trap. Treat as BAD_TRAP for the time being...
  */
 
@@ -72,7 +81,7 @@ SYM(trap_table):
   BAD_TRAP;                                     ! 02 illegal instruction
   BAD_TRAP;                                     ! 03 privileged instruction
   BAD_TRAP;                                     ! 04 fp disabled
-  TRAP( 5, SYM(window_overflow_trap_handler) ); ! 05 window overflow
+  WOTRAP(5, SYM(window_overflow_trap_handler)); ! 05 window overflow
   TRAP( 6, SYM(window_underflow_trap_handler) );! 06 window underflow
   BAD_TRAP;                                     ! 07 memory address not aligned
   BAD_TRAP;                                     ! 08 fp exception
diff --git a/c/src/lib/libcpu/sparc/reg_win/window.S b/c/src/lib/libcpu/sparc/reg_win/window.S
index dffac6a..535dc83 100644
--- a/c/src/lib/libcpu/sparc/reg_win/window.S
+++ b/c/src/lib/libcpu/sparc/reg_win/window.S
@@ -29,9 +29,8 @@
          *
          *  On entry:
          *
-         *    l0 = psr (from trap table)
-         *    l1 = pc
-         *    l2 = npc
+         *    prev regwin l1 = pc
+         *    prev regwin l2 = npc
          */
 
         PUBLIC(window_overflow_trap_handler)
@@ -51,29 +50,23 @@ SYM(window_overflow_trap_handler):
          *        register will result in the local register set changing.
          */
 
-        mov  %wim, %l3                   ! l3 = WIM
-        mov  %g1, %l7                    ! save g1
-        srl  %l3, 1, %g1                 ! g1 = WIM >> 1
-        sll  %l3, SPARC_NUMBER_OF_REGISTER_WINDOWS-1 , %l4
-                                         ! l4 = WIM << (Number Windows - 1)
-        or   %l4, %g1, %g1               ! g1 = (WIM >> 1) |
-                                         !      (WIM << (Number Windows - 1))
-
-        save                             ! Get into window to be saved.
-        mov  %g1, %wim                   ! load new WIM
-        nop; nop; nop                    ! 3 slot delay
         std  %l0, [%sp + 0x00]           ! save local register set
         std  %l2, [%sp + 0x08]
+        mov  %wim, %l3
+        sll  %l3, SPARC_NUMBER_OF_REGISTER_WINDOWS-1 , %l2
+                                         ! l2  = WIM << (Number Windows - 1)
         std  %l4, [%sp + 0x10]
         std  %l6, [%sp + 0x18]
+        srl  %l3, 1, %l3                 ! l3  = WIM >> 1
+        wr   %l3, %l2, %wim              ! WIM = (WIM >> 1) ^
+                                         !       (WIM << (Number Windows - 1))
         std  %i0, [%sp + 0x20]           ! save input register set
         std  %i2, [%sp + 0x28]
         std  %i4, [%sp + 0x30]
         std  %i6, [%sp + 0x38]
         restore                          ! Go back to trap window.
-        mov  %l7, %g1                    ! restore g1
         jmp  %l1                         ! Re-execute save.
-        rett %l2
+         rett %l2
 
         /*
          *  Window underflow trap handler.



More information about the vc mailing list