Skip to contentSkip to conversation

Use float32/64 instead of float/double

PATCH New Aurelien Jarno 1 participant 1 message Feb 13, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Use float32/64 instead of float/double

The patch below uses the float32 and float64 types instead of the float and double types in the PPC code. This doesn't change anything when using softfloat-native as the types are the same, but that helps compiling the PPC target with softfloat.

It also defines a new union CPU_FloatU in addition to CPU_DoubleU, and use them instead of identical unions that are defined in numerous places.

---
 cpu-all.h                  |    5 +
 target-ppc/op.c            |   85 +++------
 target-ppc/op_helper.c     |  418 +++++++++++++++-----------------------------
 target-ppc/op_helper.h     |  104 ++++-------
 target-ppc/op_helper_mem.h |   18 +--
 target-ppc/op_mem.h        |   69 +++-----
 6 files changed, 241 insertions(+), 458 deletions(-)
cpu-all.h +5 -0
index 7a7e655..2a2b197 100644
@@ -116,6 +116,11 @@ static inline void tswap64s(uint64_t *s)
 #define bswaptls(s) bswap64s(s)
 #endif
 
+typedef union {
+    float32 f;
+    uint32_t l;
+} CPU_FloatU;
+
 /* NOTE: arm FPA is horrible as double 32 bit words are stored in big
    endian ! */
 typedef union {
target-ppc/op.c +27 -58

128 lines not on this page · raw message

target-ppc/op_helper.c +145 -273

784 lines not on this page · raw message

target-ppc/op_helper.h +37 -67

145 lines not on this page · raw message

target-ppc/op_helper_mem.h +6 -12
index 1d7b991..c8ef7ce 100644
@@ -316,15 +316,12 @@ void glue(do_POWER2_lfq, MEMSUFFIX) (void)
     FT1 = glue(ldfq, MEMSUFFIX)((uint32_t)(T0 + 4));
 }
 
-static always_inline double glue(ldfqr, MEMSUFFIX) (target_ulong EA)
+static always_inline float64 glue(ldfqr, MEMSUFFIX) (target_ulong EA)
 {
-    union {
-        double d;
-        uint64_t u;
-    } u;
+    CPU_DoubleU u;
 
     u.d = glue(ldfq, MEMSUFFIX)(EA);
-    u.u = bswap64(u.u);
+    u.ll = bswap64(u.ll);
 
     return u.d;
 }
@@ -341,15 +338,12 @@ void glue(do_POWER2_stfq, MEMSUFFIX) (void)
     glue(stfq, MEMSUFFIX)((uint32_t)(T0 + 4), FT1);
 }
 
-static always_inline void glue(stfqr, MEMSUFFIX) (target_ulong EA, double d)
+static always_inline void glue(stfqr, MEMSUFFIX) (target_ulong EA, float64 d)
 {
-    union {
-        double d;
-        uint64_t u;
-    } u;
+    CPU_DoubleU u;
 
     u.d = d;
-    u.u = bswap64(u.u);
+    u.ll = bswap64(u.ll);
     glue(stfq, MEMSUFFIX)(EA, u.d);
 }
 
target-ppc/op_mem.h +21 -48

128 lines not on this page · raw message

Signature · 7 lines
1.5.3.8

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net