frontend/A32/types: Use helper function in operator+ overload
Allows deduplicating an assert and a cast.
This commit is contained in:
parent
796bb8a7f7
commit
511613c736
1 changed files with 2 additions and 4 deletions
|
@ -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<size_t>(reg) + number;
|
||||
const size_t new_reg = RegNumber(reg) + number;
|
||||
ASSERT(new_reg <= 15);
|
||||
|
||||
return static_cast<Reg>(new_reg);
|
||||
}
|
||||
|
||||
inline ExtReg operator+(ExtReg reg, size_t number) {
|
||||
ExtReg new_reg = static_cast<ExtReg>(static_cast<size_t>(reg) + number);
|
||||
const auto new_reg = static_cast<ExtReg>(static_cast<size_t>(reg) + number);
|
||||
|
||||
ASSERT((IsSingleExtReg(reg) && IsSingleExtReg(new_reg)) ||
|
||||
(IsDoubleExtReg(reg) && IsDoubleExtReg(new_reg)));
|
||||
|
|
Loading…
Reference in a new issue