Blame SOURCES/valgrind-3.14.0-ppc64-lxvb16x.patch

560544
commit 5c00e04a1b61475a7f731f8cfede114201815e0a
560544
Author: Mark Wielaard <mark@klomp.org>
560544
Date:   Sun Dec 9 23:25:05 2018 +0100
560544
560544
    Implement ppc64 lxvb16x as 128-bit vector load with reversed double words.
560544
    
560544
    This makes it possible for memcheck to know which part of the 128bit
560544
    vector is defined, even if the load is partly beyond an addressable block.
560544
    
560544
    Partially resolves bug 386945.
560544
560544
diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c
560544
index 7af4973..ec2f90a 100644
560544
--- a/VEX/priv/guest_ppc_toIR.c
560544
+++ b/VEX/priv/guest_ppc_toIR.c
560544
@@ -20702,54 +20702,29 @@ dis_vx_load ( UInt theInstr )
560544
    {
560544
       DIP("lxvb16x %d,r%u,r%u\n", (UInt)XT, rA_addr, rB_addr);
560544
 
560544
-      IRTemp byte[16];
560544
-      int i;
560544
-      UInt ea_off = 0;
560544
-      IRExpr* irx_addr;
560544
-      IRTemp tmp_low[9];
560544
-      IRTemp tmp_hi[9];
560544
+      /* The result of lxvb16x should be the same on big and little
560544
+         endian systems. We do a host load, then reverse the bytes in
560544
+         the double words. If the host load was little endian we swap
560544
+         them around again. */
560544
 
560544
-      tmp_low[0] = newTemp( Ity_I64 );
560544
-      tmp_hi[0] = newTemp( Ity_I64 );
560544
-      assign( tmp_low[0], mkU64( 0 ) );
560544
-      assign( tmp_hi[0], mkU64( 0 ) );
560544
-
560544
-      for ( i = 0; i < 8; i++ ) {
560544
-         byte[i] = newTemp( Ity_I64 );
560544
-         tmp_low[i+1] = newTemp( Ity_I64 );
560544
-
560544
-         irx_addr = binop( mkSzOp( ty, Iop_Add8 ), mkexpr( EA ),
560544
-                           ty == Ity_I64 ? mkU64( ea_off ) : mkU32( ea_off ) );
560544
-         ea_off += 1;
560544
-
560544
-         assign( byte[i], binop( Iop_Shl64,
560544
-                                 unop( Iop_8Uto64,
560544
-                                       load( Ity_I8, irx_addr ) ),
560544
-                                 mkU8( 8 * ( 7 - i ) ) ) );
560544
+      IRTemp high = newTemp(Ity_I64);
560544
+      IRTemp high_rev = newTemp(Ity_I64);
560544
+      IRTemp low = newTemp(Ity_I64);
560544
+      IRTemp low_rev = newTemp(Ity_I64);
560544
 
560544
-         assign( tmp_low[i+1],
560544
-                 binop( Iop_Or64,
560544
-                        mkexpr( byte[i] ), mkexpr( tmp_low[i] ) ) );
560544
-      }
560544
+      IRExpr *t128 = load( Ity_V128, mkexpr( EA ) );
560544
 
560544
-      for ( i = 0; i < 8; i++ ) {
560544
-         byte[i + 8] = newTemp( Ity_I64 );
560544
-         tmp_hi[i+1] = newTemp( Ity_I64 );
560544
+      assign( high, unop(Iop_V128HIto64, t128) );
560544
+      assign( high_rev, unop(Iop_Reverse8sIn64_x1, mkexpr(high)) );
560544
+      assign( low, unop(Iop_V128to64, t128) );
560544
+      assign( low_rev, unop(Iop_Reverse8sIn64_x1, mkexpr(low)) );
560544
 
560544
-         irx_addr = binop( mkSzOp( ty, Iop_Add8 ), mkexpr( EA ),
560544
-                           ty == Ity_I64 ? mkU64( ea_off ) : mkU32( ea_off ) );
560544
-         ea_off += 1;
560544
+      if (host_endness == VexEndnessLE)
560544
+         t128 = binop( Iop_64HLtoV128, mkexpr (low_rev), mkexpr (high_rev) );
560544
+      else
560544
+         t128 = binop( Iop_64HLtoV128, mkexpr (high_rev), mkexpr (low_rev) );
560544
 
560544
-         assign( byte[i+8], binop( Iop_Shl64,
560544
-                                   unop( Iop_8Uto64,
560544
-                                         load( Ity_I8, irx_addr ) ),
560544
-                                   mkU8( 8 * ( 7 - i ) ) ) );
560544
-         assign( tmp_hi[i+1], binop( Iop_Or64,
560544
-                                     mkexpr( byte[i+8] ),
560544
-                                     mkexpr( tmp_hi[i] ) ) );
560544
-      }
560544
-      putVSReg( XT, binop( Iop_64HLtoV128,
560544
-                           mkexpr( tmp_low[8] ), mkexpr( tmp_hi[8] ) ) );
560544
+      putVSReg( XT, t128 );
560544
       break;
560544
    }
560544