diff --git a/src/common/bit_util.h b/src/common/bit_util.h index 35ef032b..93e6e652 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -218,18 +218,18 @@ constexpr T RotateRight(T value, size_t amount) { return static_cast((x >> amount) | (x << (BitSize() - amount))); } -constexpr u16 Swap16(u16 value) { +constexpr u16 SwapBytes16(u16 value) { return static_cast(u32{value} >> 8 | u32{value} << 8); } -constexpr u32 Swap32(u32 value) { +constexpr u32 SwapBytes32(u32 value) { return ((value & 0xFF000000U) >> 24) | ((value & 0x00FF0000U) >> 8) | ((value & 0x0000FF00U) << 8) | ((value & 0x000000FFU) << 24); } -constexpr u64 Swap64(u64 value) { +constexpr u64 SwapBytes64(u64 value) { return ((value & 0xFF00000000000000ULL) >> 56) | ((value & 0x00FF000000000000ULL) >> 40) | ((value & 0x0000FF0000000000ULL) >> 24) | diff --git a/src/ir_opt/constant_propagation_pass.cpp b/src/ir_opt/constant_propagation_pass.cpp index 1f91adc9..c726503f 100644 --- a/src/ir_opt/constant_propagation_pass.cpp +++ b/src/ir_opt/constant_propagation_pass.cpp @@ -138,13 +138,13 @@ void FoldByteReverse(IR::Inst& inst, Op op) { } if (op == Op::ByteReverseWord) { - const u32 result = Common::Swap32(static_cast(operand.GetImmediateAsU64())); + const u32 result = Common::SwapBytes32(static_cast(operand.GetImmediateAsU64())); inst.ReplaceUsesWith(IR::Value{result}); } else if (op == Op::ByteReverseHalf) { - const u16 result = Common::Swap16(static_cast(operand.GetImmediateAsU64())); + const u16 result = Common::SwapBytes16(static_cast(operand.GetImmediateAsU64())); inst.ReplaceUsesWith(IR::Value{result}); } else { - const u64 result = Common::Swap64(operand.GetImmediateAsU64()); + const u64 result = Common::SwapBytes64(operand.GetImmediateAsU64()); inst.ReplaceUsesWith(IR::Value{result}); } }