Commit cb85a2f3 by Richard Henderson Committed by Richard Henderson

sparc.h (MACHINE_STATE_SAVE, [...]): Rewrite to not be so gross, and to properly function with PIC.

* sparc.h (MACHINE_STATE_SAVE, MACHINE_STATE_RESTORE): Rewrite
to not be so gross, and to properly function with PIC.

From-SVN: r19352
parent 99b13ed3
Tue Apr 21 02:15:36 1998 Richard Henderson <rth@cygnus.com>
* sparc.h (MACHINE_STATE_SAVE, MACHINE_STATE_RESTORE): Rewrite
to not be so gross, and to properly function with PIC.
Mon Apr 20 20:44:25 1998 Jim Wilson <wilson@cygnus.com> Mon Apr 20 20:44:25 1998 Jim Wilson <wilson@cygnus.com>
* frame.c (heapsort): Rename to frame_heapsort. * frame.c (heapsort): Rename to frame_heapsort.
......
...@@ -1956,18 +1956,23 @@ while(0) ...@@ -1956,18 +1956,23 @@ while(0)
and hope that this is enough. */ and hope that this is enough. */
#define MACHINE_STATE_SAVE(ID) \ #define MACHINE_STATE_SAVE(ID) \
asm (" mov %g0,%l0");\ int ms_flags, ms_saveret; \
asm (" be,a LFLGNZ" ID);\ asm volatile( \
asm (" or %l0,4,%l0");\ "mov %%g0,%0\n\
asm ("LFLGNZ" ID ": bcs,a LFLGNC" ID);\ be,a LFLGNZ"ID"\n\
asm (" or %l0,1,%l0");\ or %0,4,%0\n\
asm ("LFLGNC" ID ": bvs,a LFLGNV" ID);\ LFLGNZ"ID":\n\
asm (" or %l0,2,%l0");\ bcs,a LFLGNC"ID"\n\
asm ("LFLGNV" ID ": bneg,a LFLGNN" ID);\ or %0,1,%0\n\
asm (" or %l0,8,%l0");\ LFLGNC"ID":\n\
asm ("LFLGNN" ID ": sethi %hi(LFLAGS" ID "),%l1");\ bvs,a LFLGNV"ID"\n\
asm (" st %l0,[%l1+%lo(LFLAGS" ID ")]"); \ or %0,2,%0\n\
asm (" st %g2,[%l1+%lo(LSAVRET" ID ")]"); LFLGNV"ID":\n\
bneg,a LFLGNN"ID"\n\
or %0,8,%0\n\
LFLGNN"ID":\n\
mov %%g2,%1" \
: "=r"(ms_flags), "=r"(ms_saveret));
/* On sparc MACHINE_STATE_RESTORE restores the psw register from memory. /* On sparc MACHINE_STATE_RESTORE restores the psw register from memory.
The psw register can be written in supervisor mode only, The psw register can be written in supervisor mode only,
...@@ -1978,73 +1983,64 @@ while(0) ...@@ -1978,73 +1983,64 @@ while(0)
instruction will be executed to abort the program. */ instruction will be executed to abort the program. */
#define MACHINE_STATE_RESTORE(ID) \ #define MACHINE_STATE_RESTORE(ID) \
asm (" sethi %hi(LFLGTAB" ID "),%l1");\ { extern char flgtab[] __asm__("LFLGTAB"ID); \
asm (" ld [%l1+%lo(LFLGTAB" ID "-(LFLGTAB" ID "-LFLAGS" ID "))],%l0");\ int scratch; \
asm (" ld [%l1+%lo(LFLGTAB" ID "-(LFLGTAB" ID "-LSAVRET" ID "))],%g2");\ asm volatile ( \
asm (" sll %l0,2,%l0");\ "jmpl %2+%1,%%g0\n\
asm (" add %l0,%l1,%l0");\ ! Do part of VC in the delay slot here, as it needs 3 insns.\n\
asm (" ld [%l0+%lo(LFLGTAB" ID ")],%l1");\ addcc 2,%3,%%g0\n\
asm (" jmp %l1");\ LFLGTAB" ID ":\n\
asm (" nop");\ ! 0\n\
asm (".data");\ ba LFLGRET"ID"\n\
asm (" .align 4");\ orcc 1,%%g0,%%g0\n\
asm ("LFLAGS" ID ":");\ ! C\n\
asm (" .word 0");\ ba LFLGRET"ID"\n\
asm ("LSAVRET" ID ":");\ addcc 2,%3,%%g0\n\
asm (" .word 0");\ ! V\n\
asm ("LFLGTAB" ID ": ");\ unimp\n\
asm (" .word LSFLG0" ID);\ nop\n\
asm (" .word LSFLGC" ID);\ ! VC\n\
asm (" .word LSFLGV" ID);\ ba LFLGRET"ID"\n\
asm (" .word LSFLGVC" ID);\ addxcc %4,%4,%0\n\
asm (" .word LSFLGZ" ID);\ ! Z\n\
asm (" .word LSFLGZC" ID);\ ba LFLGRET"ID"\n\
asm (" .word LSFLGZV" ID);\ subcc %%g0,%%g0,%%g0\n\
asm (" .word LSFLGZVC" ID);\ ! ZC\n\
asm (" .word LSFLGN" ID);\ ba LFLGRET"ID"\n\
asm (" .word LSFLGNC" ID);\ addcc 1,%3,%0\n\
asm (" .word LSFLGNV" ID);\ ! ZVC\n\
asm (" .word LSFLGNVC" ID);\ ba LFLGRET"ID"\n\
asm (" .word LSFLGNZ" ID);\ addcc %4,%4,%0\n\
asm (" .word LSFLGNZC" ID);\ ! N\n\
asm (" .word LSFLGNZV" ID);\ ba LFLGRET"ID"\n\
asm (" .word LSFLGNZVC" ID);\ orcc %%g0,-1,%%g0\n\
asm (".text");\ ! NC\n\
asm ("LSFLGVC" ID ": mov -1,%l0");\ ba LFLGRET"ID"\n\
asm (" addcc 2,%l0,%g0");\ addcc %%g0,%3,%%g0\n\
asm (" sethi %hi(0x80000000),%l0");\ ! NV\n\
asm (" mov %l0,%l1");\ unimp\n\
asm (" ba LFLGRET" ID);\ nop\n\
asm (" addxcc %l0,%l1,%l0");\ ! NVC\n\
asm ("LSFLGC" ID ": mov -1,%l0");\ unimp\n\
asm (" ba LFLGRET" ID);\ nop\n\
asm (" addcc 2,%l0,%g0");\ ! NZ\n\
asm ("LSFLGZC" ID ": mov -1,%l0");\ unimp\n\
asm (" ba LFLGRET" ID);\ nop\n\
asm (" addcc 1,%l0,%l0");\ ! NZC\n\
asm ("LSFLGZVC" ID ": sethi %hi(0x80000000),%l0");\ unimp\n\
asm (" mov %l0,%l1");\ nop\n\
asm (" ba LFLGRET" ID);\ ! NZV\n\
asm (" addcc %l0,%l1,%l0");\ unimp\n\
asm ("LSFLGZ" ID ": ba LFLGRET" ID);\ nop\n\
asm (" subcc %g0,%g0,%g0");\ ! NZVC\n\
asm ("LSFLGNC" ID ": add %g0,1,%l0");\ unimp\n\
asm (" ba LFLGRET" ID);\ nop\n\
asm (" subcc %g0,%l0,%g0");\ LFLGRET"ID":\n\
asm ("LSFLG0" ID ": ba LFLGRET" ID);\ mov %5,%%g2" \
asm (" orcc 1,%g0,%g0");\ : "=r"(scratch) \
asm ("LSFLGN" ID ": ba LFLGRET" ID);\ : "r"(ms_flags*8), "r"(flgtab), "r"(-1), \
asm (" orcc -1,%g0,%g0");\ "r"(0x80000000), "r"(ms_saveret) \
asm ("LSFLGV" ID ":");\ : "cc", "%g2"); }
asm ("LSFLGZV" ID ":");\
asm ("LSFLGNV" ID ":");\
asm ("LSFLGNVC" ID ":");\
asm ("LSFLGNZ" ID ":");\
asm ("LSFLGNZC" ID ":");\
asm ("LSFLGNZV" ID ":");\
asm ("LSFLGNZVC" ID ":");\
asm (" unimp");\
asm ("LFLGRET" ID ":");
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
the stack pointer does not matter. The value is tested only in the stack pointer does not matter. The value is tested only in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment