about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/mpa-arch.h
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2013-03-26 19:28:50 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2013-03-26 19:28:50 +0530
commit6f2e90e78f151bab153c2b38492505ae2012db06 (patch)
tree03965f28878b90725ad89572ae61993bff4ebdfd /sysdeps/ieee754/dbl-64/mpa-arch.h
parentfce14d4e9c6e08ad8c825fe88d8cbdac5c739565 (diff)
downloadglibc-6f2e90e78f151bab153c2b38492505ae2012db06.tar.gz
glibc-6f2e90e78f151bab153c2b38492505ae2012db06.tar.xz
glibc-6f2e90e78f151bab153c2b38492505ae2012db06.zip
Make mantissa type of mp_no configurable
The mantissa of mp_no is intended to take only integral values.  This
is a relatively good choice for powerpc due to its 4 fpus, but not for
other architectures, which suffer due to this choice.  This change
makes the default mantissa a long integer and allows powerpc to
override it.  Additionally, some operations have been optimized for
integer manipulation, resulting in a significant improvement in
performance.
Diffstat (limited to 'sysdeps/ieee754/dbl-64/mpa-arch.h')
-rw-r--r--sysdeps/ieee754/dbl-64/mpa-arch.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/mpa-arch.h b/sysdeps/ieee754/dbl-64/mpa-arch.h
new file mode 100644
index 0000000000..7de9d51ae2
--- /dev/null
+++ b/sysdeps/ieee754/dbl-64/mpa-arch.h
@@ -0,0 +1,47 @@
+/* Overridable constants and operations.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+   This program 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.
+
+   This program 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 this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stdint.h>
+
+typedef long mantissa_t;
+typedef int64_t mantissa_store_t;
+
+#define TWOPOW(i) (1L << i)
+
+#define RADIX_EXP 24
+#define  RADIX TWOPOW (RADIX_EXP)		/* 2^24    */
+
+/* Divide D by RADIX and put the remainder in R.  D must be a non-negative
+   integral value.  */
+#define DIV_RADIX(d, r) \
+  ({									      \
+    r = d & (RADIX - 1);						      \
+    d >>= RADIX_EXP;							      \
+  })
+
+/* Put the integer component of a double X in R and retain the fraction in
+   X.  This is used in extracting mantissa digits for MP_NO by using the
+   integer portion of the current value of the number as the current mantissa
+   digit and then scaling by RADIX to get the next mantissa digit in the same
+   manner.  */
+#define INTEGER_OF(x, i) \
+  ({									      \
+    i = (mantissa_t) x;							      \
+    x -= i;								      \
+  })
+
+/* Align IN down to F.  The code assumes that F is a power of two.  */
+#define ALIGN_DOWN_TO(in, f) ((in) & -(f))