CodeGen: Added basic x64 stuff.

git-svn-id: http://svn.purei.org/purei/trunk@640 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
jpd002 2010-05-04 04:26:19 +00:00
parent 0e1b9e5303
commit ad6e573710
2 changed files with 29 additions and 3 deletions

View File

@ -115,10 +115,15 @@ void CJitter::PushCst(uint32 nValue)
void CJitter::PushRef(void* pAddr)
{
if(sizeof(pAddr) == 4)
size_t addrSize = sizeof(pAddr);
if(addrSize == 4)
{
m_Shadow.Push(MakeSymbol(SYM_CONSTANT, *reinterpret_cast<uint32*>(&pAddr)));
}
else if(addrSize == 8)
{
m_Shadow.Push(MakeConstant64(*reinterpret_cast<uint64*>(&pAddr)));
}
else
{
assert(0);
@ -200,10 +205,21 @@ void CJitter::Call(void* pFunc, unsigned int nParamCount, bool nKeepRet)
InsertStatement(paramStatement);
}
assert(sizeof(void*) == 4);
size_t addrSize = sizeof(pFunc);
STATEMENT callStatement;
callStatement.src1 = MakeSymbolRef(MakeSymbol(SYM_CONSTANT, reinterpret_cast<uint32>(pFunc)));
if(addrSize == 4)
{
callStatement.src1 = MakeSymbolRef(MakeSymbol(SYM_CONSTANT, reinterpret_cast<uint32>(pFunc)));
}
else if(addrSize == 8)
{
callStatement.src1 = MakeSymbolRef(MakeConstant64(reinterpret_cast<uint64>(pFunc)));
}
else
{
assert(0);
}
callStatement.src2 = MakeSymbolRef(MakeSymbol(SYM_CONSTANT, nParamCount));
callStatement.op = OP_CALL;
InsertStatement(callStatement);

View File

@ -1,5 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "MemoryFunction.h"
CMemoryFunction::CMemoryFunction(const void* code, size_t size)
@ -18,6 +19,12 @@ void CMemoryFunction::operator()(void* context)
volatile const void* code = m_code;
volatile const void* dataPtr = context;
#ifdef AMD64
assert(0);
#else
__asm
{
push ebp
@ -34,4 +41,7 @@ void CMemoryFunction::operator()(void* context)
pop ebx
pop ebp
}
#endif
}