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.
This commit is contained in:
Daniel Hellstrom
2014-11-11 15:18:01 +01:00
parent 6930aa7f19
commit 0d3b5d4742
2 changed files with 16 additions and 9 deletions

View File

@@ -50,6 +50,15 @@
save; \
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

View File

@@ -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.