diff --git a/src/backend/A64/emitter/a64_emitter.cpp b/src/backend/A64/emitter/a64_emitter.cpp index 028b0a76..c387b37a 100644 --- a/src/backend/A64/emitter/a64_emitter.cpp +++ b/src/backend/A64/emitter/a64_emitter.cpp @@ -276,6 +276,31 @@ bool FPImm8FromFloat(float value, u8* imm_out) { return true; } + +static constexpr bool IsInRangeImm19(s64 distance) { + return (distance >= -0x40000 && distance <= 0x3FFFF); +} + +static constexpr bool IsInRangeImm14(s64 distance) { + return (distance >= -0x2000 && distance <= 0x1FFF); +} + +static constexpr bool IsInRangeImm26(s64 distance) { + return (distance >= -0x2000000 && distance <= 0x1FFFFFF); +} + +static constexpr u32 MaskImm19(s64 distance) { + return distance & 0x7FFFF; +} + +static constexpr u32 MaskImm14(s64 distance) { + return distance & 0x3FFF; +} + +static constexpr u32 MaskImm26(s64 distance) { + return distance & 0x3FFFFFF; +} + } // Anonymous namespace void ARM64XEmitter::SetCodePtrUnsafe(u8* ptr) { @@ -831,30 +856,6 @@ void ARM64XEmitter::EncodeLoadStoreUnscaled(u32 size, u32 op, ARM64Reg Rt, ARM64 Write32((size << 30) | (0b111 << 27) | (op << 22) | ((imm & 0x1FF) << 12) | (Rn << 5) | Rt); } -static constexpr bool IsInRangeImm19(s64 distance) { - return (distance >= -0x40000 && distance <= 0x3FFFF); -} - -static constexpr bool IsInRangeImm14(s64 distance) { - return (distance >= -0x2000 && distance <= 0x1FFF); -} - -static constexpr bool IsInRangeImm26(s64 distance) { - return (distance >= -0x2000000 && distance <= 0x1FFFFFF); -} - -static constexpr u32 MaskImm19(s64 distance) { - return distance & 0x7FFFF; -} - -static constexpr u32 MaskImm14(s64 distance) { - return distance & 0x3FFF; -} - -static constexpr u32 MaskImm26(s64 distance) { - return distance & 0x3FFFFFF; -} - // FixupBranch branching void ARM64XEmitter::SetJumpTarget(FixupBranch const& branch) { bool Not = false;