From 5d9e960794d83eadf1322301c62a22932a75ef1d Mon Sep 17 00:00:00 2001 From: kobalicek Date: Mon, 5 Aug 2019 23:54:50 +0200 Subject: [PATCH] Fixed X86Internal::emitRegMove() to update the size of a memory operand when necessary --- src/asmjit/core/globals.h | 6 +++--- src/asmjit/x86/x86internal.cpp | 8 ++++++++ src/asmjit/x86/x86rapass.cpp | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/asmjit/core/globals.h b/src/asmjit/core/globals.h index fff13a4..f03ede5 100644 --- a/src/asmjit/core/globals.h +++ b/src/asmjit/core/globals.h @@ -21,7 +21,7 @@ ASMJIT_BEGIN_NAMESPACE namespace Support { //! Cast designed to cast between function and void* pointers. template - static constexpr Dst ptr_cast_impl(Src p) noexcept { return (Dst)p; } + static inline Dst ptr_cast_impl(Src p) noexcept { return (Dst)p; } } // {Support} #if defined(ASMJIT_NO_STDCXX) @@ -342,9 +342,9 @@ namespace ByteOrder { // ============================================================================ template -static constexpr Func ptr_as_func(void* func) noexcept { return Support::ptr_cast_impl(func); } +static inline Func ptr_as_func(void* func) noexcept { return Support::ptr_cast_impl(func); } template -static constexpr void* func_as_ptr(Func func) noexcept { return Support::ptr_cast_impl(func); } +static inline void* func_as_ptr(Func func) noexcept { return Support::ptr_cast_impl(func); } // ============================================================================ // [asmjit::DebugUtils] diff --git a/src/asmjit/x86/x86internal.cpp b/src/asmjit/x86/x86internal.cpp index 6e7c16c..ca6a8fc 100644 --- a/src/asmjit/x86/x86internal.cpp +++ b/src/asmjit/x86/x86internal.cpp @@ -824,6 +824,7 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter, uint32_t instId = Inst::kIdNone; uint32_t memFlags = 0; + uint32_t overrideMemSize = 0; enum MemFlags : uint32_t { kDstMem = 0x1, @@ -876,6 +877,7 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter, default: { uint32_t elementTypeId = Type::baseOf(typeId); if (Type::isVec32(typeId) && memFlags) { + overrideMemSize = 4; if (elementTypeId == Type::kIdF32) instId = avxEnabled ? Inst::kIdVmovss : Inst::kIdMovss; else @@ -884,6 +886,7 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter, } if (Type::isVec64(typeId) && memFlags) { + overrideMemSize = 8; if (elementTypeId == Type::kIdF64) instId = avxEnabled ? Inst::kIdVmovsd : Inst::kIdMovsd; else @@ -908,6 +911,11 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter, if (!instId) return DebugUtils::errored(kErrorInvalidState); + if (overrideMemSize) { + if (dst.isMem()) dst.as().setSize(overrideMemSize); + if (src.isMem()) src.as().setSize(overrideMemSize); + } + emitter->setInlineComment(comment); return emitter->emit(instId, dst, src); } diff --git a/src/asmjit/x86/x86rapass.cpp b/src/asmjit/x86/x86rapass.cpp index 4af31c0..5e20a8e 100644 --- a/src/asmjit/x86/x86rapass.cpp +++ b/src/asmjit/x86/x86rapass.cpp @@ -175,7 +175,7 @@ Error X86RACFGBuilder::onInst(InstNode* inst, uint32_t& controlType, RAInstBuild } } - // Do not use RegMem flag if chaning Reg to Mem requires additional + // Do not use RegMem flag if changing Reg to Mem requires additional // CPU feature that may not be enabled. if (rwInfo.rmFeature() && (flags & (RATiedReg::kUseRM | RATiedReg::kOutRM))) { flags &= ~(RATiedReg::kUseRM | RATiedReg::kOutRM);