summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2014-11-11 15:18:01 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2014-11-19 16:29:58 +0100
commit914f87c78089150d1ae51340128e37a99040ab5d (patch)
tree6209135823f5f49f8d274bb3f51db9053215e9d3
parent6dcd275550347d878c1f7c8ee39b87d56c9af742 (diff)
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.
-rw-r--r--c/src/lib/libbsp/sparc/shared/start/start.S11
-rw-r--r--c/src/lib/libcpu/sparc/reg_win/window.S14
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 b7067b32bd..3e0e42e7df 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 535dc83105..9e4158e288 100644
--- a/c/src/lib/libcpu/sparc/reg_win/window.S
+++ b/c/src/lib/libcpu/sparc/reg_win/window.S
@@ -73,9 +73,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)
@@ -95,17 +95,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
@@ -116,7 +114,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.