Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/34177 )

Change subject: base: Minor cleanup of the ChunkGenerator.
......................................................................

base: Minor cleanup of the ChunkGenerator.

Minor style fixes, switched to Addr for some types so they'll definitely
be large enough.

Change-Id: I985004116c48ce6fb236c04e04fe54ed49a68277
---
M src/base/chunk_generator.hh
1 file changed, 18 insertions(+), 21 deletions(-)



diff --git a/src/base/chunk_generator.hh b/src/base/chunk_generator.hh
index d1378aa..3873a66 100644
--- a/src/base/chunk_generator.hh
+++ b/src/base/chunk_generator.hh
@@ -26,8 +26,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

-#ifndef __BASE__CHUNK_GENERATOR_HH__
-#define __BASE__CHUNK_GENERATOR_HH__
+#ifndef __BASE_CHUNK_GENERATOR_HH__
+#define __BASE_CHUNK_GENERATOR_HH__

 /**
  * @file
@@ -60,13 +60,13 @@
     /** The starting address of the next chunk (after the current one). */
     Addr nextAddr;
     /** The size of the current chunk (in bytes). */
-    unsigned  curSize;
+    Addr curSize;
/** The number of bytes remaining in the region after the current chunk. */
-    unsigned  sizeLeft;
+    Addr sizeLeft;
     /** The start address so we can calculate offset in writing block. */
     const Addr startAddr;
     /** The maximum chunk size, e.g., the cache block size or page size. */
-    const unsigned chunkSize;
+    const Addr chunkSize;

   public:
     /**
@@ -76,8 +76,8 @@
      * @param _chunkSize The size/alignment of chunks into which
      *    the region should be decomposed.
      */
- ChunkGenerator(Addr _startAddr, unsigned totalSize, unsigned _chunkSize)
-        : startAddr(_startAddr), chunkSize(_chunkSize)
+    ChunkGenerator(Addr _startAddr, Addr totalSize, Addr _chunkSize) :
+        startAddr(_startAddr), chunkSize(_chunkSize)
     {
         // chunkSize must be a power of two
         assert(chunkSize == 0 || isPowerOf2(chunkSize));
@@ -85,13 +85,10 @@
         // set up initial chunk.
         curAddr = startAddr;

- if (chunkSize == 0) //Special Case, if we see 0, assume no chuncking
-        {
+ if (chunkSize == 0) { // Special Case, if we see 0, assume no chunking.
             nextAddr = startAddr + totalSize;
-        }
-        else
-        {
-            // nextAddr should be *next* chunk start
+        } else {
+            // nextAddr should be *next* chunk start.
             nextAddr = roundUp(startAddr, chunkSize);
             if (curAddr == nextAddr) {
                 // ... even if startAddr is already chunk-aligned
@@ -99,8 +96,8 @@
             }
         }

- // how many bytes are left between curAddr and the end of this chunk?
-        unsigned left_in_chunk = nextAddr - curAddr;
+ // How many bytes are left between curAddr and the end of this chunk?
+        Addr left_in_chunk = nextAddr - curAddr;
         curSize = std::min(totalSize, left_in_chunk);
         sizeLeft = totalSize - curSize;
     }
@@ -108,23 +105,23 @@
     /** Return starting address of current chunk. */
     Addr addr() const { return curAddr; }
     /** Return size in bytes of current chunk. */
-    unsigned size() const { return curSize; }
+    Addr size() const { return curSize; }

     /** Number of bytes we have already chunked up. */
-    unsigned complete() const { return curAddr - startAddr; }
+    Addr complete() const { return curAddr - startAddr; }

     /**
      * Are we done?  That is, did the last call to next() advance
      * past the end of the region?
      * @return True if yes, false if more to go.
      */
-    bool done() const { return (curSize == 0); }
+    bool done() const { return !curSize; }

     /**
      * Is this the last chunk?
      * @return True if yes, false if more to go.
      */
-    bool last() const { return (sizeLeft == 0); }
+    bool last() const { return !sizeLeft; }

     /**
      * Advance generator to next chunk.
@@ -134,7 +131,7 @@
     bool
     next()
     {
-        if (sizeLeft == 0) {
+        if (last()) {
             curSize = 0;
             return false;
         }
@@ -147,4 +144,4 @@
     }
 };

-#endif // __BASE__CHUNK_GENERATOR_HH__
+#endif // __BASE_CHUNK_GENERATOR_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34177
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I985004116c48ce6fb236c04e04fe54ed49a68277
Gerrit-Change-Number: 34177
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to