cpu: make ExecSymbol show the symbol in addition to address
[gem5.git] / src / cpu / o3 / scoreboard.hh
index 77f2cf15795d9e3d9a05643caa5f85c0ee7c1d01..5573afcc523de37363bb7199237d47b79a740924 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2004-2005 The Regents of The University of Michigan
+ * Copyright (c) 2005-2006 The Regents of The University of Michigan
+ * Copyright (c) 2013 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <iostream>
 #include <utility>
 #include <vector>
-#include "arch/alpha/isa_traits.hh"
+
 #include "base/trace.hh"
-#include "base/traceflags.hh"
+#include "config/the_isa.hh"
 #include "cpu/o3/comm.hh"
+#include "debug/Scoreboard.hh"
 
 /**
- * Implements a simple scoreboard to track which registers are ready.
- * This class assumes that the fp registers start, index wise, right after
- * the integer registers. The misc. registers start, index wise, right after
- * the fp registers.
- * @todo: Fix up handling of the zero register in case the decoder does not
- * automatically make insts that write the zero register into nops.
+ * Implements a simple scoreboard to track which registers are
+ * ready. This class operates on the unified physical register space,
+ * because the different classes of registers do not need to be distinguished.
+ * Registers being part of a fixed mapping are always considered ready.
  */
 class Scoreboard
 {
+  private:
+    /** The object name, for DPRINTF.  We have to declare this
+     *  explicitly because Scoreboard is not a SimObject. */
+    const std::string _name;
+
+    /** Scoreboard of physical integer registers, saying whether or not they
+     *  are ready. */
+    std::vector<bool> regScoreBoard;
+
+    /** The number of actual physical registers */
+    unsigned M5_CLASS_VAR_USED numPhysRegs;
+
   public:
     /** Constructs a scoreboard.
-     *  @param activeThreads The number of active threads.
-     *  @param _numLogicalIntRegs Number of logical integer registers.
-     *  @param _numPhysicalIntRegs Number of physical integer registers.
-     *  @param _numLogicalFloatRegs Number of logical fp registers.
-     *  @param _numPhysicalFloatRegs Number of physical fp registers.
+     *  @param _numPhysicalRegs Number of physical registers.
      *  @param _numMiscRegs Number of miscellaneous registers.
-     *  @param _zeroRegIdx Index of the zero register.
      */
-    Scoreboard(unsigned activeThreads,
-               unsigned _numLogicalIntRegs,
-               unsigned _numPhysicalIntRegs,
-               unsigned _numLogicalFloatRegs,
-               unsigned _numPhysicalFloatRegs,
-               unsigned _numMiscRegs,
-               unsigned _zeroRegIdx);
+    Scoreboard(const std::string &_my_name,
+               unsigned _numPhysicalRegs);
 
     /** Destructor. */
     ~Scoreboard() {}
 
     /** Returns the name of the scoreboard. */
-    std::string name() const;
+    std::string name() const { return _name; };
 
     /** Checks if the register is ready. */
-    bool getReg(PhysRegIndex ready_reg);
+    bool getReg(PhysRegIdPtr phys_reg) const
+    {
+        assert(phys_reg->flatIndex() < numPhysRegs);
 
-    /** Sets the register as ready. */
-    void setReg(PhysRegIndex phys_reg);
+        if (phys_reg->isFixedMapping()) {
+            // Fixed mapping regs are always ready
+            return true;
+        }
 
-    /** Sets the register as not ready. */
-    void unsetReg(PhysRegIndex ready_reg);
+        bool ready = regScoreBoard[phys_reg->flatIndex()];
 
-  private:
-    /** Scoreboard of physical integer registers, saying whether or not they
-     *  are ready.
-     */
-    std::vector<bool> regScoreBoard;
+        if (phys_reg->isZeroReg())
+            assert(ready);
 
-    /** Number of logical integer registers. */
-    int numLogicalIntRegs;
+        return ready;
+    }
 
-    /** Number of physical integer registers. */
-    int numPhysicalIntRegs;
+    /** Sets the register as ready. */
+    void setReg(PhysRegIdPtr phys_reg)
+    {
+        assert(phys_reg->flatIndex() < numPhysRegs);
+
+        if (phys_reg->isFixedMapping()) {
+            // Fixed mapping regs are always ready, ignore attempts to change
+            // that
+            return;
+        }
 
-    /** Number of logical floating point registers. */
-    int numLogicalFloatRegs;
+        DPRINTF(Scoreboard, "Setting reg %i (%s) as ready\n",
+                phys_reg->index(), phys_reg->className());
 
-    /** Number of physical floating point registers. */
-    int numPhysicalFloatRegs;
+        regScoreBoard[phys_reg->flatIndex()] = true;
+    }
+
+    /** Sets the register as not ready. */
+    void unsetReg(PhysRegIdPtr phys_reg)
+    {
+        assert(phys_reg->flatIndex() < numPhysRegs);
 
-    /** Number of miscellaneous registers. */
-    int numMiscRegs;
+        if (phys_reg->isFixedMapping()) {
+            // Fixed mapping regs are always ready, ignore attempts to
+            // change that
+            return;
+        }
 
-    /** Number of logical integer + float registers. */
-    int numLogicalRegs;
+        // zero reg should never be marked unready
+        if (phys_reg->isZeroReg())
+            return;
 
-    /** Number of physical integer + float registers. */
-    int numPhysicalRegs;
+        regScoreBoard[phys_reg->flatIndex()] = false;
+    }
 
-    /** The logical index of the zero register. */
-    int zeroRegIdx;
 };
 
 #endif