x86emitter:move: factorize type and extend it to 64 bits

It's still missing the REX prefix support
This commit is contained in:
Gregory Hainaut 2016-01-16 21:44:32 +01:00
parent 41f509873d
commit e2602b3967
2 changed files with 23 additions and 50 deletions

View File

@ -29,10 +29,7 @@ struct xImpl_Mov
{
xImpl_Mov() {} // Satisfy GCC's whims.
void operator()( const xRegister8& to, const xRegister8& from ) const;
void operator()( const xRegister16& to, const xRegister16& from ) const;
void operator()( const xRegister32& to, const xRegister32& from ) const;
void operator()( const xRegisterInt& to, const xRegisterInt& from ) const;
void operator()( const xIndirectVoid& dest, const xRegisterInt& from ) const;
void operator()( const xRegisterInt& to, const xIndirectVoid& src ) const;
void operator()( const xIndirect32orLess& dest, int imm ) const;
@ -88,12 +85,8 @@ struct xImpl_Mov
struct xImpl_CMov
{
JccComparisonType ccType;
void operator()( const xRegister32& to, const xRegister32& from ) const;
void operator()( const xRegister32& to, const xIndirectVoid& sibsrc ) const;
void operator()( const xRegister16& to, const xRegister16& from ) const;
void operator()( const xRegister16& to, const xIndirectVoid& sibsrc ) const;
void operator()( const xRegister16or32or64& to, const xRegister16or32or64& from ) const;
void operator()( const xRegister16or32or64& to, const xIndirectVoid& sibsrc ) const;
//void operator()( const xDirectOrIndirect32& to, const xDirectOrIndirect32& from );
//void operator()( const xDirectOrIndirect16& to, const xDirectOrIndirect16& from ) const;
@ -119,10 +112,10 @@ struct xImpl_MovExtend
{
bool SignExtend;
void operator()( const xRegister16or32& to, const xRegister8& from ) const;
void operator()( const xRegister16or32& to, const xIndirect8& sibsrc ) const;
void operator()( const xRegister32& to, const xRegister16& from ) const;
void operator()( const xRegister32& to, const xIndirect16& sibsrc ) const;
void operator()( const xRegister16or32or64& to, const xRegister8& from ) const;
void operator()( const xRegister16or32or64& to, const xIndirect8& sibsrc ) const;
void operator()( const xRegister32or64& to, const xRegister16& from ) const;
void operator()( const xRegister32or64& to, const xIndirect16& sibsrc ) const;
//void operator()( const xRegister32& to, const xDirectOrIndirect16& src ) const;
//void operator()( const xRegister16or32& to, const xDirectOrIndirect8& src ) const;

View File

@ -45,26 +45,10 @@ void _xMovRtoR( const xRegisterInt& to, const xRegisterInt& from )
EmitSibMagic( from, to );
}
void xImpl_Mov::operator()( const xRegister8& to, const xRegister8& from ) const
void xImpl_Mov::operator()( const xRegisterInt& to, const xRegisterInt& from ) const
{
if( to == from ) return; // ignore redundant MOVs.
xWrite8( 0x88 );
EmitSibMagic( from, to );
}
void xImpl_Mov::operator()( const xRegister16& to, const xRegister16& from ) const
{
if( to == from ) return; // ignore redundant MOVs.
from.prefix16();
xWrite8( 0x89 );
EmitSibMagic( from, to );
}
void xImpl_Mov::operator()( const xRegister32& to, const xRegister32& from ) const
{
if( to == from ) return; // ignore redundant MOVs.
xWrite8( 0x89 );
EmitSibMagic( from, to );
// FIXME WTF?
_xMovRtoR(to, from);
}
void xImpl_Mov::operator()( const xIndirectVoid& dest, const xRegisterInt& from ) const
@ -142,21 +126,17 @@ const xImpl_Mov xMOV;
#define EbpAssert()
void xCMOV( JccComparisonType ccType, const xRegister32& to, const xRegister32& from ) { ccSane(); xOpWrite0F( 0x40 | ccType, to, from ); }
void xCMOV( JccComparisonType ccType, const xRegister32& to, const xIndirectVoid& sibsrc ) { ccSane(); xOpWrite0F( 0x40 | ccType, to, sibsrc ); }
//void xCMOV( JccComparisonType ccType, const xDirectOrIndirect32& to, const xDirectOrIndirect32& from ) const { ccSane(); _DoI_helpermess( *this, to, from ); } // too.. lazy.. to fix.
void xCMOV( JccComparisonType ccType, const xRegister16& to, const xRegister16& from ) { ccSane(); xOpWrite0F( 0x66, 0x40 | ccType, to, from ); }
void xCMOV( JccComparisonType ccType, const xRegister16& to, const xIndirectVoid& sibsrc ) { ccSane(); xOpWrite0F( 0x66, 0x40 | ccType, to, sibsrc ); }
//void xCMOV( JccComparisonType ccType, const xDirectOrIndirect16& to, const xDirectOrIndirect16& from ) const { ccSane(); _DoI_helpermess( *this, to, from ); }
void xImpl_CMov::operator()( const xRegister16or32or64& to, const xRegister16or32or64& from ) const {
pxAssert( to->GetOperandSize() == from->GetOperandSize() );
ccSane();
xOpWrite0F( to->GetPrefix16(), 0x40 | ccType, to, from );
}
void xSET( JccComparisonType ccType, const xRegister8& to ) { ccSane(); xOpWrite0F( 0x90 | ccType, 0, to ); }
void xSET( JccComparisonType ccType, const xIndirect8& dest ) { ccSane(); xOpWrite0F( 0x90 | ccType, 0, dest ); }
void xImpl_CMov::operator()( const xRegister32& to, const xRegister32& from ) const { ccSane(); xOpWrite0F( 0x40 | ccType, to, from ); }
void xImpl_CMov::operator()( const xRegister32& to, const xIndirectVoid& sibsrc ) const { ccSane(); xOpWrite0F( 0x40 | ccType, to, sibsrc ); }
void xImpl_CMov::operator()( const xRegister16& to, const xRegister16& from ) const { ccSane(); xOpWrite0F( 0x66, 0x40 | ccType, to, from ); }
void xImpl_CMov::operator()( const xRegister16& to, const xIndirectVoid& sibsrc ) const { ccSane(); xOpWrite0F( 0x66, 0x40 | ccType, to, sibsrc ); }
void xImpl_CMov::operator()( const xRegister16or32or64& to, const xIndirectVoid& sibsrc ) const {
ccSane();
xOpWrite0F( to->GetPrefix16(), 0x40 | ccType, to, sibsrc );
}
//void xImpl_CMov::operator()( const xDirectOrIndirect32& to, const xDirectOrIndirect32& from ) const { ccSane(); _DoI_helpermess( *this, to, from ); }
//void xImpl_CMov::operator()( const xDirectOrIndirect16& to, const xDirectOrIndirect16& from ) const { ccSane(); _DoI_helpermess( *this, to, from ); }
@ -165,7 +145,7 @@ void xImpl_Set::operator()( const xRegister8& to ) const { ccSane(); xOpWrite
void xImpl_Set::operator()( const xIndirect8& dest ) const { ccSane(); xOpWrite0F( 0x90 | ccType, 0, dest ); }
//void xImpl_Set::operator()( const xDirectOrIndirect8& dest ) const { ccSane(); _DoI_helpermess( *this, dest ); }
void xImpl_MovExtend::operator()( const xRegister16or32& to, const xRegister8& from ) const
void xImpl_MovExtend::operator()( const xRegister16or32or64& to, const xRegister8& from ) const
{
EbpAssert();
xOpWrite0F(
@ -175,7 +155,7 @@ void xImpl_MovExtend::operator()( const xRegister16or32& to, const xRegister8& f
);
}
void xImpl_MovExtend::operator()( const xRegister16or32& to, const xIndirect8& sibsrc ) const
void xImpl_MovExtend::operator()( const xRegister16or32or64& to, const xIndirect8& sibsrc ) const
{
EbpAssert();
xOpWrite0F(
@ -185,13 +165,13 @@ void xImpl_MovExtend::operator()( const xRegister16or32& to, const xIndirect8& s
);
}
void xImpl_MovExtend::operator()( const xRegister32& to, const xRegister16& from ) const
void xImpl_MovExtend::operator()( const xRegister32or64& to, const xRegister16& from ) const
{
EbpAssert();
xOpWrite0F( SignExtend ? 0xbf : 0xb7, to, from );
}
void xImpl_MovExtend::operator()( const xRegister32& to, const xIndirect16& sibsrc ) const
void xImpl_MovExtend::operator()( const xRegister32or64& to, const xIndirect16& sibsrc ) const
{
EbpAssert();
xOpWrite0F( SignExtend ? 0xbf : 0xb7, to, sibsrc );