diff options
author | Andrew Bennett <andrew.bennett@imgtec.com> | 2015-08-24 22:06:29 +0100 |
---|---|---|
committer | Matthew Fortune <matthew.fortune@imgtec.com> | 2015-09-08 16:52:43 +0100 |
commit | 7498d7676dc9ffb38fcb39635bae7c195740d6f7 (patch) | |
tree | 777b1522f456dde55596ed3388229f57eb6a9dfe /sysdeps/mips/tls-macros.h | |
parent | 697ed91ca901f8e2ce3ba2b7cf69cdb18c8b37ad (diff) | |
download | glibc-7498d7676dc9ffb38fcb39635bae7c195740d6f7.zip glibc-7498d7676dc9ffb38fcb39635bae7c195740d6f7.tar.gz glibc-7498d7676dc9ffb38fcb39635bae7c195740d6f7.tar.bz2 |
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.
Diffstat (limited to 'sysdeps/mips/tls-macros.h')
-rw-r--r-- | sysdeps/mips/tls-macros.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sysdeps/mips/tls-macros.h b/sysdeps/mips/tls-macros.h index 3e87e42..a6fdfbc 100644 --- a/sysdeps/mips/tls-macros.h +++ b/sysdeps/mips/tls-macros.h @@ -2,6 +2,7 @@ #include <sys/cdefs.h> #include <sys/asm.h> +#include <sysdep.h> #define __STRING2(X) __STRING(X) #define ADDU __STRING2(PTR_ADDU) @@ -38,6 +39,14 @@ # define UNLOAD_GP #endif +# if __mips_isa_rev >= 2 +# define TLS_RDHWR "rdhwr\t%0,$29" +# else +# define TLS_RDHWR \ + ".set push\n\t.set mips32r2\n\t" \ + "rdhwr\t%0,$29\n\t.set pop" +#endif + #ifndef __mips16 # define TLS_GD(x) \ ({ void *__result, *__tmp; \ @@ -60,8 +69,7 @@ __result; }) # define TLS_IE(x) \ ({ void *__result, *__tmp; \ - asm (".set push\n\t.set mips32r2\n\t" \ - "rdhwr\t%0,$29\n\t.set pop" \ + asm (TLS_RDHWR \ : "=v" (__result)); \ asm (LOAD_GP LW " $3,%%gottprel(" #x ")($28)\n\t" \ ADDU " %0,%0,$3" \ @@ -71,8 +79,7 @@ __result; }) # define TLS_LE(x) \ ({ void *__result; \ - asm (".set push\n\t.set mips32r2\n\t" \ - "rdhwr\t%0,$29\n\t.set pop" \ + asm (TLS_RDHWR \ : "=v" (__result)); \ asm ("lui $3,%%tprel_hi(" #x ")\n\t" \ "addiu $3,$3,%%tprel_lo(" #x ")\n\t" \ |