about summary refs log tree commit diff
path: root/sysdeps/powerpc/fpu/s_float_bitwise.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2011-09-07 22:10:26 -0400
committerUlrich Drepper <drepper@gmail.com>2011-09-07 22:10:26 -0400
commit77a2a8b4a19f0ad8d34e821a07da15d415f8f263 (patch)
tree1e6ca46c2bb0fa92e145abdb2b90a94952d62029 /sysdeps/powerpc/fpu/s_float_bitwise.h
parent24f579d86e13131beb3f4823e944cc447633a2c1 (diff)
downloadglibc-77a2a8b4a19f0ad8d34e821a07da15d415f8f263.tar.gz
glibc-77a2a8b4a19f0ad8d34e821a07da15d415f8f263.tar.xz
glibc-77a2a8b4a19f0ad8d34e821a07da15d415f8f263.zip
Trigonometric optimizations for POWER
Diffstat (limited to 'sysdeps/powerpc/fpu/s_float_bitwise.h')
-rw-r--r--sysdeps/powerpc/fpu/s_float_bitwise.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/sysdeps/powerpc/fpu/s_float_bitwise.h b/sysdeps/powerpc/fpu/s_float_bitwise.h
new file mode 100644
index 0000000000..c8b1d7a07e
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_float_bitwise.h
@@ -0,0 +1,112 @@
+/* Bitwise manipulation over float. Function prototypes.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _FLOAT_BITWISE_
+#define _FLOAT_BITWISE_ 1
+
+#include "math_private.h"
+
+/* Returns (int)(num & 0x7FFFFFF0 == value) */
+static inline
+int __float_and_test28 (float num, float value)
+{
+  float ret;
+#ifdef _ARCH_PWR7
+  vector int mask = (vector int) {
+    0x7ffffffe, 0x00000000, 0x00000000, 0x0000000
+  };
+  __asm__ (
+  /* the 'f' constrain is use on mask because we just need
+   * to compare floats, not full vector */
+    "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask)
+  );
+#else
+  int32_t inum;
+  GET_FLOAT_WORD(inum, num);
+  inum = (inum & 0x7ffffff0);
+  SET_FLOAT_WORD(ret, inum);
+#endif
+  return (ret == value);
+}
+
+/* Returns (int)(num & 0x7FFFFF00 == value) */
+static inline
+int __float_and_test24 (float num, float value)
+{
+  float ret;
+#ifdef _ARCH_PWR7
+  vector int mask = (vector int) {
+    0x7fffffe0, 0x00000000, 0x00000000, 0x0000000
+  };
+  __asm__ (
+    "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask)
+  );
+#else
+  int32_t inum;
+  GET_FLOAT_WORD(inum, num);
+  inum = (inum & 0x7fffff00);
+  SET_FLOAT_WORD(ret, inum);
+#endif
+  return (ret == value);
+}
+
+/* Returns (float)(num & 0x7F800000) */
+static inline
+float __float_and8 (float num)
+{
+  float ret;
+#ifdef _ARCH_PWR7
+  vector int mask = (vector int) {
+    0x7ff00000, 0x00000000, 0x00000000, 0x00000000 
+  };
+  __asm__ (
+    "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask)
+  );
+#else
+  int32_t inum;
+  GET_FLOAT_WORD(inum, num);
+  inum = (inum & 0x7f800000);
+  SET_FLOAT_WORD(ret, inum);
+#endif
+  return ret;
+}
+
+/* Returns ((int32_t)(num & 0x7F800000) >> 23) */
+static inline
+int32_t __float_get_exp (float num)
+{
+  int32_t inum;
+#ifdef _ARCH_PWR7
+  float ret;
+  vector int mask = (vector int) {
+    0x7ff00000, 0x00000000, 0x00000000, 0x00000000
+  };
+  __asm__ (
+    "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask)
+  );
+  GET_FLOAT_WORD(inum, ret);
+#else
+  GET_FLOAT_WORD(inum, num);
+  inum = inum & 0x7f800000;
+#endif
+  return inum >> 23;
+}
+
+#endif /* s_float_bitwise.h */