changeset 5d4ebc92d32e in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=5d4ebc92d32e
description:
ext: Update fputils to rev 6a47fd8358
This patch updates fputils to the latest revision (6a47fd8358) from
the upstream repository (github.com/andysan/fputils). Most notably,
this includes changes that export a limited set of 64-bit float
manipulation and avoids a warning about unused 64-bit floats in clang.
diffstat:
ext/fputils/Makefile.am | 8 ++-
ext/fputils/SConscript | 1 +
ext/fputils/configure.ac | 36 ++++++++++++++
ext/fputils/configure.in | 36 --------------
ext/fputils/fp64.c | 45 ++++++++++++++++++
ext/fputils/fp80.c | 56 ++++++++-------------
ext/fputils/fpbits.h | 17 ++++++
ext/fputils/include/fputils/fp64.h | 73 +++++++++++++++++++++++++++++
ext/fputils/include/fputils/fp80.h | 60 ++++++++++++++++--------
ext/fputils/include/fputils/fptypes.h | 86 +++++++++++++++++++++++++++++++++++
10 files changed, 327 insertions(+), 91 deletions(-)
diffs (truncated from 567 to 300 lines):
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/Makefile.am
--- a/ext/fputils/Makefile.am Thu Oct 16 05:49:57 2014 -0400
+++ b/ext/fputils/Makefile.am Thu Oct 16 05:49:58 2014 -0400
@@ -6,11 +6,17 @@
lib_LTLIBRARIES = libfputils.la
-include_HEADERS = include/fputils/fp80.h
+include_HEADERS = \
+ include/fputils/fp80.h \
+ include/fputils/fp64.h \
+ include/fputils/fptypes.h
libfputils_la_SOURCES = \
include/fputils/fp80.h \
+ include/fputils/fp64.h \
+ include/fputils/fptypes.h \
fpbits.h \
+ fp64.c \
fp80.c
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/SConscript
--- a/ext/fputils/SConscript Thu Oct 16 05:49:57 2014 -0400
+++ b/ext/fputils/SConscript Thu Oct 16 05:49:58 2014 -0400
@@ -40,6 +40,7 @@
fpenv.Append(CCFLAGS=['-std=c99'])
fpenv.Library('fputils', [
+ fpenv.SharedObject('fp64.c'),
fpenv.SharedObject('fp80.c'),
])
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/configure.ac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ext/fputils/configure.ac Thu Oct 16 05:49:58 2014 -0400
@@ -0,0 +1,36 @@
+AC_INIT(libfputils, 1.0, [email protected])
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([foreign -Wall])
+
+DX_PDF_FEATURE(OFF)
+DX_PS_FEATURE(OFF)
+DX_MAN_FEATURE(OFF)
+DX_INIT_DOXYGEN([libfputils])
+
+AC_REQUIRE_AUX_FILE([tap-driver.sh])
+
+AC_PROG_CC
+AC_PROG_CC_C99
+AC_PROG_LIBTOOL
+AC_PROG_AWK
+
+if test "x$ac_cv_prog_cc_c99" = "xno"; then
+ AC_MSG_ERROR([Could not enable C99 support in compiler.])
+fi
+
+AM_CFLAGS="-Wall -Werror"
+AM_CPPFLAGS="-I\$(abs_top_srcdir)/include"
+
+AC_SUBST(AM_CFLAGS)
+AC_SUBST(AM_CPPFLAGS)
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_CONFIG_FILES([ \
+ Doxyfile \
+ Makefile \
+ tests/Makefile \
+])
+AC_OUTPUT
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/configure.in
--- a/ext/fputils/configure.in Thu Oct 16 05:49:57 2014 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-AC_INIT(libfputils, 1.0, [email protected])
-
-AC_CONFIG_MACRO_DIR([m4])
-
-AM_INIT_AUTOMAKE([foreign -Wall -Werror])
-
-DX_PDF_FEATURE(OFF)
-DX_PS_FEATURE(OFF)
-DX_MAN_FEATURE(OFF)
-DX_INIT_DOXYGEN([libfputils])
-
-AC_REQUIRE_AUX_FILE([tap-driver.sh])
-
-AC_PROG_CC
-AC_PROG_CC_C99
-AC_PROG_LIBTOOL
-AC_PROG_AWK
-
-if test "x$ac_cv_prog_cc_c99" = "xno"; then
- AC_MSG_ERROR([Could not enable C99 support in compiler.])
-fi
-
-AM_CFLAGS="-Wall -Werror"
-AM_CPPFLAGS="-I\$(abs_top_srcdir)/include"
-
-AC_SUBST(AM_CFLAGS)
-AC_SUBST(AM_CPPFLAGS)
-
-AC_CONFIG_HEADERS([config.h])
-
-AC_CONFIG_FILES([ \
- Doxyfile \
- Makefile \
- tests/Makefile \
-])
-AC_OUTPUT
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/fp64.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ext/fputils/fp64.c Thu Oct 16 05:49:58 2014 -0400
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, Andreas Sandberg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <fputils/fp64.h>
+#include "fpbits.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include <stdio.h>
+
+const fp64_t fp64_pinf = BUILD_FP64(0, 0, FP64_EXP_SPECIAL);
+const fp64_t fp64_ninf = BUILD_FP64(1, 0, FP64_EXP_SPECIAL);
+const fp64_t fp64_qnan = BUILD_FP64(0, FP64_FRAC_QNAN, FP64_EXP_SPECIAL);
+const fp64_t fp64_nqnan = BUILD_FP64(1, FP64_FRAC_QNAN, FP64_EXP_SPECIAL);
+const fp64_t fp64_qnani = BUILD_FP64(1, FP64_FRAC_QNANI, FP64_EXP_SPECIAL);
+const fp64_t fp64_snan = BUILD_FP64(0, FP64_FRAC_SNAN, FP64_EXP_SPECIAL);
+const fp64_t fp64_nsnan = BUILD_FP64(1, FP64_FRAC_SNAN, FP64_EXP_SPECIAL);
+const fp64_t fp64_nan = BUILD_FP64(0, FP64_FRAC_QNAN, FP64_EXP_SPECIAL);
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/fp80.c
--- a/ext/fputils/fp80.c Thu Oct 16 05:49:57 2014 -0400
+++ b/ext/fputils/fp80.c Thu Oct 16 05:49:58 2014 -0400
@@ -28,6 +28,7 @@
*/
#include <fputils/fp80.h>
+#include <fputils/fp64.h>
#include "fpbits.h"
#include <assert.h>
@@ -35,39 +36,13 @@
#include <stdio.h>
-typedef union {
- uint64_t bits;
- double value;
-} fp64_t;
-
-const fp80_t fp80_pinf = BUILD_FP80(0, 0, FP80_EXP_SPECIAL);
-const fp80_t fp80_ninf = BUILD_FP80(1, 0, FP80_EXP_SPECIAL);
-const fp80_t fp80_qnan = BUILD_FP80(0, FP80_FRAC_QNAN, FP80_EXP_SPECIAL);
+const fp80_t fp80_pinf = BUILD_FP80(0, 0, FP80_EXP_SPECIAL);
+const fp80_t fp80_ninf = BUILD_FP80(1, 0, FP80_EXP_SPECIAL);
+const fp80_t fp80_qnan = BUILD_FP80(0, FP80_FRAC_QNAN, FP80_EXP_SPECIAL);
const fp80_t fp80_qnani = BUILD_FP80(1, FP80_FRAC_QNANI, FP80_EXP_SPECIAL);
-const fp80_t fp80_snan = BUILD_FP80(0, FP80_FRAC_SNAN, FP80_EXP_SPECIAL);
-const fp80_t fp80_nan = BUILD_FP80(0, FP80_FRAC_QNAN, FP80_EXP_SPECIAL);
-
-static const fp64_t fp64_pinf = BUILD_FP64(0, 0, FP64_EXP_SPECIAL);
-static const fp64_t fp64_ninf = BUILD_FP64(1, 0, FP64_EXP_SPECIAL);
-static const fp64_t fp64_qnan = BUILD_FP64(0, FP64_FRAC_QNAN,
- FP64_EXP_SPECIAL);
-static const fp64_t fp64_nqnan = BUILD_FP64(1, FP64_FRAC_QNAN,
- FP64_EXP_SPECIAL);
-static const fp64_t fp64_qnani = BUILD_FP64(1, FP64_FRAC_QNANI,
- FP64_EXP_SPECIAL);
-static const fp64_t fp64_snan = BUILD_FP64(0, FP64_FRAC_SNAN,
- FP64_EXP_SPECIAL);
-static const fp64_t fp64_nsnan = BUILD_FP64(1, FP64_FRAC_SNAN,
- FP64_EXP_SPECIAL);
-
-static double
-build_fp64(int sign, uint64_t frac, int exp)
-{
- const fp64_t f = BUILD_FP64(sign, frac, exp);
-
- return f.value;
-}
+const fp80_t fp80_snan = BUILD_FP80(0, FP80_FRAC_SNAN, FP80_EXP_SPECIAL);
+const fp80_t fp80_nan = BUILD_FP80(0, FP80_FRAC_QNAN, FP80_EXP_SPECIAL);
int
fp80_sgn(fp80_t fp80)
@@ -167,6 +142,12 @@
double
fp80_cvtd(fp80_t fp80)
{
+ return fp80_cvtfp64(fp80).value;
+}
+
+fp64_t
+fp80_cvtfp64(fp80_t fp80)
+{
const int sign = fp80.repr.se & FP80_SIGN_BIT;
if (!fp80_isspecial(fp80)) {
@@ -191,12 +172,12 @@
if (fp80_isinf(fp80)) {
return build_fp64(sign, 0, FP64_EXP_SPECIAL);
} else if (fp80_issnan(fp80)) {
- return fp80_sgn(fp80) > 0 ? fp64_snan.value : fp64_nsnan.value;
+ return fp80_sgn(fp80) > 0 ? fp64_snan : fp64_nsnan;
} else if (fp80_isqnani(fp80)) {
- return fp64_qnani.value;
+ return fp64_qnani;
} else {
assert(fp80_isqnan(fp80));
- return fp80_sgn(fp80) > 0 ? fp64_qnan.value : fp64_nqnan.value;
+ return fp80_sgn(fp80) > 0 ? fp64_qnan : fp64_nqnan;
}
}
}
@@ -205,6 +186,13 @@
fp80_cvfd(double value)
{
const fp64_t fp64 = { .value = value };
+
+ return fp80_cvffp64(fp64);
+}
+
+fp80_t
+fp80_cvffp64(fp64_t fp64)
+{
const uint64_t frac = FP64_FRAC(fp64);
const unsigned exp = FP64_EXP(fp64);
const int unb_exp = exp - FP64_EXP_BIAS;
diff -r 60b4471a8181 -r 5d4ebc92d32e ext/fputils/fpbits.h
--- a/ext/fputils/fpbits.h Thu Oct 16 05:49:57 2014 -0400
+++ b/ext/fputils/fpbits.h Thu Oct 16 05:49:58 2014 -0400
@@ -66,6 +66,14 @@
#define BUILD_FP64(sign, frac, exp) \
{ .bits = BUILD_IFP64(sign, frac, exp) }
+static inline fp64_t
+build_fp64(int sign, uint64_t frac, int exp)
+{
+ const fp64_t f = BUILD_FP64(sign, frac, exp);
+
+ return f;
+}
+
#define BUILD_FP80_SE(sign, exp) \
((sign) ? FP80_SIGN_BIT : 0) | \
((exp) & FP80_EXP_MASK)
@@ -80,6 +88,14 @@
.repr.fi = BUILD_FP80_FI(frac, exp) \
}
+static inline fp80_t
+build_fp80(int sign, uint64_t frac, int exp)
+{
+ const fp80_t f = BUILD_FP80(sign, frac, exp);
+
+ return f;
+}
+
#define FP80_FRAC(fp80) \
(fp80.repr.fi & FP80_FRAC_MASK)
@@ -92,4 +108,5 @@
#define FP64_EXP(fp80) \
((fp64.bits & FP64_EXP_MASK) >> FP64_EXP_SHIFT)
+
#endif
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev