From 70dc35a659d024a4362c7b3f08887f04285b34f9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Tue, 16 Jul 2019 10:51:08 +0200 Subject: mem-cache: Use shouldAllocate() instead of CPack's decompress() Split decompression functionality using the proper function to determine if a dictionary entry should be allocated after decompression or not. Change-Id: I4995304f4c4508c03c9fc1685f04511622969556 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21146 Tested-by: kokoro Reviewed-by: Nikos Nikoleris Reviewed-by: Bobby R. Bruce Maintainer: Nikos Nikoleris --- src/mem/cache/compressors/cpack.hh | 49 ++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'src/mem/cache/compressors/cpack.hh') diff --git a/src/mem/cache/compressors/cpack.hh b/src/mem/cache/compressors/cpack.hh index 664a37601..1a271eeae 100644 --- a/src/mem/cache/compressors/cpack.hh +++ b/src/mem/cache/compressors/cpack.hh @@ -357,11 +357,10 @@ class CPack::Pattern * its data. * * @param dict_bytes The bytes in the corresponding matching entry. - * @param data The decompressed pattern. - * @return Whether entry should be added to dictionary or not. + * @return The decompressed pattern. */ - virtual bool decompress(const std::array dict_bytes, - std::array& data) const = 0; + virtual std::array decompress( + const std::array dict_bytes) const = 0; }; class CPack::PatternZZZZ : public Pattern @@ -378,11 +377,10 @@ class CPack::PatternZZZZ : public Pattern (bytes[0] == 0); } - bool decompress(const std::array dict_bytes, - std::array& data) const override + std::array + decompress(const std::array dict_bytes) const override { - data = {0, 0, 0, 0}; - return false; + return {0, 0, 0, 0}; } }; @@ -407,11 +405,10 @@ class CPack::PatternXXXX : public Pattern return true; } - bool decompress(const std::array dict_bytes, - std::array& data) const override + std::array + decompress(const std::array dict_bytes) const override { - data = bytes; - return true; + return bytes; } }; @@ -428,11 +425,10 @@ class CPack::PatternMMMM : public Pattern return (bytes == dict_bytes) && (match_location >= 0); } - bool decompress(const std::array dict_bytes, - std::array& data) const override + std::array + decompress(const std::array dict_bytes) const override { - data = dict_bytes; - return true; + return dict_bytes; } }; @@ -461,11 +457,10 @@ class CPack::PatternMMXX : public Pattern } - bool decompress(const std::array dict_bytes, - std::array& data) const override + std::array + decompress(const std::array dict_bytes) const override { - data = {byte0, byte1, dict_bytes[2], dict_bytes[3]}; - return true; + return {byte0, byte1, dict_bytes[2], dict_bytes[3]}; } }; @@ -489,11 +484,10 @@ class CPack::PatternZZZX : public Pattern (bytes[0] != 0); } - bool decompress(const std::array dict_bytes, - std::array& data) const override + std::array + decompress(const std::array dict_bytes) const override { - data = {byte, 0, 0, 0}; - return false; + return {byte, 0, 0, 0}; } }; @@ -519,11 +513,10 @@ class CPack::PatternMMMX : public Pattern (match_location >= 0); } - bool decompress(const std::array dict_bytes, - std::array& data) const override + std::array + decompress(const std::array dict_bytes) const override { - data = {byte, dict_bytes[1], dict_bytes[2], dict_bytes[3]}; - return true; + return {byte, dict_bytes[1], dict_bytes[2], dict_bytes[3]}; } }; -- cgit v1.2.3