]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add new IR primops: Iop_CmpNEZ8x8, Iop_CmpNEZ16x4, Iop_CmpNEZ32x2 and
authorJulian Seward <jseward@acm.org>
Thu, 13 Jan 2005 19:16:04 +0000 (19:16 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 13 Jan 2005 19:16:04 +0000 (19:16 +0000)
isel support for them in the x86 back end.  They are used for Memcheck
annotation of 64-bit SIMD code.

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

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

index 4972e1358a91d8165bcbc6f9890702d938fd5059..5255fc1cac339160492ce512442efa1bdfb3385b 100644 (file)
@@ -246,6 +246,21 @@ static inline UChar cmpgt8S ( Char xx, Char yy )
    return xx>yy ? 0xFF : 0;
 }
 
+static inline UInt cmpnez32 ( UInt xx )
+{
+   return xx==0 ? 0 : 0xFFFFFFFF;
+}
+
+static inline UShort cmpnez16 ( UShort xx )
+{
+   return xx==0 ? 0 : 0xFFFF;
+}
+
+static inline UChar cmpnez8 ( UChar xx )
+{
+   return xx==0 ? 0 : 0xFF;
+}
+
 static inline Short qnarrow32Sto16 ( UInt xx0 )
 {
    Int xx = (Int)xx0;
@@ -615,6 +630,38 @@ ULong h_generic_calc_CmpGT8Sx8 ( ULong xx, ULong yy )
           );
 }
 
+ULong h_generic_calc_CmpNEZ32x2 ( ULong xx )
+{
+   return mk32x2(
+             cmpnez32( sel32x2_1(xx) ),
+             cmpnez32( sel32x2_0(xx) )
+          );
+}
+
+ULong h_generic_calc_CmpNEZ16x4 ( ULong xx )
+{
+   return mk16x4(
+             cmpnez16( sel16x4_3(xx) ),
+             cmpnez16( sel16x4_2(xx) ),
+             cmpnez16( sel16x4_1(xx) ),
+             cmpnez16( sel16x4_0(xx) )
+          );
+}
+
+ULong h_generic_calc_CmpNEZ8x8 ( ULong xx )
+{
+   return mk8x8(
+             cmpnez8( sel8x8_7(xx) ),
+             cmpnez8( sel8x8_6(xx) ),
+             cmpnez8( sel8x8_5(xx) ),
+             cmpnez8( sel8x8_4(xx) ),
+             cmpnez8( sel8x8_3(xx) ),
+             cmpnez8( sel8x8_2(xx) ),
+             cmpnez8( sel8x8_1(xx) ),
+             cmpnez8( sel8x8_0(xx) )
+          );
+}
+
 /* ------------ Saturating narrowing ------------ */
 
 ULong h_generic_calc_QNarrow32Sx2 ( ULong aa, ULong bb )
index 6a9a6a13a949749b313d3e7ebd7c50b1344a8d89..8bbe6a030367540ac87f60463ed5c9b422ace769 100644 (file)
@@ -82,6 +82,10 @@ extern ULong h_generic_calc_CmpGT32Sx2 ( ULong, ULong );
 extern ULong h_generic_calc_CmpGT16Sx4 ( ULong, ULong );
 extern ULong h_generic_calc_CmpGT8Sx8  ( ULong, ULong );
 
+extern ULong h_generic_calc_CmpNEZ32x2 ( ULong );
+extern ULong h_generic_calc_CmpNEZ16x4 ( ULong );
+extern ULong h_generic_calc_CmpNEZ8x8  ( ULong );
+
 extern ULong h_generic_calc_QNarrow32Sx2 ( ULong, ULong );
 extern ULong h_generic_calc_QNarrow16Sx4 ( ULong, ULong );
 extern ULong h_generic_calc_QNarrow16Ux4 ( ULong, ULong );
index f5d4938ad7df233481581bfb156bef4313f9a3de..c0a03c0a3c1d7aa30661ffa6cbf4fa9b31ccd322 100644 (file)
@@ -2218,6 +2218,33 @@ static void iselInt64Expr_wrk ( HReg* rHi, HReg* rLo, ISelEnv* env, IRExpr* e )
             return;
          }
 
+         case Iop_CmpNEZ32x2:
+            fn = (HWord)h_generic_calc_CmpNEZ32x2; goto unish;
+         case Iop_CmpNEZ16x4:
+            fn = (HWord)h_generic_calc_CmpNEZ16x4; goto unish;
+         case Iop_CmpNEZ8x8:
+            fn = (HWord)h_generic_calc_CmpNEZ8x8; goto unish;
+         unish: {
+            /* Note: the following assumes all helpers are of
+               signature 
+                  ULong fn ( ULong ), and they are
+               not marked as regparm functions. 
+            */
+            HReg xLo, xHi;
+            HReg tLo = newVRegI(env);
+            HReg tHi = newVRegI(env);
+            iselInt64Expr(&xHi, &xLo, env, e->Iex.Unop.arg);
+            addInstr(env, X86Instr_Push(X86RMI_Reg(xHi)));
+            addInstr(env, X86Instr_Push(X86RMI_Reg(xLo)));
+            addInstr(env, X86Instr_Call( Xcc_ALWAYS, (UInt)fn, 0 ));
+            add_to_esp(env, 2*4);
+            addInstr(env, mk_iMOVsd_RR(hregX86_EDX(), tHi));
+            addInstr(env, mk_iMOVsd_RR(hregX86_EAX(), tLo));
+            *rHi = tHi;
+            *rLo = tLo;
+            return;
+         }
+
          default: 
             break;
       }
index cf595d98a4a69b25b4955906ffcfbc11d492910f..6fa5804af6ec0955f098d40657c7b73c20b6b1f7 100644 (file)
@@ -268,6 +268,10 @@ void ppIROp ( IROp op )
       case Iop_InterleaveLO16x4: vex_printf("InterleaveLO16x4"); return;
       case Iop_InterleaveLO32x2: vex_printf("InterleaveLO32x2"); return;
 
+      case Iop_CmpNEZ32x2: vex_printf("CmpNEZ32x2"); return;
+      case Iop_CmpNEZ16x4: vex_printf("CmpNEZ16x4"); return;
+      case Iop_CmpNEZ8x8:  vex_printf("CmpNEZ8x8"); return;
+
       case Iop_Add32Fx4:  vex_printf("Add32Fx4"); return;
       case Iop_Add32F0x4: vex_printf("Add32F0x4"); return;
       case Iop_Add64Fx2:  vex_printf("Add64Fx2"); return;
@@ -346,6 +350,7 @@ void ppIROp ( IROp op )
       case Iop_And128:     vex_printf("And128"); return;
       case Iop_Or128:      vex_printf("Or128");  return;
       case Iop_Xor128:     vex_printf("Xor128"); return;
+
       case Iop_CmpNEZ8x16: vex_printf("CmpNEZ8x16"); return;
       case Iop_CmpNEZ16x8: vex_printf("CmpNEZ16x8"); return;
       case Iop_CmpNEZ32x4: vex_printf("CmpNEZ32x4"); return;
@@ -1206,7 +1211,10 @@ void typeOfPrimop ( IROp op, IRType* t_dst, IRType* t_arg1, IRType* t_arg2 )
       case Iop_Not8:   UNARY(Ity_I8,Ity_I8);
       case Iop_Not16:  UNARY(Ity_I16,Ity_I16);
       case Iop_Not32:  UNARY(Ity_I32,Ity_I32);
-      case Iop_Not64:  UNARY(Ity_I64,Ity_I64);
+
+      case Iop_Not64:  
+      case Iop_CmpNEZ32x2: case Iop_CmpNEZ16x4: case Iop_CmpNEZ8x8:
+         UNARY(Ity_I64,Ity_I64);
 
       case Iop_CmpEQ8: case Iop_CmpNE8:
          COMPARISON(Ity_I8);
index 799a0510f957caa8acc46f67528d97146ec689e3..6e1497d82fdf758a9a1b0f3a9cd732d6fd64d1d1 100644 (file)
@@ -330,7 +330,7 @@ typedef
       /* ------------------ 64-bit SIMD Integer. ------------------ */
 
       /* MISC (vector integer cmp != 0) */
-      //      Iop_CmpNEZ8x8, Iop_CmpNEZ16x4, Iop_CmpNEZ32x2,
+      Iop_CmpNEZ8x8, Iop_CmpNEZ16x4, Iop_CmpNEZ32x2,
 
       /* ADDITION (normal / unsigned sat / signed sat) */
       Iop_Add8x8,   Iop_Add16x4,   Iop_Add32x2,