mem-cache: Fix copy ellision on base compressor
[gem5.git] / src / mem / cache / tags / sector_blk.hh
index d252a610f9cab2bbcd967ee6b5702c20064c9c62..0a9087eee1b4e41dd357e1fc481a9642c3db5986 100644 (file)
@@ -24,8 +24,6 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Daniel Carvalho
  */
 
 /** @file
@@ -39,7 +37,7 @@
 #include <vector>
 
 #include "mem/cache/cache_blk.hh"
-#include "mem/cache/replacement_policies/base.hh"
+#include "mem/cache/replacement_policies/replaceable_entry.hh"
 
 class SectorBlk;
 
@@ -49,7 +47,7 @@ class SectorBlk;
  */
 class SectorSubBlk : public CacheBlk
 {
-  private:
+  protected:
     /**
      * Sector block associated to this block.
      */
@@ -101,11 +99,26 @@ class SectorSubBlk : public CacheBlk
      */
     Addr getTag() const;
 
+    /**
+     * Set valid bit and inform sector block.
+     */
+    void setValid() override;
+
+    /**
+     * Set secure bit and inform sector block.
+     */
+    void setSecure() override;
+
+    /**
+     * Invalidate the block and inform sector block.
+     */
+    void invalidate() override;
+
     /**
      * Set member variables when a block insertion occurs. Resets reference
      * count to 1 (the insertion counts as a reference), and touch block if
      * it hadn't been touched previously. Sets the insertion tick to the
-     * current tick. Does not make block valid.
+     * current tick. Marks the block valid.
      *
      * @param tag Block address tag.
      * @param is_secure Whether the block is in secure space or not.
@@ -130,13 +143,25 @@ class SectorSubBlk : public CacheBlk
 class SectorBlk : public ReplaceableEntry
 {
   private:
+    /**
+     * Counter of the number of valid sub-blocks. The sector is valid if any
+     * of its sub-blocks is valid.
+     */
+    uint8_t _validCounter;
+
+  protected:
     /**
      * Sector tag value. A sector's tag is the tag of all its sub-blocks.
      */
     Addr _tag;
 
+    /**
+     * Whether sector blk is in secure-space or not.
+     */
+    bool _secureBit;
+
   public:
-    SectorBlk() : ReplaceableEntry(), _tag(MaxAddr) {}
+    SectorBlk();
     SectorBlk(const SectorBlk&) = delete;
     SectorBlk& operator=(const SectorBlk&) = delete;
     ~SectorBlk() {};
@@ -151,6 +176,13 @@ class SectorBlk : public ReplaceableEntry
      */
     bool isValid() const;
 
+    /**
+     * Get the number of sub-blocks that have been validated.
+     *
+     * @return The number of valid sub-blocks.
+     */
+    uint8_t getNumValid() const;
+
     /**
      * Checks that a sector block is secure. A single secure block suffices
      * to imply that the whole sector is secure, as the insertion proccess
@@ -173,6 +205,29 @@ class SectorBlk : public ReplaceableEntry
      * @return The tag value.
      */
     Addr getTag() const;
+
+    /**
+     * Increase the number of valid sub-blocks.
+     */
+    void validateSubBlk();
+
+    /**
+     * Decrease the number of valid sub-blocks.
+     */
+    void invalidateSubBlk();
+
+    /**
+     * Set secure bit.
+     */
+    void setSecure();
+
+    /**
+     * Sets the position of the sub-entries, besides its own.
+     *
+     * @param set The set of this entry and sub-entries.
+     * @param way The way of this entry and sub-entries.
+     */
+    void setPosition(const uint32_t set, const uint32_t way) override;
 };
 
 #endif //__MEM_CACHE_TAGS_SECTOR_BLK_HH__