1/**
2 * Copyright (c) 2018 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 112 unchanged lines hidden (view full) ---

121};
122
123/**
124 * A basic compression superblock.
125 * Contains the tag and a list of blocks associated to this superblock.
126 */
127class SuperBlk : public SectorBlk
128{
129 protected:
130 /** Block size, in bytes. */
131 std::size_t blkSize;
132
133 public:
130 SuperBlk() : SectorBlk() {}
134 SuperBlk() : SectorBlk(), blkSize(0) {}
135 SuperBlk(const SuperBlk&) = delete;
136 SuperBlk& operator=(const SuperBlk&) = delete;
137 ~SuperBlk() {};
138
139 /**
140 * Returns whether the superblock contains compressed blocks or not. By
141 * default, if not blocks are valid, the superblock is compressible.
142 *
143 * @param ignored_blk If provided don't consider the given block.
144 * @return The compressibility state of the superblock.
145 */
141 bool isCompressed() const;
146 bool isCompressed(const CompressionBlk* ignored_blk = nullptr) const;
147
148 /**
149 * Checks whether a superblock can co-allocate given compressed data block.
150 *
151 * @param compressed_size Size, in bits, of new block to allocate.
152 * @return True if block can be co-allocated in superblock.
153 */
154 bool canCoAllocate(const std::size_t compressed_size) const;
155
156 /**
157 * Set block size. Should be called only once, when initializing blocks.
158 *
159 * @param blk_size The uncompressed block size.
160 */
161 void setBlkSize(const std::size_t blk_size);
162};
163
164#endif //__MEM_CACHE_TAGS_SUPER_BLK_HH__