mirror of https://github.com/PCSX2/pcsx2.git
x86emitter: Remove unused classes
xAddressInfo was not being used xSmartJump was not being used and is incompatible with x86-64
This commit is contained in:
parent
096bb8bf74
commit
1a727febe9
|
@ -545,30 +545,6 @@ struct xRegisterEmpty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME This one is likely useless and superseeded by the future xRegister16or32or64
|
|
||||||
class xRegister16or32
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
const xRegisterInt &m_convtype;
|
|
||||||
|
|
||||||
public:
|
|
||||||
xRegister16or32(const xRegister32 &src)
|
|
||||||
: m_convtype(src)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
xRegister16or32(const xRegister16 &src)
|
|
||||||
: m_convtype(src)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
operator const xRegisterBase &() const { return m_convtype; }
|
|
||||||
|
|
||||||
const xRegisterInt *operator->() const
|
|
||||||
{
|
|
||||||
return &m_convtype;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class xRegister16or32or64
|
class xRegister16or32or64
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -720,73 +696,6 @@ public:
|
||||||
__fi void operator-=(sptr imm) { Add(-imm); }
|
__fi void operator-=(sptr imm) { Add(-imm); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// xAddressInfo
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
template <typename BaseType>
|
|
||||||
class xAddressInfo : public xAddressVoid
|
|
||||||
{
|
|
||||||
typedef xAddressVoid _parent;
|
|
||||||
|
|
||||||
public:
|
|
||||||
xAddressInfo(const xAddressReg &base, const xAddressReg &index, int factor = 1, sptr displacement = 0)
|
|
||||||
: _parent(base, index, factor, displacement)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*xAddressInfo( const xAddressVoid& src )
|
|
||||||
: _parent( src ) {}*/
|
|
||||||
|
|
||||||
explicit xAddressInfo(const xAddressReg &index, sptr displacement = 0)
|
|
||||||
: _parent(index, displacement)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit xAddressInfo(sptr displacement = 0)
|
|
||||||
: _parent(displacement)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static xAddressInfo<BaseType> FromIndexReg(const xAddressReg &index, int scale = 0, sptr displacement = 0);
|
|
||||||
|
|
||||||
public:
|
|
||||||
using _parent::operator+=;
|
|
||||||
using _parent::operator-=;
|
|
||||||
|
|
||||||
bool IsByteSizeDisp() const { return is_s8(Displacement); }
|
|
||||||
|
|
||||||
xAddressInfo<BaseType> &Add(sptr imm)
|
|
||||||
{
|
|
||||||
Displacement += imm;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
xAddressInfo<BaseType> &Add(const xAddressReg &src)
|
|
||||||
{
|
|
||||||
_parent::Add(src);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
xAddressInfo<BaseType> &Add(const xAddressInfo<BaseType> &src)
|
|
||||||
{
|
|
||||||
_parent::Add(src);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
__fi xAddressInfo<BaseType> operator+(const xAddressReg &right) const { return xAddressInfo(*this).Add(right); }
|
|
||||||
__fi xAddressInfo<BaseType> operator+(const xAddressInfo<BaseType> &right) const { return xAddressInfo(*this).Add(right); }
|
|
||||||
__fi xAddressInfo<BaseType> operator+(sptr imm) const { return xAddressInfo(*this).Add(imm); }
|
|
||||||
__fi xAddressInfo<BaseType> operator-(sptr imm) const { return xAddressInfo(*this).Add(-imm); }
|
|
||||||
__fi xAddressInfo<BaseType> operator+(const void *addr) const { return xAddressInfo(*this).Add((uptr)addr); }
|
|
||||||
|
|
||||||
__fi void operator+=(const xAddressInfo<BaseType> &right) { Add(right); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef xAddressInfo<u128> xAddress128;
|
|
||||||
typedef xAddressInfo<u64> xAddress64;
|
|
||||||
typedef xAddressInfo<u32> xAddress32;
|
|
||||||
typedef xAddressInfo<u16> xAddress16;
|
|
||||||
typedef xAddressInfo<u8> xAddress8;
|
|
||||||
|
|
||||||
static __fi xAddressVoid operator+(const void *addr, const xAddressVoid &right)
|
static __fi xAddressVoid operator+(const void *addr, const xAddressVoid &right)
|
||||||
{
|
{
|
||||||
return right + addr;
|
return right + addr;
|
||||||
|
@ -797,19 +706,6 @@ static __fi xAddressVoid operator+(sptr addr, const xAddressVoid &right)
|
||||||
return right + addr;
|
return right + addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename OperandType>
|
|
||||||
static __fi xAddressInfo<OperandType> operator+(const void *addr, const xAddressInfo<OperandType> &right)
|
|
||||||
{
|
|
||||||
//return xAddressInfo<OperandType>( (sptr)addr ).Add( reg );
|
|
||||||
return right + addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OperandType>
|
|
||||||
static __fi xAddressInfo<OperandType> operator+(sptr addr, const xAddressInfo<OperandType> &right)
|
|
||||||
{
|
|
||||||
return right + addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// xImmReg< typename xRegType >
|
// xImmReg< typename xRegType >
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -902,11 +798,6 @@ public:
|
||||||
{
|
{
|
||||||
_operandSize = sizeof(OperandType);
|
_operandSize = sizeof(OperandType);
|
||||||
}
|
}
|
||||||
explicit xIndirect(const xAddressInfo<OperandType> &src)
|
|
||||||
: _parent(src)
|
|
||||||
{
|
|
||||||
_operandSize = sizeof(OperandType);
|
|
||||||
}
|
|
||||||
xIndirect(xAddressReg base, xAddressReg index, int scale = 0, sptr displacement = 0)
|
xIndirect(xAddressReg base, xAddressReg index, int scale = 0, sptr displacement = 0)
|
||||||
: _parent(base, index, scale, displacement)
|
: _parent(base, index, scale, displacement)
|
||||||
{
|
{
|
||||||
|
@ -1018,122 +909,6 @@ extern const xAddressIndexer<xIndirect32> ptr32;
|
||||||
extern const xAddressIndexer<xIndirect16> ptr16;
|
extern const xAddressIndexer<xIndirect16> ptr16;
|
||||||
extern const xAddressIndexer<xIndirect8> ptr8;
|
extern const xAddressIndexer<xIndirect8> ptr8;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// xDirectOrIndirect
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// This utility class can represent either a direct (register) or indirect (memory address)
|
|
||||||
// source or destination operand. When supplied to an emitted instruction, the direct form
|
|
||||||
// is favored *if* it is not Empty (xEmptyReg). Otherwise the indirect form is used.
|
|
||||||
//
|
|
||||||
#if 0
|
|
||||||
template< typename xRegType, typename xSibType >
|
|
||||||
class xDirectOrIndirect
|
|
||||||
{
|
|
||||||
xRegType m_RegDirect;
|
|
||||||
xSibType m_MemIndirect;
|
|
||||||
|
|
||||||
public:
|
|
||||||
xDirectOrIndirect() :
|
|
||||||
m_RegDirect(), m_MemIndirect( 0 ) {}
|
|
||||||
|
|
||||||
xDirectOrIndirect( const xRegType& srcreg ) :
|
|
||||||
m_RegDirect( srcreg ), m_MemIndirect( 0 ) {}
|
|
||||||
|
|
||||||
explicit xDirectOrIndirect( const xSibType& srcmem ) :
|
|
||||||
m_RegDirect(), m_MemIndirect( srcmem ) {}
|
|
||||||
|
|
||||||
const xRegType& GetReg() const { return m_RegDirect; }
|
|
||||||
const xSibType& GetMem() const { return m_MemIndirect; }
|
|
||||||
bool IsDirect() const { return !m_RegDirect.IsEmpty(); }
|
|
||||||
bool IsIndirect() const { return m_RegDirect.IsEmpty(); }
|
|
||||||
|
|
||||||
bool operator==( const xDirectOrIndirect& src ) const
|
|
||||||
{
|
|
||||||
return IsDirect() ?
|
|
||||||
(m_RegDirect == src.m_RegDirect) :
|
|
||||||
(m_MemIndirect == src.m_MemIndirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=( const xDirectOrIndirect& src ) const
|
|
||||||
{
|
|
||||||
return !operator==( src );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==( const xRegType& src ) const { return (m_RegDirect == src); }
|
|
||||||
bool operator!=( const xRegType& src ) const { return (m_RegDirect != src); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef xDirectOrIndirect<xRegister8,xIndirect8> xDirectOrIndirect8;
|
|
||||||
typedef xDirectOrIndirect<xRegister16,xIndirect16> xDirectOrIndirect16;
|
|
||||||
typedef xDirectOrIndirect<xRegister32,xIndirect32> xDirectOrIndirect32;
|
|
||||||
typedef xDirectOrIndirect<xRegisterSSE,xIndirect128> xDirectOrIndirect128;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// xSmartJump
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// This class provides an interface for generating forward-based j8's or j32's "smartly"
|
|
||||||
// as per the measured displacement distance. If the displacement is a valid s8, then
|
|
||||||
// a j8 is inserted, else a j32.
|
|
||||||
//
|
|
||||||
// Note: This class is inherently unsafe, and so it's recommended to use xForwardJump8/32
|
|
||||||
// whenever it is known that the jump destination is (or is not) short. Only use
|
|
||||||
// xSmartJump in cases where it's unknown what jump encoding will be ideal.
|
|
||||||
//
|
|
||||||
// Important: Use this tool with caution! xSmartJump cannot be used in cases where jump
|
|
||||||
// targets overlap, since the writeback of the second target will alter the position of
|
|
||||||
// the first target (which breaks the relative addressing). To assist in avoiding such
|
|
||||||
// errors, xSmartJump works based on C++ block scope, where the destruction of the
|
|
||||||
// xSmartJump object (invoked by a '}') signals the target of the jump. Example:
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// iCMP( EAX, ECX );
|
|
||||||
// xSmartJump jumpTo( Jcc_Above );
|
|
||||||
// [... conditional code ...]
|
|
||||||
// } // smartjump targets this spot.
|
|
||||||
//
|
|
||||||
// No code inside the scope can attempt to jump outside the scoped block (unless the jump
|
|
||||||
// uses an immediate addressing method, such as Register or Mod/RM forms of JMP/CALL).
|
|
||||||
// Multiple SmartJumps can be safely nested inside scopes, as long as they are properly
|
|
||||||
// scoped themselves.
|
|
||||||
//
|
|
||||||
// Performance Analysis: j8's use 4 less byes per opcode, and thus can provide minor
|
|
||||||
// speed benefits in the form of L1/L2 cache clutter, on any CPU. They're also notably
|
|
||||||
// faster on P4's, and mildly faster on AMDs. (Core2's and i7's don't care)
|
|
||||||
//
|
|
||||||
class xSmartJump
|
|
||||||
{
|
|
||||||
DeclareNoncopyableObject(xSmartJump);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
u8 *m_baseptr; // base address of the instruction (passed to the instruction emitter)
|
|
||||||
JccComparisonType m_cc; // comparison type of the instruction
|
|
||||||
|
|
||||||
public:
|
|
||||||
int GetMaxInstructionSize() const
|
|
||||||
{
|
|
||||||
pxAssert(m_cc != Jcc_Unknown);
|
|
||||||
return (m_cc == Jcc_Unconditional) ? 5 : 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
JccComparisonType GetCondition() const { return m_cc; }
|
|
||||||
virtual ~xSmartJump();
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// ccType - Comparison type to be written back to the jump instruction position.
|
|
||||||
//
|
|
||||||
xSmartJump(JccComparisonType ccType)
|
|
||||||
{
|
|
||||||
pxAssert(ccType != Jcc_Unknown);
|
|
||||||
m_baseptr = xGetPtr();
|
|
||||||
m_cc = ccType;
|
|
||||||
xAdvancePtr(GetMaxInstructionSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void SetTarget();
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// xForwardJump
|
// xForwardJump
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -128,35 +128,6 @@ void xImpl_FastCall::operator()(const xIndirectNative &f, const xRegisterLong &a
|
||||||
|
|
||||||
const xImpl_FastCall xFastCall = {};
|
const xImpl_FastCall xFastCall = {};
|
||||||
|
|
||||||
void xSmartJump::SetTarget()
|
|
||||||
{
|
|
||||||
u8 *target = xGetPtr();
|
|
||||||
if (m_baseptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xSetPtr(m_baseptr);
|
|
||||||
u8 *const saveme = m_baseptr + GetMaxInstructionSize();
|
|
||||||
xJccKnownTarget(m_cc, target, true);
|
|
||||||
|
|
||||||
// Copy recompiled data inward if the jump instruction didn't fill the
|
|
||||||
// alloted buffer (means that we optimized things to a j8!)
|
|
||||||
|
|
||||||
const int spacer = (sptr)saveme - (sptr)xGetPtr();
|
|
||||||
if (spacer != 0) {
|
|
||||||
u8 *destpos = xGetPtr();
|
|
||||||
const int copylen = (sptr)target - (sptr)saveme;
|
|
||||||
|
|
||||||
memcpy(destpos, saveme, copylen);
|
|
||||||
xSetPtr(target - spacer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xSmartJump::~xSmartJump()
|
|
||||||
{
|
|
||||||
SetTarget();
|
|
||||||
m_baseptr = NULL; // just in case (sometimes helps in debugging too)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Emits a 32 bit jump, and returns a pointer to the 32 bit displacement.
|
// Emits a 32 bit jump, and returns a pointer to the 32 bit displacement.
|
||||||
// (displacements should be assigned relative to the end of the jump instruction,
|
// (displacements should be assigned relative to the end of the jump instruction,
|
||||||
|
|
Loading…
Reference in New Issue