From 8c3122ff46bbb328e6b49f341a5b7903ec84df45 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 2 May 2019 17:45:42 -0400 Subject: [PATCH] A64/translate/impl/impl: Mark locals const where applicable in DecodeBitMasks() Follows the convention of making immutable state explicit. --- src/frontend/A64/translate/impl/impl.cpp | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/frontend/A64/translate/impl/impl.cpp b/src/frontend/A64/translate/impl/impl.cpp index 50aa6011..15545de7 100644 --- a/src/frontend/A64/translate/impl/impl.cpp +++ b/src/frontend/A64/translate/impl/impl.cpp @@ -40,24 +40,25 @@ bool TranslatorVisitor::RaiseException(Exception exception) { } std::optional TranslatorVisitor::DecodeBitMasks(bool immN, Imm<6> imms, Imm<6> immr, bool immediate) { - int len = Common::HighestSetBit((immN ? 1 << 6 : 0) | (imms.ZeroExtend() ^ 0b111111)); - if (len < 1) + const int len = Common::HighestSetBit((immN ? 1 << 6 : 0) | (imms.ZeroExtend() ^ 0b111111)); + if (len < 1) { return std::nullopt; + } - size_t levels = Common::Ones(len); - - if (immediate && (imms.ZeroExtend() & levels) == levels) + const size_t levels = Common::Ones(len); + if (immediate && (imms.ZeroExtend() & levels) == levels) { return std::nullopt; + } - s32 S = s32(imms.ZeroExtend() & levels); - s32 R = s32(immr.ZeroExtend() & levels); - u64 d = u64(S - R) & levels; + const s32 S = s32(imms.ZeroExtend() & levels); + const s32 R = s32(immr.ZeroExtend() & levels); + const u64 d = u64(S - R) & levels; - size_t esize = static_cast(1) << len; - u64 welem = Common::Ones(S + 1); - u64 telem = Common::Ones(d + 1); - u64 wmask = Common::RotateRight(Common::Replicate(welem, esize), R); - u64 tmask = Common::Replicate(telem, esize); + const size_t esize = size_t{1} << len; + const u64 welem = Common::Ones(S + 1); + const u64 telem = Common::Ones(d + 1); + const u64 wmask = Common::RotateRight(Common::Replicate(welem, esize), R); + const u64 tmask = Common::Replicate(telem, esize); return BitMasks{wmask, tmask}; }