Skip to contentSkip to conversation

(PPC) Fix Alpha target floating point

PATCH In review Alexander Graf 2 participants 2 messages Jan 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 4/5 (PPC) Fix Alpha target floating point

This fixes the Alpha target for PowerPC hosts. It is merely a part of the original gcc4 patch posted by Michael Matz.

target-alpha/op_template.h renamed from target-alpha/op_template.h.mm +19 -0
@@ -28,7 +28,26 @@ void OPPROTO glue(op_reset_T, REG) (void
 
 void OPPROTO glue(op_reset_FT, REG) (void)
 {
+#ifdef HOST_PPC
+    /* We have a problem with HOST_PPC here:
+       We want this code:
+         glue(FT, REG) = 0;
+       unfortunately GCC4 notices that this stores (double)0.0 into
+       env->ft0 and emits that constant into the .rodata, and instructions
+       to load that zero from there.  But that construct can't be parsed by dyngen.
+       We could add -ffast-math for compiling op.c, that would just make it generate
+       two stores of zeros into both words of ft0.  But -ffast-math may have other
+       side-effects regarding the emulation.  We could use __builtin_memset,
+       which perhaps would be the sanest.  That relies on -O2 and our other options
+       to inline that memset, which currently it does, but who knows for how long.
+       So, we simply do that by hand, and a barely typesafe way :-/  */
+    union baeh { double d; unsigned int i[2];};
+    union baeh *p = (union baeh*)&(glue(FT, REG));
+    p->i[0] = 0;
+    p->i[1] = 0;
+#else
     glue(FT, REG) = 0;
+#endif
     RETURN();
 }
#1 lore raw
Quoted 2 lines · Alexander Graf

This fixes the Alpha target for PowerPC hosts. It is merely a part of the original gcc4 patch posted by Michael Matz.

Sparc host had the same problem with Alpha reset ops, I solved that by introducing a helper.