Implement RDTSC (amd64).


git-svn-id: svn://svn.valgrind.org/vex/trunk@1346 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/guest-amd64/toIR.c b/priv/guest-amd64/toIR.c
index 327d60e..0a27bef 100644
--- a/priv/guest-amd64/toIR.c
+++ b/priv/guest-amd64/toIR.c
@@ -13084,35 +13084,24 @@
          break;
 
       /* =-=-=-=-=-=-=-=-=- RDTSC -=-=-=-=-=-=-=-=-=-=-= */
-
-      case 0x31: /* RDTSC */
-         if (haveF2orF3(pfx)) goto decode_failure;
-         if (0) vex_printf("vex amd64->IR: kludged rdtsc\n");
-         putIRegRAX(4, mkU32(1));
-         putIRegRDX(4, mkU32(0));
-
-//.. //--          t1 = newTemp(cb);
-//.. //--          t2 = newTemp(cb);
-//.. //--          t3 = newTemp(cb);
-//.. //--          uInstr0(cb, CALLM_S, 0);
-//.. //--          // Nb: even though these args aren't used by RDTSC_helper, need
-//.. //--          // them to be defined (for Memcheck).  The TempRegs pushed must
-//.. //--          // also be distinct.
-//.. //--          uInstr2(cb, MOV,   4, Literal, 0, TempReg, t1);
-//.. //--          uLiteral(cb, 0);
-//.. //--          uInstr1(cb, PUSH,  4, TempReg, t1);
-//.. //--          uInstr2(cb, MOV,   4, Literal, 0, TempReg, t2);
-//.. //--          uLiteral(cb, 0);
-//.. //--          uInstr1(cb, PUSH,  4, TempReg, t2);
-//.. //--          uInstr1(cb, CALLM, 0, Lit16,   VGOFF_(helper_RDTSC));
-//.. //--          uFlagsRWU(cb, FlagsEmpty, FlagsEmpty, FlagsEmpty);
-//.. //--          uInstr1(cb, POP,   4, TempReg, t3);
-//.. //--          uInstr2(cb, PUT,   4, TempReg, t3, ArchReg, R_EDX);
-//.. //--          uInstr1(cb, POP,   4, TempReg, t3);
-//.. //--          uInstr2(cb, PUT,   4, TempReg, t3, ArchReg, R_EAX);
-//.. //--          uInstr0(cb, CALLM_E, 0);
+      case 0x31: { /* RDTSC */
+         IRTemp   val  = newTemp(Ity_I64);
+         IRExpr** args = mkIRExprVec_0();
+         IRDirty* d    = unsafeIRDirty_1_N ( 
+                            val, 
+                            0/*regparms*/, 
+                            "amd64g_dirtyhelper_RDTSC", 
+                            &amd64g_dirtyhelper_RDTSC, 
+                            args 
+                         );
+         if (have66orF2orF3(pfx)) goto decode_failure;
+         /* execute the dirty call, dumping the result in val. */
+         stmt( IRStmt_Dirty(d) );
+         putIRegRDX(4, unop(Iop_64HIto32, mkexpr(val)));
+         putIRegRAX(4, unop(Iop_64to32, mkexpr(val)));
          DIP("rdtsc\n");
          break;
+      }
 
 //..       /* =-=-=-=-=-=-=-=-=- PUSH/POP Sreg =-=-=-=-=-=-=-=-=-= */
 //..