mem: Make the XBar responsible for tracking response routing
[gem5.git] / src / cpu / legiontrace.cc
index 58181cb88bf8f9ecf33ef5a29b3bf477b0a26b33..b94b8f5fef7abfded6415696162cbb1df7b632f8 100644 (file)
  *          Steve Raasch
  */
 
-#include "arch/isa_specific.hh"
+#include "config/the_isa.hh"
 #if THE_ISA != SPARC_ISA
     #error Legion tracing only works with SPARC simulations!
 #endif
 
-#include "config/full_system.hh"
-#if !FULL_SYSTEM
-    #error Legion tracing only works in full system!
-#endif
-
-#include <iomanip>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 
-#include "arch/sparc/predecoder.hh"
-#include "arch/sparc/regfile.hh"
+#include <cstdio>
+#include <iomanip>
+
+#include "arch/sparc/decoder.hh"
+#include "arch/sparc/registers.hh"
 #include "arch/sparc/utility.hh"
+#include "arch/tlb.hh"
 #include "base/socket.hh"
 #include "cpu/base.hh"
 #include "cpu/legiontrace.hh"
 #include "cpu/static_inst.hh"
 #include "cpu/thread_context.hh"
-#include "params/LegionTrace.hh"
+#include "sim/full_system.hh"
 #include "sim/system.hh"
 
-#if FULL_SYSTEM
-#include "arch/tlb.hh"
-#endif
-
 //XXX This is temporary
 #include "cpu/m5legion_interface.h"
 
 using namespace std;
 using namespace TheISA;
 
-#if FULL_SYSTEM
 static int diffcount = 0;
 static bool wasMicro = false;
-#endif
 
 namespace Trace {
 SharedData *shared_data = NULL;
@@ -101,7 +93,7 @@ setupSharedData()
 //  Utility methods for pretty printing a report about a difference
 //
 
-inline char * genCenteredLabel(int length, char * buffer, char * label)
+inline char * genCenteredLabel(int length, char * buffer, const char * label)
 {
     int labelLength = strlen(label);
     assert(labelLength <= length);
@@ -128,7 +120,7 @@ inline void printColumnLabels(ostream & os)
     ccprintf(os, "--------------------+-----------------------+-----------------------\n");
 }
 
-inline void printSectionHeader(ostream & os, char * name)
+inline void printSectionHeader(ostream & os, const char * name)
 {
     char sectionString[70];
     genCenteredLabel(69, sectionString, name);
@@ -153,7 +145,6 @@ Trace::LegionTraceRecord::dump()
 {
     ostream &outs = Trace::output();
 
-    static TheISA::Predecoder predecoder(NULL);
     // Compare
     bool compared = false;
     bool diffPC   = false;
@@ -165,7 +156,7 @@ Trace::LegionTraceRecord::dump()
     bool diffTnpc = false;
     bool diffTstate = false;
     bool diffTt = false;
-    bool diffTba = false;
+    bool diffTba M5_VAR_USED = false;
     bool diffHpstate = false;
     bool diffHtstate = false;
     bool diffHtba = false;
@@ -210,7 +201,7 @@ Trace::LegionTraceRecord::dump()
     if(!staticInst->isMicroop() || staticInst->isLastMicroop()) {
         while (!compared) {
             if (shared_data->flags == OWN_M5) {
-                m5Pc = PC & SparcISA::PAddrImplMask;
+                m5Pc = pc.instAddr() & SparcISA::PAddrImplMask;
                 if (bits(shared_data->pstate,3,3)) {
                     m5Pc &= mask(32);
                 }
@@ -233,8 +224,7 @@ Trace::LegionTraceRecord::dump()
                     }
                 }
                 for (int i = 0; i < TheISA::NumFloatRegs/2; i++) {
-                    if (thread->readFloatRegBits(i*2,
-                                FloatRegFile::DoubleWidth) !=
+                    if (thread->readFloatRegBits(i*2) !=
                             shared_data->fpregs[i]) {
                         diffFpRegs = true;
                     }
@@ -431,14 +421,13 @@ Trace::LegionTraceRecord::dump()
                          << staticInst->disassemble(m5Pc, debugSymbolTable)
                          << endl;
 
-                    predecoder.setTC(thread);
-                    predecoder.moreBytes(m5Pc, m5Pc,
-                            shared_data->instruction);
+                    TheISA::Decoder *decoder = thread->getDecoderPtr();
+                    decoder->moreBytes(m5Pc, m5Pc, shared_data->instruction);
 
-                    assert(predecoder.extMachInstReady());
+                    assert(decoder->instReady());
 
-                    StaticInstPtr legionInst =
-                        StaticInst::decode(predecoder.getExtMachInst(), lgnPc);
+                    PCState tempPC = pc;
+                    StaticInstPtr legionInst = decoder->decode(tempPC);
                     outs << setfill(' ') << setw(15)
                          << " Legion Inst: "
                          << "0x" << setw(8) << setfill('0') << hex
@@ -540,14 +529,13 @@ Trace::LegionTraceRecord::dump()
                             char label[8];
                             sprintf(label, "%%f%d", x);
                             printRegPair(outs, label,
-                                thread->readFloatRegBits(x*2,
-                                    FloatRegFile::DoubleWidth),
+                                thread->readFloatRegBits(x*2),
                                 shared_data->fpregs[x]);
                         }
                     }
                     if (diffTlb) {
                         printColumnLabels(outs);
-                        char label[8];
+                        char label[9];
                         for (int x = 0; x < 64; x++) {
                             if (shared_data->itb[x] !=
                                     ULL(0xFFFFFFFFFFFFFFFF) ||
@@ -587,7 +575,7 @@ Trace::LegionTraceRecord::dump()
     } // if not microop
 }
 
-/* namespace Trace */ }
+} // namespace Trace
 
 ////////////////////////////////////////////////////////////////////////
 //
@@ -596,5 +584,7 @@ Trace::LegionTraceRecord::dump()
 Trace::LegionTrace *
 LegionTraceParams::create()
 {
-    return new Trace::LegionTrace(name);
+    if (!FullSystem)
+        panic("Legion tracing only works in full system!");
+    return new Trace::LegionTrace(this);
 };