From 7498d7676dc9ffb38fcb39635bae7c195740d6f7 Mon Sep 17 00:00:00 2001 From: Andrew Bennett Date: Mon, 24 Aug 2015 22:06:29 +0100 Subject: MIPS: Only use .set mips* assembler directives when necessary There are a few .set mips* assembler directives used in the MIPS specific sysdep code that force an instruction to be assembled for a specific ISA. The reason for these is to allow an instruction to be encoded when it might not be supported in the current ISA (when the code is run the Linux kernel will trap and emulate any unsupported instructions). Unfortunately forcing a specific ISA means that when assembling for a newer ISA, where the instruction has a different encoding, the wrong encoding will be used. * sysdeps/mips/bits/atomic.h [_MIPS_SIM == _ABIO32] (MIPS_PUSH_MIPS2): Only use .set mips2 if the current ISA is below mips2. * sysdeps/mips/sys/tas.h [_MIPS_SIM == _ABIO32] (_test_and_set): Likewise. * sysdeps/mips/nptl/tls.h (READ_THREAD_POINTER): Only use .set mips32r2 if the current ISA is below mips32r2. * sysdeps/mips/tls-macros.h (TLS_RDHWR): New define. (TLS_IE): Updated to use the TLD_RDHWR macro. (TLS_LE): Likewise. * sysdeps/unix/mips/sysdep.h (__mips_isa_rev): Moved out of #ifdef __ASSEMBLER__ condition. --- sysdeps/mips/nptl/tls.h | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'sysdeps/mips/nptl') diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index ef1145779d..e69c3970df 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -25,6 +25,8 @@ # include # include # include +/* Get system call information. */ +# include /* Type for the dtv. */ typedef union dtv @@ -42,29 +44,37 @@ typedef union dtv # define READ_THREAD_POINTER() (__builtin_thread_pointer ()) #else /* Note: rd must be $v1 to be ABI-conformant. */ -# define READ_THREAD_POINTER() \ - ({ void *__result; \ - asm volatile (".set\tpush\n\t.set\tmips32r2\n\t" \ - "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \ - __result; }) +# if __mips_isa_rev >= 2 +# define READ_THREAD_POINTER() \ + ({ void *__result; \ + asm volatile ("rdhwr\t%0, $29" : "=v" (__result)); \ + __result; }) +# else +# define READ_THREAD_POINTER() \ + ({ void *__result; \ + asm volatile (".set\tpush\n\t.set\tmips32r2\n\t" \ + "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \ + __result; }) +# endif #endif #else /* __ASSEMBLER__ */ # include -# define READ_THREAD_POINTER(rd) \ - .set push; \ - .set mips32r2; \ - rdhwr rd, $29; \ - .set pop +# if __mips_isa_rev >= 2 +# define READ_THREAD_POINTER(rd) rdhwr rd, $29 +# else +# define READ_THREAD_POINTER(rd) \ + .set push; \ + .set mips32r2; \ + rdhwr rd, $29; \ + .set pop +# endif #endif /* __ASSEMBLER__ */ #ifndef __ASSEMBLER__ -/* Get system call information. */ -# include - /* The TP points to the start of the thread blocks. */ # define TLS_DTV_AT_TP 1 # define TLS_TCB_AT_TP 0 -- cgit 1.4.1