Remove the rest of x86_32 support from Common.
This commit is contained in:
parent
a70fad4dcb
commit
0c24e1dcf2
|
@ -148,14 +148,11 @@ inline u64 _rotr64(u64 x, unsigned int shift){
|
|||
#define fstat64 _fstat64
|
||||
#define fileno _fileno
|
||||
|
||||
#if _M_X86_32
|
||||
#define Crash() {__asm int 3}
|
||||
#else
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllimport) void __stdcall DebugBreak(void);
|
||||
}
|
||||
#define Crash() {DebugBreak();}
|
||||
#endif // M_IX86
|
||||
#define Crash() {DebugBreak();}
|
||||
#endif // WIN32 ndef
|
||||
|
||||
// Generic function to get last error message.
|
||||
|
|
|
@ -152,14 +152,8 @@ static BOOL GetFunctionInfoFromAddresses( ULONG fnAddress, ULONG stackAddress, L
|
|||
_tcscpy( lpszSymbol, _T("?") );
|
||||
|
||||
// Get symbol info for IP
|
||||
#if _M_X86_32
|
||||
DWORD dwDisp = 0;
|
||||
if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, &dwDisp, pSym ) )
|
||||
#else
|
||||
//makes it compile but hell im not sure if this works...
|
||||
DWORD64 dwDisp = 0;
|
||||
if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, (PDWORD64)&dwDisp, pSym ) )
|
||||
#endif
|
||||
{
|
||||
// Make the symbol readable for humans
|
||||
UnDecorateSymbolName( pSym->Name, lpszNonUnicodeUnDSymbol, BUFFERSIZE,
|
||||
|
@ -313,15 +307,9 @@ void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
|
|||
}
|
||||
|
||||
::ZeroMemory( &callStack, sizeof(callStack) );
|
||||
#if _M_X86_32
|
||||
callStack.AddrPC.Offset = context.Eip;
|
||||
callStack.AddrStack.Offset = context.Esp;
|
||||
callStack.AddrFrame.Offset = context.Ebp;
|
||||
#else
|
||||
callStack.AddrPC.Offset = context.Rip;
|
||||
callStack.AddrStack.Offset = context.Rsp;
|
||||
callStack.AddrFrame.Offset = context.Rbp;
|
||||
#endif
|
||||
callStack.AddrPC.Mode = AddrModeFlat;
|
||||
callStack.AddrStack.Mode = AddrModeFlat;
|
||||
callStack.AddrFrame.Mode = AddrModeFlat;
|
||||
|
|
|
@ -40,39 +40,25 @@
|
|||
#define USE_RVALUE_REFERENCES
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && _M_X86_64
|
||||
#define USE_CONDITION_VARIABLES
|
||||
#elif defined(_WIN32)
|
||||
#define USE_EVENTS
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
class condition_variable
|
||||
{
|
||||
#if defined(_WIN32) && defined(USE_CONDITION_VARIABLES)
|
||||
#if defined(_WIN32)
|
||||
typedef CONDITION_VARIABLE native_type;
|
||||
#elif defined(_WIN32)
|
||||
typedef HANDLE native_type;
|
||||
#else
|
||||
typedef pthread_cond_t native_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef USE_EVENTS
|
||||
typedef native_type native_handle_type;
|
||||
#else
|
||||
typedef native_type* native_handle_type;
|
||||
#endif
|
||||
|
||||
condition_variable()
|
||||
{
|
||||
#if defined(_WIN32) && defined(USE_CONDITION_VARIABLES)
|
||||
#if defined(_WIN32)
|
||||
InitializeConditionVariable(&m_handle);
|
||||
#elif defined(_WIN32)
|
||||
m_handle = CreateEvent(nullptr, false, false, nullptr);
|
||||
#else
|
||||
pthread_cond_init(&m_handle, nullptr);
|
||||
#endif
|
||||
|
@ -80,9 +66,7 @@ public:
|
|||
|
||||
~condition_variable()
|
||||
{
|
||||
#if defined(_WIN32) && !defined(USE_CONDITION_VARIABLES)
|
||||
CloseHandle(m_handle);
|
||||
#elif !defined(_WIN32)
|
||||
#ifndef _WIN32
|
||||
pthread_cond_destroy(&m_handle);
|
||||
#endif
|
||||
}
|
||||
|
@ -92,10 +76,8 @@ public:
|
|||
|
||||
void notify_one()
|
||||
{
|
||||
#if defined(_WIN32) && defined(USE_CONDITION_VARIABLES)
|
||||
#if defined(_WIN32)
|
||||
WakeConditionVariable(&m_handle);
|
||||
#elif defined(_WIN32)
|
||||
SetEvent(m_handle);
|
||||
#else
|
||||
pthread_cond_signal(&m_handle);
|
||||
#endif
|
||||
|
@ -103,11 +85,8 @@ public:
|
|||
|
||||
void notify_all()
|
||||
{
|
||||
#if defined(_WIN32) && defined(USE_CONDITION_VARIABLES)
|
||||
#if defined(_WIN32)
|
||||
WakeAllConditionVariable(&m_handle);
|
||||
#elif defined(_WIN32)
|
||||
// TODO: broken
|
||||
SetEvent(m_handle);
|
||||
#else
|
||||
pthread_cond_broadcast(&m_handle);
|
||||
#endif
|
||||
|
@ -116,16 +95,7 @@ public:
|
|||
void wait(unique_lock<mutex>& lock)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_SRWLOCKS
|
||||
SleepConditionVariableSRW(&m_handle, lock.mutex()->native_handle(), INFINITE, 0);
|
||||
#elif defined(USE_CONDITION_VARIABLES)
|
||||
SleepConditionVariableCS(&m_handle, lock.mutex()->native_handle(), INFINITE);
|
||||
#else
|
||||
// TODO: broken, the unlock and wait need to be atomic
|
||||
lock.unlock();
|
||||
WaitForSingleObject(m_handle, INFINITE);
|
||||
lock.lock();
|
||||
#endif
|
||||
#else
|
||||
pthread_cond_wait(&m_handle, lock.mutex()->native_handle());
|
||||
#endif
|
||||
|
@ -158,11 +128,7 @@ public:
|
|||
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
#ifdef USE_EVENTS
|
||||
return m_handle;
|
||||
#else
|
||||
return &m_handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
#define USE_RVALUE_REFERENCES
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && _M_X86_64
|
||||
#define USE_SRWLOCKS
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
|
@ -122,7 +118,6 @@ private:
|
|||
native_type m_handle;
|
||||
};
|
||||
|
||||
#if !defined(_WIN32) || defined(USE_SRWLOCKS)
|
||||
|
||||
class mutex
|
||||
{
|
||||
|
@ -193,11 +188,6 @@ private:
|
|||
native_type m_handle;
|
||||
};
|
||||
|
||||
#else
|
||||
typedef recursive_mutex mutex; // just use CriticalSections
|
||||
|
||||
#endif
|
||||
|
||||
enum defer_lock_t { defer_lock };
|
||||
enum try_to_lock_t { try_to_lock };
|
||||
enum adopt_lock_t { adopt_lock };
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#if defined(_WIN32) && defined(_M_X86_64)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <math.h>
|
||||
#include <Windows.h>
|
||||
|
|
|
@ -11,26 +11,7 @@ using namespace Gen;
|
|||
// Shared code between Win64 and Unix64
|
||||
|
||||
unsigned int XEmitter::ABI_GetAlignedFrameSize(unsigned int frameSize, bool noProlog) {
|
||||
// On platforms other than Windows 32-bit: At the beginning of a function,
|
||||
// the stack pointer is 4/8 bytes less than a multiple of 16; however, the
|
||||
// function prolog immediately subtracts an appropriate amount to align
|
||||
// it, so no alignment is required around a call.
|
||||
// In the functions generated by ThunkManager::ProtectFunction and some
|
||||
// others, we add the necessary subtraction (and 0x20 bytes shadow space
|
||||
// for Win64) into this rather than having a separate prolog.
|
||||
// On Windows 32-bit, the required alignment is only 4 bytes, so we just
|
||||
// ensure that the frame size isn't misaligned.
|
||||
#if _M_X86_64
|
||||
// expect frameSize == 0
|
||||
frameSize = noProlog ? 0x28 : 0;
|
||||
#elif defined(_WIN32)
|
||||
frameSize = (frameSize + 3) & -4;
|
||||
#else
|
||||
unsigned int existingAlignment = noProlog ? 0xc : 0;
|
||||
frameSize -= existingAlignment;
|
||||
frameSize = (frameSize + 15) & -16;
|
||||
frameSize += existingAlignment;
|
||||
#endif
|
||||
return frameSize;
|
||||
}
|
||||
|
||||
|
@ -38,35 +19,22 @@ void XEmitter::ABI_AlignStack(unsigned int frameSize, bool noProlog) {
|
|||
unsigned int fillSize =
|
||||
ABI_GetAlignedFrameSize(frameSize, noProlog) - frameSize;
|
||||
if (fillSize != 0) {
|
||||
#if _M_X86_64
|
||||
SUB(64, R(RSP), Imm8(fillSize));
|
||||
#else
|
||||
SUB(32, R(ESP), Imm8(fillSize));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void XEmitter::ABI_RestoreStack(unsigned int frameSize, bool noProlog) {
|
||||
unsigned int alignedSize = ABI_GetAlignedFrameSize(frameSize, noProlog);
|
||||
if (alignedSize != 0) {
|
||||
#if _M_X86_64
|
||||
ADD(64, R(RSP), Imm8(alignedSize));
|
||||
#else
|
||||
ADD(32, R(ESP), Imm8(alignedSize));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void XEmitter::ABI_PushRegistersAndAdjustStack(u32 mask, bool noProlog)
|
||||
{
|
||||
int regSize =
|
||||
#if _M_X86_64
|
||||
8;
|
||||
#else
|
||||
4;
|
||||
#endif
|
||||
int regSize = 8;
|
||||
int shadow = 0;
|
||||
#if defined(_WIN32) && _M_X86_64
|
||||
#if defined(_WIN32)
|
||||
shadow = 0x20;
|
||||
#endif
|
||||
int count = 0;
|
||||
|
@ -100,14 +68,9 @@ void XEmitter::ABI_PushRegistersAndAdjustStack(u32 mask, bool noProlog)
|
|||
|
||||
void XEmitter::ABI_PopRegistersAndAdjustStack(u32 mask, bool noProlog)
|
||||
{
|
||||
int regSize =
|
||||
#if _M_X86_64
|
||||
8;
|
||||
#else
|
||||
4;
|
||||
#endif
|
||||
int regSize = 8;
|
||||
int size = 0;
|
||||
#if defined(_WIN32) && _M_X86_64
|
||||
#if defined(_WIN32)
|
||||
size += 0x20;
|
||||
#endif
|
||||
for (int x = 0; x < 16; x++)
|
||||
|
@ -137,152 +100,6 @@ void XEmitter::ABI_PopRegistersAndAdjustStack(u32 mask, bool noProlog)
|
|||
}
|
||||
}
|
||||
|
||||
#if _M_X86_32 // All32
|
||||
|
||||
// Shared code between Win32 and Unix32
|
||||
void XEmitter::ABI_CallFunction(void *func) {
|
||||
ABI_AlignStack(0);
|
||||
CALL(func);
|
||||
ABI_RestoreStack(0);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
|
||||
ABI_AlignStack(1 * 2);
|
||||
PUSH(16, Imm16(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(1 * 2);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionCC16(void *func, u32 param1, u16 param2) {
|
||||
ABI_AlignStack(1 * 2 + 1 * 4);
|
||||
PUSH(16, Imm16(param2));
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(1 * 2 + 1 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {
|
||||
ABI_AlignStack(1 * 4);
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(1 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
|
||||
ABI_AlignStack(2 * 4);
|
||||
PUSH(32, Imm32(param2));
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(2 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionCP(void *func, u32 param1, void *param2) {
|
||||
ABI_AlignStack(2 * 4);
|
||||
PUSH(32, Imm32((u32)param2));
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(2 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param3) {
|
||||
ABI_AlignStack(3 * 4);
|
||||
PUSH(32, Imm32(param3));
|
||||
PUSH(32, Imm32(param2));
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(3 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *param3) {
|
||||
ABI_AlignStack(3 * 4);
|
||||
PUSH(32, Imm32((u32)param3));
|
||||
PUSH(32, Imm32(param2));
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(3 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionCCCP(void *func, u32 param1, u32 param2,u32 param3, void *param4) {
|
||||
ABI_AlignStack(4 * 4);
|
||||
PUSH(32, Imm32((u32)param4));
|
||||
PUSH(32, Imm32(param3));
|
||||
PUSH(32, Imm32(param2));
|
||||
PUSH(32, Imm32(param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(4 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionPC(void *func, void *param1, u32 param2) {
|
||||
ABI_AlignStack(2 * 4);
|
||||
PUSH(32, Imm32(param2));
|
||||
PUSH(32, Imm32((u32)param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(2 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionPPC(void *func, void *param1, void *param2,u32 param3) {
|
||||
ABI_AlignStack(3 * 4);
|
||||
PUSH(32, Imm32(param3));
|
||||
PUSH(32, Imm32((u32)param2));
|
||||
PUSH(32, Imm32((u32)param1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(3 * 4);
|
||||
}
|
||||
|
||||
// Pass a register as a parameter.
|
||||
void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) {
|
||||
ABI_AlignStack(1 * 4);
|
||||
PUSH(32, R(reg1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(1 * 4);
|
||||
}
|
||||
|
||||
// Pass two registers as parameters.
|
||||
void XEmitter::ABI_CallFunctionRR(void *func, Gen::X64Reg reg1, Gen::X64Reg reg2, bool noProlog)
|
||||
{
|
||||
ABI_AlignStack(2 * 4, noProlog);
|
||||
PUSH(32, R(reg2));
|
||||
PUSH(32, R(reg1));
|
||||
CALL(func);
|
||||
ABI_RestoreStack(2 * 4, noProlog);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionAC(void *func, const Gen::OpArg &arg1, u32 param2)
|
||||
{
|
||||
ABI_AlignStack(2 * 4);
|
||||
PUSH(32, Imm32(param2));
|
||||
PUSH(32, arg1);
|
||||
CALL(func);
|
||||
ABI_RestoreStack(2 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_CallFunctionA(void *func, const Gen::OpArg &arg1)
|
||||
{
|
||||
ABI_AlignStack(1 * 4);
|
||||
PUSH(32, arg1);
|
||||
CALL(func);
|
||||
ABI_RestoreStack(1 * 4);
|
||||
}
|
||||
|
||||
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
|
||||
PUSH(EBP);
|
||||
MOV(32, R(EBP), R(ESP));
|
||||
PUSH(EBX);
|
||||
PUSH(ESI);
|
||||
PUSH(EDI);
|
||||
SUB(32, R(ESP), Imm8(0xc));
|
||||
}
|
||||
|
||||
void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
||||
ADD(32, R(ESP), Imm8(0xc));
|
||||
POP(EDI);
|
||||
POP(ESI);
|
||||
POP(EBX);
|
||||
POP(EBP);
|
||||
}
|
||||
|
||||
#else //64bit
|
||||
|
||||
// Common functions
|
||||
void XEmitter::ABI_CallFunction(void *func) {
|
||||
ABI_AlignStack(0);
|
||||
|
@ -643,6 +460,3 @@ void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
|||
|
||||
#endif // WIN32
|
||||
|
||||
#endif // 32bit
|
||||
|
||||
|
||||
|
|
|
@ -6,17 +6,9 @@
|
|||
|
||||
#include "Common/x64Emitter.h"
|
||||
|
||||
// x86/x64 ABI:s, and helpers to help follow them when JIT-ing code.
|
||||
// x64 ABI:s, and helpers to help follow them when JIT-ing code.
|
||||
// All convensions return values in EAX (+ possibly EDX).
|
||||
|
||||
// Linux 32-bit, Windows 32-bit (cdecl, System V):
|
||||
// * Caller pushes left to right
|
||||
// * Caller fixes stack after call
|
||||
// * function subtract from stack for local storage only.
|
||||
// Scratch: EAX ECX EDX
|
||||
// Callee-save: EBX ESI EDI EBP
|
||||
// Parameters: -
|
||||
|
||||
// Windows 64-bit
|
||||
// * 4-reg "fastcall" variant, very new-skool stack handling
|
||||
// * Callee moves stack pointer, to make room for shadow regs for the biggest function _it itself calls_
|
||||
|
@ -31,22 +23,6 @@
|
|||
// Callee-save: RBX RBP R12 R13 R14 R15
|
||||
// Parameters: RDI RSI RDX RCX R8 R9
|
||||
|
||||
#if _M_X86_32 // 32 bit calling convention, shared by all
|
||||
|
||||
// 32-bit don't pass parameters in regs, but these are convenient to have anyway when we have to
|
||||
// choose regs to put stuff in.
|
||||
#define ABI_PARAM1 RCX
|
||||
#define ABI_PARAM2 RDX
|
||||
|
||||
// There are no ABI_PARAM* here, since args are pushed.
|
||||
// 32-bit bog standard cdecl, shared between linux and windows
|
||||
// MacOSX 32-bit is same as System V with a few exceptions that we probably don't care much about.
|
||||
|
||||
#define ABI_ALL_CALLEE_SAVED ((1 << EAX) | (1 << ECX) | (1 << EDX) | \
|
||||
0xff00 /* xmm0..7 */)
|
||||
|
||||
#else // 64 bit calling convention
|
||||
|
||||
#ifdef _WIN32 // 64-bit Windows - the really exotic calling convention
|
||||
|
||||
#define ABI_PARAM1 RCX
|
||||
|
@ -74,4 +50,3 @@
|
|||
|
||||
#endif // WIN32
|
||||
|
||||
#endif // X86
|
||||
|
|
|
@ -90,22 +90,12 @@ CPUInfo::CPUInfo() {
|
|||
void CPUInfo::Detect()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
#if _M_X86_32
|
||||
Mode64bit = false;
|
||||
#elif _M_X86_64
|
||||
#ifdef _M_X86_64
|
||||
Mode64bit = true;
|
||||
OS64bit = true;
|
||||
#endif
|
||||
num_cores = 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _M_X86_32
|
||||
BOOL f64 = false;
|
||||
IsWow64Process(GetCurrentProcess(), &f64);
|
||||
OS64bit = (f64 == TRUE) ? true : false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Set obvious defaults, for extra safety
|
||||
if (Mode64bit) {
|
||||
bSSE = true;
|
||||
|
|
|
@ -125,7 +125,6 @@ void XEmitter::WriteSIB(int scale, int index, int base)
|
|||
void OpArg::WriteRex(XEmitter *emit, int opBits, int bits, int customOp) const
|
||||
{
|
||||
if (customOp == -1) customOp = operandReg;
|
||||
#if _M_X86_64
|
||||
u8 op = 0x40;
|
||||
// REX.W (whether operation is a 64-bit operation)
|
||||
if (opBits == 64) op |= 8;
|
||||
|
@ -145,17 +144,6 @@ void OpArg::WriteRex(XEmitter *emit, int opBits, int bits, int customOp) const
|
|||
_dbg_assert_(DYNA_REC, (offsetOrBaseReg & 0x100) == 0);
|
||||
_dbg_assert_(DYNA_REC, (customOp & 0x100) == 0);
|
||||
}
|
||||
#else
|
||||
// Make sure we don't perform a 64-bit operation.
|
||||
_dbg_assert_(DYNA_REC, opBits != 64);
|
||||
// Make sure the operation doesn't access R8-R15 registers.
|
||||
_dbg_assert_(DYNA_REC, (customOp & 8) == 0);
|
||||
_dbg_assert_(DYNA_REC, (indexReg & 8) == 0);
|
||||
_dbg_assert_(DYNA_REC, (offsetOrBaseReg & 8) == 0);
|
||||
// Make sure the operation doesn't access SIL, DIL, BPL, or SPL.
|
||||
_dbg_assert_(DYNA_REC, opBits != 8 || (customOp & 0x10c) != 4);
|
||||
_dbg_assert_(DYNA_REC, scale != SCALE_NONE || bits != 8 || (offsetOrBaseReg & 0x10c) != 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpArg::WriteVex(XEmitter* emit, int size, int packed, Gen::X64Reg regOp1, Gen::X64Reg regOp2) const
|
||||
|
@ -208,7 +196,6 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg,
|
|||
_offsetOrBaseReg = 5;
|
||||
emit->WriteModRM(0, _operandReg, _offsetOrBaseReg);
|
||||
//TODO : add some checks
|
||||
#if _M_X86_64
|
||||
u64 ripAddr = (u64)emit->GetCodePtr() + 4 + extraBytes;
|
||||
s64 distance = (s64)offset - (s64)ripAddr;
|
||||
_assert_msg_(DYNA_REC,
|
||||
|
@ -219,9 +206,6 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg,
|
|||
ripAddr, offset);
|
||||
s32 offs = (s32)distance;
|
||||
emit->Write32((u32)offs);
|
||||
#else
|
||||
emit->Write32((u32)offset);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1251,6 @@ void XEmitter::MOVD_xmm(X64Reg dest, const OpArg &arg) {WriteSSEOp(64, 0x6E, tru
|
|||
void XEmitter::MOVD_xmm(const OpArg &arg, X64Reg src) {WriteSSEOp(64, 0x7E, true, src, arg, 0);}
|
||||
|
||||
void XEmitter::MOVQ_xmm(X64Reg dest, OpArg arg) {
|
||||
#if _M_X86_64
|
||||
// Alternate encoding
|
||||
// This does not display correctly in MSVC's debugger, it thinks it's a MOVD
|
||||
arg.operandReg = dest;
|
||||
|
@ -1276,13 +1259,6 @@ void XEmitter::MOVQ_xmm(X64Reg dest, OpArg arg) {
|
|||
Write8(0x0f);
|
||||
Write8(0x6E);
|
||||
arg.WriteRest(this, 0);
|
||||
#else
|
||||
arg.operandReg = dest;
|
||||
Write8(0xF3);
|
||||
Write8(0x0f);
|
||||
Write8(0x7E);
|
||||
arg.WriteRest(this, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void XEmitter::MOVQ_xmm(OpArg arg, X64Reg src) {
|
||||
|
@ -1626,8 +1602,6 @@ void XEmitter::RTDSC() { Write8(0x0F); Write8(0x31); }
|
|||
void XEmitter::CallCdeclFunction3(void* fnptr, u32 arg0, u32 arg1, u32 arg2)
|
||||
{
|
||||
using namespace Gen;
|
||||
#if _M_X86_64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
MOV(32, R(RCX), Imm32(arg0));
|
||||
MOV(32, R(RDX), Imm32(arg1));
|
||||
|
@ -1639,26 +1613,11 @@ void XEmitter::CallCdeclFunction3(void* fnptr, u32 arg0, u32 arg1, u32 arg2)
|
|||
MOV(32, R(RDX), Imm32(arg2));
|
||||
CALL(fnptr);
|
||||
#endif
|
||||
|
||||
#else
|
||||
ABI_AlignStack(3 * 4);
|
||||
PUSH(32, Imm32(arg2));
|
||||
PUSH(32, Imm32(arg1));
|
||||
PUSH(32, Imm32(arg0));
|
||||
CALL(fnptr);
|
||||
#ifdef _WIN32
|
||||
// don't inc stack
|
||||
#else
|
||||
ABI_RestoreStack(3 * 4);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void XEmitter::CallCdeclFunction4(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3)
|
||||
{
|
||||
using namespace Gen;
|
||||
#if _M_X86_64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
MOV(32, R(RCX), Imm32(arg0));
|
||||
MOV(32, R(RDX), Imm32(arg1));
|
||||
|
@ -1672,27 +1631,11 @@ void XEmitter::CallCdeclFunction4(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32
|
|||
MOV(32, R(RCX), Imm32(arg3));
|
||||
CALL(fnptr);
|
||||
#endif
|
||||
|
||||
#else
|
||||
ABI_AlignStack(4 * 4);
|
||||
PUSH(32, Imm32(arg3));
|
||||
PUSH(32, Imm32(arg2));
|
||||
PUSH(32, Imm32(arg1));
|
||||
PUSH(32, Imm32(arg0));
|
||||
CALL(fnptr);
|
||||
#ifdef _WIN32
|
||||
// don't inc stack
|
||||
#else
|
||||
ABI_RestoreStack(4 * 4);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void XEmitter::CallCdeclFunction5(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4)
|
||||
{
|
||||
using namespace Gen;
|
||||
#if _M_X86_64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
MOV(32, R(RCX), Imm32(arg0));
|
||||
MOV(32, R(RDX), Imm32(arg1));
|
||||
|
@ -1708,28 +1651,11 @@ void XEmitter::CallCdeclFunction5(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32
|
|||
MOV(32, R(R8), Imm32(arg4));
|
||||
CALL(fnptr);
|
||||
#endif
|
||||
|
||||
#else
|
||||
ABI_AlignStack(5 * 4);
|
||||
PUSH(32, Imm32(arg4));
|
||||
PUSH(32, Imm32(arg3));
|
||||
PUSH(32, Imm32(arg2));
|
||||
PUSH(32, Imm32(arg1));
|
||||
PUSH(32, Imm32(arg0));
|
||||
CALL(fnptr);
|
||||
#ifdef _WIN32
|
||||
// don't inc stack
|
||||
#else
|
||||
ABI_RestoreStack(5 * 4);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void XEmitter::CallCdeclFunction6(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
|
||||
{
|
||||
using namespace Gen;
|
||||
#if _M_X86_64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
MOV(32, R(RCX), Imm32(arg0));
|
||||
MOV(32, R(RDX), Imm32(arg1));
|
||||
|
@ -1747,26 +1673,8 @@ void XEmitter::CallCdeclFunction6(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32
|
|||
MOV(32, R(R9), Imm32(arg5));
|
||||
CALL(fnptr);
|
||||
#endif
|
||||
|
||||
#else
|
||||
ABI_AlignStack(6 * 4);
|
||||
PUSH(32, Imm32(arg5));
|
||||
PUSH(32, Imm32(arg4));
|
||||
PUSH(32, Imm32(arg3));
|
||||
PUSH(32, Imm32(arg2));
|
||||
PUSH(32, Imm32(arg1));
|
||||
PUSH(32, Imm32(arg0));
|
||||
CALL(fnptr);
|
||||
#ifdef _WIN32
|
||||
// don't inc stack
|
||||
#else
|
||||
ABI_RestoreStack(6 * 4);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if _M_X86_64
|
||||
|
||||
// See header
|
||||
void XEmitter::___CallCdeclImport3(void* impptr, u32 arg0, u32 arg1, u32 arg2) {
|
||||
MOV(32, R(RCX), Imm32(arg0));
|
||||
|
@ -1799,6 +1707,4 @@ void XEmitter::___CallCdeclImport6(void* impptr, u32 arg0, u32 arg1, u32 arg2, u
|
|||
CALLptr(M(impptr));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -702,11 +702,7 @@ public:
|
|||
void ABI_AlignStack(unsigned int frameSize, bool noProlog = false);
|
||||
void ABI_RestoreStack(unsigned int frameSize, bool noProlog = false);
|
||||
|
||||
#if _M_X86_32
|
||||
inline int ABI_GetNumXMMRegs() { return 8; }
|
||||
#else
|
||||
inline int ABI_GetNumXMMRegs() { return 16; }
|
||||
#endif
|
||||
|
||||
// Strange call wrappers.
|
||||
void CallCdeclFunction3(void* fnptr, u32 arg0, u32 arg1, u32 arg2);
|
||||
|
@ -714,17 +710,6 @@ public:
|
|||
void CallCdeclFunction5(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4);
|
||||
void CallCdeclFunction6(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5);
|
||||
|
||||
#if _M_X86_32
|
||||
|
||||
#define CallCdeclFunction3_I(a,b,c,d) CallCdeclFunction3((void *)(a), (b), (c), (d))
|
||||
#define CallCdeclFunction4_I(a,b,c,d,e) CallCdeclFunction4((void *)(a), (b), (c), (d), (e))
|
||||
#define CallCdeclFunction5_I(a,b,c,d,e,f) CallCdeclFunction5((void *)(a), (b), (c), (d), (e), (f))
|
||||
#define CallCdeclFunction6_I(a,b,c,d,e,f,g) CallCdeclFunction6((void *)(a), (b), (c), (d), (e), (f), (g))
|
||||
|
||||
#define DECLARE_IMPORT(x)
|
||||
|
||||
#else
|
||||
|
||||
// Comments from VertexLoader.cpp about these horrors:
|
||||
|
||||
// This is a horrible hack that is necessary in 64-bit mode because Opengl32.dll is based way, way above the 32-bit
|
||||
|
@ -743,8 +728,6 @@ public:
|
|||
|
||||
#define DECLARE_IMPORT(x) extern "C" void *__imp_##x
|
||||
|
||||
#endif
|
||||
|
||||
// Utility to generate a call to a std::function object.
|
||||
//
|
||||
// Unfortunately, calling operator() directly is undefined behavior in C++
|
||||
|
|
|
@ -32,30 +32,9 @@ namespace FPURoundMode
|
|||
fesetround(rounding_mode_lut[mode]);
|
||||
}
|
||||
|
||||
void SetPrecisionMode(PrecisionMode mode)
|
||||
void SetPrecisionMode(PrecisionMode /* mode */)
|
||||
{
|
||||
#ifdef _M_X86_32
|
||||
// sets the floating-point lib to 53-bit
|
||||
// PowerPC has a 53bit floating pipeline only
|
||||
// eg: sscanf is very sensitive
|
||||
#ifdef _WIN32
|
||||
_control87(_PC_53, MCW_PC);
|
||||
#else
|
||||
const unsigned short PRECISION_MASK = 3 << 8;
|
||||
const unsigned short precision_table[] = {
|
||||
0 << 8, // 24 bits
|
||||
2 << 8, // 53 bits
|
||||
3 << 8, // 64 bits
|
||||
};
|
||||
unsigned short _mode;
|
||||
asm ("fstcw %0" : "=m" (_mode));
|
||||
_mode = (_mode & ~PRECISION_MASK) | precision_table[mode];
|
||||
asm ("fldcw %0" : : "m" (_mode));
|
||||
#endif
|
||||
#else
|
||||
//x64 doesn't need this - fpu is done with SSE
|
||||
//but still - set any useful sse options here
|
||||
#endif
|
||||
//x64 doesn't need this - fpu is done with SSE
|
||||
}
|
||||
|
||||
void SetSIMDMode(int rounding_mode, bool non_ieee_mode)
|
||||
|
|
Loading…
Reference in New Issue