Merge zizzer.eecs.umich.edu:/z/m5/Bitkeeper/m5
[gem5.git] / cpu / base_dyn_inst.cc
index 74f6b8a6c0250b419f2b17632377f5f54e715ac2..86314bef1cd74505a8b0d920658507558a58d925 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2004 The Regents of The University of Michigan
+ * Copyright (c) 2004-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,8 +26,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef __BASE_DYN_INST_CC__
-#define __BASE_DYN_INST_CC__
+#ifndef __CPU_BASE_DYN_INST_CC__
+#define __CPU_BASE_DYN_INST_CC__
 
 #include <iostream>
 #include <string>
@@ -41,8 +41,8 @@
 #include "mem/mem_req.hh"
 
 #include "cpu/base_dyn_inst.hh"
-#include "cpu/beta_cpu/alpha_impl.hh"
-#include "cpu/beta_cpu/alpha_full_cpu.hh"
+#include "cpu/o3/alpha_impl.hh"
+#include "cpu/o3/alpha_cpu.hh"
 
 using namespace std;
 
@@ -63,131 +63,72 @@ typedef m5::hash_map<const BaseDynInst *, const BaseDynInst *, MyHashFunc> my_ha
 my_hash_t thishash;
 #endif
 
-/** This may need to be specific to an implementation. */
-//int BaseDynInst<Impl>::instcount = 0;
-
-//int break_inst = -1;
-
 template <class Impl>
 BaseDynInst<Impl>::BaseDynInst(MachInst machInst, Addr inst_PC,
                                Addr pred_PC, InstSeqNum seq_num,
                                FullCPU *cpu)
     : staticInst(machInst), traceData(NULL), cpu(cpu), xc(cpu->xcBase())
 {
-    DPRINTF(FullCPU, "DynInst: Creating new DynInst.\n");
+    seqNum = seq_num;
+
+    PC = inst_PC;
+    nextPC = PC + sizeof(MachInst);
+    predPC = pred_PC;
+
+    initVars();
+}
+
+template <class Impl>
+BaseDynInst<Impl>::BaseDynInst(StaticInstPtr &_staticInst)
+    : staticInst(_staticInst), traceData(NULL)
+{
+    initVars();
+}
 
+template <class Impl>
+void
+BaseDynInst<Impl>::initVars()
+{
     effAddr = MemReq::inval_addr;
     physEffAddr = MemReq::inval_addr;
 
     readyRegs = 0;
 
-    seqNum = seq_num;
-
-//    specMemWrite = false;
-
+    completed = false;
     canIssue = false;
     issued = false;
     executed = false;
     canCommit = false;
     squashed = false;
     squashedInIQ = false;
+    eaCalcDone = false;
 
     blockingInst = false;
     recoverInst = false;
-    specMode = false;
-//    btbMissed = false;
+
     // Eventually make this a parameter.
     threadNumber = 0;
-    // Also make this a parameter.
-    specMode = true;
+
     // Also make this a parameter, or perhaps get it from xc or cpu.
     asid = 0;
 
     // Initialize the fault to be unimplemented opcode.
-    fault = Unimplemented_Opcode_Fault;
-
-    PC = inst_PC;
-    nextPC = PC + sizeof(MachInst);
-    predPC = pred_PC;
-
-    // Make sure to have the renamed register entries set to the same
-    // as the normal register entries.  It will allow the IQ to work
-    // without any modifications.
-    for (int i = 0; i < staticInst->numDestRegs(); i++)
-    {
-        _destRegIdx[i] = staticInst->destRegIdx(i);
-    }
-
-    for (int i = 0; i < staticInst->numSrcRegs(); i++)
-    {
-        _srcRegIdx[i] = staticInst->srcRegIdx(i);
-        _readySrcRegIdx[i] = 0;
-    }
+    fault = UnimplementedOpcodeFault;
 
     ++instcount;
 
-//    assert(instcount < 50);
-
     DPRINTF(FullCPU, "DynInst: Instruction created.  Instcount=%i\n",
             instcount);
 }
 
-template <class Impl>
-BaseDynInst<Impl>::BaseDynInst(StaticInstPtr<ISA> &_staticInst)
-    : staticInst(_staticInst), traceData(NULL)
-{
-    effAddr = MemReq::inval_addr;
-    physEffAddr = MemReq::inval_addr;
-
-//    specMemWrite = false;
-
-    blockingInst = false;
-    recoverInst = false;
-    specMode = false;
-//    btbMissed = false;
-
-    // Make sure to have the renamed register entries set to the same
-    // as the normal register entries.  It will allow the IQ to work
-    // without any modifications.
-    for (int i = 0; i < staticInst->numDestRegs(); i++)
-    {
-        _destRegIdx[i] = staticInst->destRegIdx(i);
-    }
-
-    for (int i = 0; i < staticInst->numSrcRegs(); i++)
-    {
-        _srcRegIdx[i] = staticInst->srcRegIdx(i);
-    }
-}
-
 template <class Impl>
 BaseDynInst<Impl>::~BaseDynInst()
 {
-/*
-    if (specMemWrite) {
-        // Remove effects of this instruction from speculative memory
-        xc->spec_mem->erase(effAddr);
-    }
-*/
     --instcount;
     DPRINTF(FullCPU, "DynInst: Instruction destroyed.  Instcount=%i\n",
             instcount);
 }
 
-template <class Impl>
-FunctionalMemory *
-BaseDynInst<Impl>::getMemory(void)
-{
-    return xc->mem;
-}
-/*
-template <class Impl>
-IntReg *
-BaseDynInst<Impl>::getIntegerRegs(void)
-{
-    return (spec_mode ? xc->specIntRegFile : xc->regs.intRegFile);
-}
-*/
 template <class Impl>
 void
 BaseDynInst<Impl>::prefetch(Addr addr, unsigned flags)
@@ -201,12 +142,12 @@ BaseDynInst<Impl>::prefetch(Addr addr, unsigned flags)
     req->asid = asid;
 
     // Prefetches never cause faults.
-    fault = No_Fault;
+    fault = NoFault;
 
     // note this is a local, not BaseDynInst::fault
     Fault trans_fault = xc->translateDataReadReq(req);
 
-    if (trans_fault == No_Fault && !(req->flags & UNCACHEABLE)) {
+    if (trans_fault == NoFault && !(req->flags & UNCACHEABLE)) {
         // It's a valid address to cacheable space.  Record key MemReq
         // parameters so we can generate another one just like it for
         // the timing access without calling translate() again (which
@@ -225,7 +166,7 @@ BaseDynInst<Impl>::prefetch(Addr addr, unsigned flags)
      * Replace the disjoint functional memory with a unified one and remove
      * this hack.
      */
-#ifndef FULL_SYSTEM
+#if !FULL_SYSTEM
     req->paddr = req->vaddr;
 #endif
 
@@ -247,7 +188,7 @@ BaseDynInst<Impl>::writeHint(Addr addr, int size, unsigned flags)
 
     fault = xc->translateDataWriteReq(req);
 
-    if (fault == No_Fault && !(req->flags & UNCACHEABLE)) {
+    if (fault == NoFault && !(req->flags & UNCACHEABLE)) {
         // Record key MemReq parameters so we can generate another one
         // just like it for the timing access without calling translate()
         // again (which might mess up the TLB).
@@ -276,7 +217,7 @@ BaseDynInst<Impl>::copySrcTranslate(Addr src)
     // translate to physical address
     Fault fault = xc->translateDataReadReq(req);
 
-    if (fault == No_Fault) {
+    if (fault == NoFault) {
         xc->copySrcAddr = src;
         xc->copySrcPhysAddr = req->paddr;
     } else {
@@ -302,7 +243,7 @@ BaseDynInst<Impl>::copy(Addr dest)
     // translate to physical address
     Fault fault = xc->translateDataWriteReq(req);
 
-    if (fault == No_Fault) {
+    if (fault == NoFault) {
         Addr dest_addr = req->paddr;
         // Need to read straight from memory since we have more than 8 bytes.
         req->paddr = xc->copySrcPhysAddr;
@@ -351,7 +292,7 @@ BaseDynInst<Impl>::mem_access(mem_cmd cmd, Addr addr, void *p, int nbytes)
 #if 0
         panic("unaligned access. Cycle = %n", curTick);
 #endif
-        return No_Fault;
+        return NoFault;
     }
 
     MemReqPtr req = new MemReq(addr, thread, nbytes);
@@ -362,7 +303,7 @@ BaseDynInst<Impl>::mem_access(mem_cmd cmd, Addr addr, void *p, int nbytes)
 
       case Write:
         fault = spec_mem->write(req, (uint8_t *)p);
-        if (fault != No_Fault)
+        if (fault != NoFault)
             break;
 
         specMemWrite = true;
@@ -384,7 +325,7 @@ BaseDynInst<Impl>::mem_access(mem_cmd cmd, Addr addr, void *p, int nbytes)
         break;
 
       default:
-        fault = Machine_Check_Fault;
+        fault = MachineCheckFault;
         break;
     }
 
@@ -395,10 +336,28 @@ BaseDynInst<Impl>::mem_access(mem_cmd cmd, Addr addr, void *p, int nbytes)
 
 #endif
 
+template <class Impl>
+bool
+BaseDynInst<Impl>::eaSrcsReady()
+{
+    // For now I am assuming that src registers 1..n-1 are the ones that the
+    // EA calc depends on.  (i.e. src reg 0 is the source of the data to be
+    // stored)
+
+    for (int i = 1; i < numSrcRegs(); ++i)
+    {
+        if (!_readySrcRegIdx[i])
+            return false;
+    }
+
+    return true;
+}
+
+// Forward declaration
+template class BaseDynInst<AlphaSimpleImpl>;
+
+template <>
 int
 BaseDynInst<AlphaSimpleImpl>::instcount = 0;
 
-// Forward declaration...
-template BaseDynInst<AlphaSimpleImpl>;
-
-#endif // __BASE_DYN_INST_CC__
+#endif // __CPU_BASE_DYN_INST_CC__