summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-09-30 09:42:30 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-09-30 09:42:30 +0200
commitcccca70149d585d03ea5613c672ceebf00ec36f7 (patch)
treec23dbb8931078f59bc7669f518b2c2afaded37c4
parentd3937f3b373ee9b1af09176d8a7d86eb6fcf790f (diff)
downloadgem5-cccca70149d585d03ea5613c672ceebf00ec36f7.tar.xz
x86: Add support routines to load and store 80-bit floats
The x87 FPU on x86 supports extended floating point. We currently handle all floating point on x86 as double and don't support 80-bit loads/stores. This changeset add a utility function to load and convert 80-bit floats to doubles (loadFloat80) and another function to store doubles as 80-bit floats (storeFloat80). Both functions use libfputils to do the conversion in software. The functions are currently not used, but are required to handle floating point in KVM and to properly support all x87 loads/stores.
-rw-r--r--src/arch/x86/utility.cc17
-rw-r--r--src/arch/x86/utility.hh16
2 files changed, 33 insertions, 0 deletions
diff --git a/src/arch/x86/utility.cc b/src/arch/x86/utility.cc
index 41f5aee0b..b50b99dfa 100644
--- a/src/arch/x86/utility.cc
+++ b/src/arch/x86/utility.cc
@@ -44,6 +44,7 @@
#include "arch/x86/utility.hh"
#include "arch/x86/x86_traits.hh"
#include "cpu/base.hh"
+#include "fputils/fp80.h"
#include "sim/system.hh"
namespace X86ISA {
@@ -351,4 +352,20 @@ genX87Tags(uint16_t ftw, uint8_t top, int8_t spm)
return ftw;
}
+double
+loadFloat80(const void *_mem)
+{
+ const fp80_t *fp80((const fp80_t *)_mem);
+
+ return fp80_cvtd(*fp80);
+}
+
+void
+storeFloat80(void *_mem, double value)
+{
+ fp80_t *fp80((fp80_t *)_mem);
+
+ *fp80 = fp80_cvfd(value);
+}
+
} // namespace X86_ISA
diff --git a/src/arch/x86/utility.hh b/src/arch/x86/utility.hh
index dcf61bddb..046b959db 100644
--- a/src/arch/x86/utility.hh
+++ b/src/arch/x86/utility.hh
@@ -187,6 +187,22 @@ namespace X86ISA
* @return New value of the FTW register.
*/
uint16_t genX87Tags(uint16_t ftw, uint8_t top, int8_t spm);
+
+ /**
+ * Load an 80-bit float from memory and convert it to double.
+ *
+ * @param mem Pointer to an 80-bit float.
+ * @return double representation of the 80-bit float.
+ */
+ double loadFloat80(const void *mem);
+
+ /**
+ * Convert and store a double as an 80-bit float.
+ *
+ * @param mem Pointer to destination for the 80-bit float.
+ * @param value Double precision float to store.
+ */
+ void storeFloat80(void *mem, double value);
}
#endif // __ARCH_X86_UTILITY_HH__