[llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Fri Apr 23 12:12:26 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

TraceOptEmitter.cpp updated: 1.3 -> 1.4

---
Log message:

Interface the TraceOptEmitter to Anand's VirtualMem i/o class.
Turn emitByte() into a runtime error.
Implement emitWordAt() for it.
Add debugging printouts.


---
Diffs of the changes:  (+17 -2)

Index: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp
diff -u reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.3 reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.4
--- reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.3	Wed Apr 14 12:18:42 2004
+++ reopt/lib/LightWtProfiling/TraceOptEmitter.cpp	Fri Apr 23 12:11:41 2004
@@ -22,6 +22,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "reopt/ScratchMemory.h"
+#include "reopt/VirtualMem.h"
+#include "ReoptimizerInternal.h"
 #include "llvm/Constant.h"
 #include "llvm/Module.h"
 #include "llvm/CodeGen/MachineCodeEmitter.h"
@@ -67,6 +69,7 @@
     }
     virtual void emitByte(unsigned char B);
     virtual void emitWord(unsigned W);
+    virtual void emitWordAt(unsigned W, unsigned *Ptr);
 
     virtual uint64_t getGlobalValueAddress(GlobalValue *V);
     virtual uint64_t getGlobalValueAddress(const std::string &Name);
@@ -148,14 +151,26 @@
 }
 
 void TraceOptEmitter::emitByte(unsigned char B) {
-  *CurByte++ = B;   // Write the byte to memory
+  std::cerr << "TraceOptEmitter: attempt to emit a single byte: 0x" << std::hex << (unsigned)B << std::dec << " at cursor: " << (unsigned)(uintptr_t)CurByte << "\n";
+  abort ();
+  // *CurByte = W;
+  ++CurByte;
 }
 
 void TraceOptEmitter::emitWord(unsigned W) {
   // This won't work if the endianness of the host and target don't agree!  (For
   // a JIT this can't happen though.  :)
-  *(unsigned*)CurByte = W;
+  std::cerr << "TraceOptEmitter: emitting word 0x" << std::hex << W
+            << " at cursor: " << (uint64_t)(uintptr_t)CurByte << std::dec
+            << "\n";
+  vm->writeInstToVM (W, (uint64_t) CurByte);  // does: *(unsigned*)CurByte = W;
   CurByte += sizeof(unsigned);
+}
+
+void TraceOptEmitter::emitWordAt(unsigned W, unsigned *Ptr) {
+  std::cerr << "TraceOptEmitter: emitting word 0x" << std::hex << W
+            << std::dec << " at pointer: " << Ptr << "\n";
+  vm->writeInstToVM (W, (uint64_t) Ptr);  // does: *Ptr = W;
 }
 
 uint64_t TraceOptEmitter::getGlobalValueAddress(GlobalValue *V) {





More information about the llvm-commits mailing list