]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/powerpc/fpu_control.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / powerpc / fpu_control.h
index 07ccc849d99d292d8283b1c2e72e365dda158469..8f40b1ae798efca3093c6e24dd1c49f7380e88fe 100644 (file)
@@ -1,5 +1,5 @@
 /* FPU control word definitions.  PowerPC version.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #ifndef _FPU_CONTROL_H
 #define _FPU_CONTROL_H
@@ -65,35 +65,37 @@ extern fpu_control_t __fpu_control;
 typedef unsigned int fpu_control_t;
 
 /* Macros for accessing the hardware control word.  */
-# define __FPU_MFFS()                                          \
-  ({register double __fr;                                      \
-    __asm__ ("mffs %0" : "=f" (__fr));                         \
-    __fr;                                                      \
-  })
-
 # define _FPU_GETCW(cw)                                                \
   ({union { double __d; unsigned long long __ll; } __u;                \
-    __u.__d = __FPU_MFFS();                                    \
+    __asm__ __volatile__("mffs %0" : "=f" (__u.__d));          \
     (cw) = (fpu_control_t) __u.__ll;                           \
     (fpu_control_t) __u.__ll;                                  \
   })
 
-#ifdef _ARCH_PWR9
-# define __FPU_MFFSL()                                         \
-  ({register double __fr;                                      \
-    __asm__ ("mffsl %0" : "=f" (__fr));                                \
-    __fr;                                                      \
+# define _FPU_GET_RC_ISA300()                                          \
+  ({union { double __d; unsigned long long __ll; } __u;                        \
+    __asm__ __volatile__(                                              \
+      ".machine push; .machine \"power9\"; mffsl %0; .machine pop"     \
+      : "=f" (__u.__d));                                               \
+    (fpu_control_t) (__u.__ll & _FPU_MASK_RC);                         \
   })
-#else
-# define __FPU_MFFSL() __FPU_MFFS()
-#endif
-    
-# define _FPU_GET_RC()                                         \
-  ({union { double __d; unsigned long long __ll; } __u;                \
-    __u.__d = __FPU_MFFSL();                                   \
-    __u.__ll &= _FPU_MASK_RC;                                  \
-    (fpu_control_t) __u.__ll;                                  \
+
+# ifdef _ARCH_PWR9
+#  define _FPU_GET_RC() _FPU_GET_RC_ISA300()
+# elif defined __BUILTIN_CPU_SUPPORTS__
+#  define _FPU_GET_RC()                                                        \
+  ({fpu_control_t __rc;                                                        \
+    __rc = __glibc_likely (__builtin_cpu_supports ("arch_3_00"))       \
+      ? _FPU_GET_RC_ISA300 ()                                          \
+      : _FPU_GETCW (__rc) & _FPU_MASK_RC;                              \
+    __rc;                                                              \
+  })
+# else
+#  define _FPU_GET_RC()                                                \
+  ({fpu_control_t __rc = _FPU_GETCW (__rc) & _FPU_MASK_RC;     \
+    __rc;                                                      \
   })
+# endif
 
 # define _FPU_SETCW(cw)                                                \
   { union { double __d; unsigned long long __ll; } __u;                \
@@ -101,7 +103,7 @@ typedef unsigned int fpu_control_t;
     __u.__ll = 0xfff80000LL << 32; /* This is a QNaN.  */      \
     __u.__ll |= (cw) & 0xffffffffLL;                           \
     __fr = __u.__d;                                            \
-    __asm__ ("mtfsf 255,%0" : : "f" (__fr));                   \
+    __asm__ __volatile__("mtfsf 255,%0" : : "f" (__fr));       \
   }
 
 /* Default control word set at startup.  */