]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[AArch64] Use builtins for fpcr/fpsr
authorWilco Dijkstra <wdijkstr@arm.com>
Fri, 9 Feb 2018 16:59:23 +0000 (16:59 +0000)
committerWilco Dijkstra <wdijkstr@arm.com>
Fri, 9 Feb 2018 16:59:23 +0000 (16:59 +0000)
Since GCC has support for accessing FPSR/FPCR, use them when possible
so that the asm instructions can be removed eventually.  Although GCC 5
supports the builtins, it has an optimization bug, so use them from GCC 6
onwards.

* sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing
FPCR/FPSR.

ChangeLog
sysdeps/aarch64/fpu/fpu_control.h

index 041f38ef6d416d049bf6381d1012de09e2e82047..385e8667b8d88e6329f29e9c69e652f286c49757 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-09  Wilco Dijkstra  <wdijkstr@arm.com>
+
+       * sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing
+       FPCR/FPSR.
+
 2018-02-09  Rical Jasan  <ricaljasan@pacific.net>
 
        * manual/creature.texi: Convert references to gcc.info to gcc.
index 570e3dca78adbbccdc21ca879c582e1e09196f2d..d0cc5afc9faf42249a45b7f6b24a374f944998fd 100644 (file)
 
 /* Macros for accessing the FPCR and FPSR.  */
 
-#define _FPU_GETCW(fpcr) \
+#if __GNUC_PREREQ (6,0)
+# define _FPU_GETCW(fpcr) (fpcr = __builtin_aarch64_get_fpcr ())
+# define _FPU_SETCW(fpcr) __builtin_aarch64_set_fpcr (fpcr)
+# define _FPU_GETFPSR(fpsr) (fpsr = __builtin_aarch64_get_fpsr ())
+# define _FPU_SETFPSR(fpsr) __builtin_aarch64_set_fpsr (fpsr)
+#else
+# define _FPU_GETCW(fpcr) \
   __asm__ __volatile__ ("mrs   %0, fpcr" : "=r" (fpcr))
 
-#define _FPU_SETCW(fpcr) \
+# define _FPU_SETCW(fpcr) \
   __asm__ __volatile__ ("msr   fpcr, %0" : : "r" (fpcr))
 
-#define _FPU_GETFPSR(fpsr) \
+# define _FPU_GETFPSR(fpsr) \
   __asm__ __volatile__ ("mrs   %0, fpsr" : "=r" (fpsr))
 
-#define _FPU_SETFPSR(fpsr) \
+# define _FPU_SETFPSR(fpsr) \
   __asm__ __volatile__ ("msr   fpsr, %0" : : "r" (fpsr))
+#endif
 
 /* Reserved bits should be preserved when modifying register
    contents. These two masks indicate which bits in each of FPCR and