]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add 'missing' primop Iop_ReinterpF32asI32 and code generation support
authorJulian Seward <jseward@acm.org>
Tue, 9 Jan 2007 15:20:07 +0000 (15:20 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 9 Jan 2007 15:20:07 +0000 (15:20 +0000)
for it on x86 hosts.

git-svn-id: svn://svn.valgrind.org/vex/trunk@1721

VEX/priv/host-x86/isel.c
VEX/priv/ir/irdefs.c
VEX/pub/libvex_ir.h

index 2c339dbb6e8709010f445326299f23f386f91b7e..94a1f5d559f1545b74f7c8f657637f0476dad880 100644 (file)
@@ -1143,6 +1143,29 @@ static HReg iselIntExpr_R_wrk ( ISelEnv* env, IRExpr* e )
             return dst;
          }
 
+         /* ReinterpF32asI32(e) */
+         /* Given an IEEE754 single, produce an I32 with the same bit
+            pattern.  Keep stack 8-aligned even though only using 4
+            bytes. */
+         case Iop_ReinterpF32asI32: {
+            HReg rf   = iselFltExpr(env, e->Iex.Unop.arg);
+            HReg dst  = newVRegI(env);
+            X86AMode* zero_esp = X86AMode_IR(0, hregX86_ESP());
+            /* paranoia */
+            set_FPU_rounding_default(env);
+            /* subl $8, %esp */
+            sub_from_esp(env, 8);
+            /* gstF %rf, 0(%esp) */
+            addInstr(env,
+                     X86Instr_FpLdSt(False/*store*/, 4, rf, zero_esp));
+            /* movl 0(%esp), %dst */
+            addInstr(env, 
+                     X86Instr_Alu32R(Xalu_MOV, X86RMI_Mem(zero_esp), dst));
+            /* addl $8, %esp */
+            add_to_esp(env, 8);
+            return dst;
+         }
+
          case Iop_16to8:
          case Iop_32to8:
          case Iop_32to16:
index eb12305224e057e42d2459ab98f639aae1a1bc1b..a6462ba0d49a45d4080106144b7b16a8dfa8d47d 100644 (file)
@@ -294,6 +294,7 @@ void ppIROp ( IROp op )
 
       case Iop_ReinterpF64asI64: vex_printf("ReinterpF64asI64"); return;
       case Iop_ReinterpI64asF64: vex_printf("ReinterpI64asF64"); return;
+      case Iop_ReinterpF32asI32: vex_printf("ReinterpF32asI32"); return;
       case Iop_ReinterpI32asF32: vex_printf("ReinterpI32asF32"); return;
 
       case Iop_I32UtoFx4: vex_printf("Iop_I32UtoFx4"); return;
@@ -1655,6 +1656,7 @@ void typeOfPrimop ( IROp op,
       case Iop_ReinterpI64asF64: UNARY(Ity_I64, Ity_F64);
       case Iop_ReinterpF64asI64: UNARY(Ity_F64, Ity_I64);
       case Iop_ReinterpI32asF32: UNARY(Ity_I32, Ity_F32);
+      case Iop_ReinterpF32asI32: UNARY(Ity_F32, Ity_I32);
 
       case Iop_AtanF64: case Iop_Yl2xF64:  case Iop_Yl2xp1F64: 
       case Iop_ScaleF64: case Iop_PRemF64: case Iop_PRem1F64:
index 314322171d73cf3d1f529e7c20d5d2a9ffceb8d2..436df5264a8bbd2384aa13644c6555d6c60152e8 100644 (file)
@@ -590,7 +590,7 @@ typedef
       /* Reinterpretation.  Take an F64 and produce an I64 with 
          the same bit pattern, or vice versa. */
       Iop_ReinterpF64asI64, Iop_ReinterpI64asF64,
-                            Iop_ReinterpI32asF32,
+      Iop_ReinterpF32asI32, Iop_ReinterpI32asF32,
 
       /* --- guest x86/amd64 specifics, not mandated by 754. --- */