mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-17 04:24:37 +03:00
Fixed X86Internal::emitRegMove() to update the size of a memory operand when necessary
This commit is contained in:
@@ -21,7 +21,7 @@ ASMJIT_BEGIN_NAMESPACE
|
|||||||
namespace Support {
|
namespace Support {
|
||||||
//! Cast designed to cast between function and void* pointers.
|
//! Cast designed to cast between function and void* pointers.
|
||||||
template<typename Dst, typename Src>
|
template<typename Dst, typename Src>
|
||||||
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}
|
} // {Support}
|
||||||
|
|
||||||
#if defined(ASMJIT_NO_STDCXX)
|
#if defined(ASMJIT_NO_STDCXX)
|
||||||
@@ -342,9 +342,9 @@ namespace ByteOrder {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
static constexpr Func ptr_as_func(void* func) noexcept { return Support::ptr_cast_impl<Func, void*>(func); }
|
static inline Func ptr_as_func(void* func) noexcept { return Support::ptr_cast_impl<Func, void*>(func); }
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
static constexpr void* func_as_ptr(Func func) noexcept { return Support::ptr_cast_impl<void*, Func>(func); }
|
static inline void* func_as_ptr(Func func) noexcept { return Support::ptr_cast_impl<void*, Func>(func); }
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// [asmjit::DebugUtils]
|
// [asmjit::DebugUtils]
|
||||||
|
|||||||
@@ -824,6 +824,7 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter,
|
|||||||
|
|
||||||
uint32_t instId = Inst::kIdNone;
|
uint32_t instId = Inst::kIdNone;
|
||||||
uint32_t memFlags = 0;
|
uint32_t memFlags = 0;
|
||||||
|
uint32_t overrideMemSize = 0;
|
||||||
|
|
||||||
enum MemFlags : uint32_t {
|
enum MemFlags : uint32_t {
|
||||||
kDstMem = 0x1,
|
kDstMem = 0x1,
|
||||||
@@ -876,6 +877,7 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter,
|
|||||||
default: {
|
default: {
|
||||||
uint32_t elementTypeId = Type::baseOf(typeId);
|
uint32_t elementTypeId = Type::baseOf(typeId);
|
||||||
if (Type::isVec32(typeId) && memFlags) {
|
if (Type::isVec32(typeId) && memFlags) {
|
||||||
|
overrideMemSize = 4;
|
||||||
if (elementTypeId == Type::kIdF32)
|
if (elementTypeId == Type::kIdF32)
|
||||||
instId = avxEnabled ? Inst::kIdVmovss : Inst::kIdMovss;
|
instId = avxEnabled ? Inst::kIdVmovss : Inst::kIdMovss;
|
||||||
else
|
else
|
||||||
@@ -884,6 +886,7 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Type::isVec64(typeId) && memFlags) {
|
if (Type::isVec64(typeId) && memFlags) {
|
||||||
|
overrideMemSize = 8;
|
||||||
if (elementTypeId == Type::kIdF64)
|
if (elementTypeId == Type::kIdF64)
|
||||||
instId = avxEnabled ? Inst::kIdVmovsd : Inst::kIdMovsd;
|
instId = avxEnabled ? Inst::kIdVmovsd : Inst::kIdMovsd;
|
||||||
else
|
else
|
||||||
@@ -908,6 +911,11 @@ ASMJIT_FAVOR_SIZE Error X86Internal::emitRegMove(Emitter* emitter,
|
|||||||
if (!instId)
|
if (!instId)
|
||||||
return DebugUtils::errored(kErrorInvalidState);
|
return DebugUtils::errored(kErrorInvalidState);
|
||||||
|
|
||||||
|
if (overrideMemSize) {
|
||||||
|
if (dst.isMem()) dst.as<Mem>().setSize(overrideMemSize);
|
||||||
|
if (src.isMem()) src.as<Mem>().setSize(overrideMemSize);
|
||||||
|
}
|
||||||
|
|
||||||
emitter->setInlineComment(comment);
|
emitter->setInlineComment(comment);
|
||||||
return emitter->emit(instId, dst, src);
|
return emitter->emit(instId, dst, src);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
// CPU feature that may not be enabled.
|
||||||
if (rwInfo.rmFeature() && (flags & (RATiedReg::kUseRM | RATiedReg::kOutRM))) {
|
if (rwInfo.rmFeature() && (flags & (RATiedReg::kUseRM | RATiedReg::kOutRM))) {
|
||||||
flags &= ~(RATiedReg::kUseRM | RATiedReg::kOutRM);
|
flags &= ~(RATiedReg::kUseRM | RATiedReg::kOutRM);
|
||||||
|
|||||||
Reference in New Issue
Block a user