From 511613c7360292913547ed9237c9f403ed336dda Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 2 May 2019 00:03:12 -0400 Subject: [PATCH] frontend/A32/types: Use helper function in operator+ overload Allows deduplicating an assert and a cast. --- src/frontend/A32/types.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/frontend/A32/types.h b/src/frontend/A32/types.h index d6b36384..50a76ef8 100644 --- a/src/frontend/A32/types.h +++ b/src/frontend/A32/types.h @@ -92,16 +92,14 @@ inline size_t RegNumber(ExtReg reg) { } inline Reg operator+(Reg reg, size_t number) { - ASSERT(reg != Reg::INVALID_REG); - - size_t new_reg = static_cast(reg) + number; + const size_t new_reg = RegNumber(reg) + number; ASSERT(new_reg <= 15); return static_cast(new_reg); } inline ExtReg operator+(ExtReg reg, size_t number) { - ExtReg new_reg = static_cast(static_cast(reg) + number); + const auto new_reg = static_cast(static_cast(reg) + number); ASSERT((IsSingleExtReg(reg) && IsSingleExtReg(new_reg)) || (IsDoubleExtReg(reg) && IsDoubleExtReg(new_reg)));