- reuse temp virtual registers

This commit is contained in:
Magnus Norddahl 2018-10-07 09:02:28 +02:00
parent c5a5265e40
commit 47485194f4
8 changed files with 218 additions and 188 deletions

View file

@ -112,6 +112,8 @@ void JitCompiler::Codegen()
cc.bind(labels[i]);
ResetTemp();
FString lineinfo;
lineinfo.Format("; %s(line %d): %02x%02x%02x%02x %s", sfunc->PrintableName.GetChars(), sfunc->PCToLine(pc), pc->op, pc->a, pc->b, pc->c, OpNames[op]);
cc.comment(lineinfo.GetChars(), lineinfo.Len());
@ -277,7 +279,7 @@ void JitCompiler::EmitThrowException(EVMAbortException reason)
#endif
// Return from function
X86Gp vReg = cc.newInt32();
X86Gp vReg = newTempInt32();
cc.mov(vReg, 0);
cc.ret(vReg);
}
@ -296,7 +298,7 @@ void JitCompiler::EmitThrowException(EVMAbortException reason, asmjit::X86Gp arg
#endif
// Return from function
X86Gp vReg = cc.newInt32();
X86Gp vReg = newTempInt32();
cc.mov(vReg, 0);
cc.ret(vReg);
}
@ -309,7 +311,7 @@ asmjit::X86Gp JitCompiler::CheckRegD(int r0, int r1)
}
else
{
auto copy = cc.newInt32();
auto copy = newTempInt32();
cc.mov(copy, regD[r0]);
return copy;
}
@ -323,7 +325,7 @@ asmjit::X86Xmm JitCompiler::CheckRegF(int r0, int r1)
}
else
{
auto copy = cc.newXmm();
auto copy = newTempXmmSd();
cc.movsd(copy, regF[r0]);
return copy;
}
@ -337,7 +339,7 @@ asmjit::X86Xmm JitCompiler::CheckRegF(int r0, int r1, int r2)
}
else
{
auto copy = cc.newXmm();
auto copy = newTempXmmSd();
cc.movsd(copy, regF[r0]);
return copy;
}
@ -351,7 +353,7 @@ asmjit::X86Xmm JitCompiler::CheckRegF(int r0, int r1, int r2, int r3)
}
else
{
auto copy = cc.newXmm();
auto copy = newTempXmmSd();
cc.movsd(copy, regF[r0]);
return copy;
}
@ -365,7 +367,7 @@ asmjit::X86Gp JitCompiler::CheckRegS(int r0, int r1)
}
else
{
auto copy = cc.newIntPtr();
auto copy = newTempIntPtr();
cc.mov(copy, regS[r0]);
return copy;
}
@ -379,7 +381,7 @@ asmjit::X86Gp JitCompiler::CheckRegA(int r0, int r1)
}
else
{
auto copy = cc.newIntPtr();
auto copy = newTempIntPtr();
cc.mov(copy, regA[r0]);
return copy;
}

View file

@ -22,7 +22,7 @@ void JitCompiler::EmitPARAM()
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_INT);
break;
case REGT_INT | REGT_ADDROF:
stackPtr = cc.newIntPtr();
stackPtr = newTempIntPtr();
cc.mov(stackPtr, frameD);
cc.add(stackPtr, (int)(C * sizeof(int32_t)));
cc.mov(x86::ptr(params, index * sizeof(VMValue) + offsetof(VMValue, a)), stackPtr);
@ -41,7 +41,7 @@ void JitCompiler::EmitPARAM()
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_POINTER);
break;
case REGT_STRING | REGT_KONST:
tmp = cc.newIntPtr();
tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konsts[C]));
cc.mov(x86::ptr(params, index * sizeof(VMValue) + offsetof(VMValue, sp)), tmp);
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_STRING);
@ -51,14 +51,14 @@ void JitCompiler::EmitPARAM()
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_POINTER);
break;
case REGT_POINTER | REGT_ADDROF:
stackPtr = cc.newIntPtr();
stackPtr = newTempIntPtr();
cc.mov(stackPtr, frameA);
cc.add(stackPtr, (int)(C * sizeof(void*)));
cc.mov(x86::ptr(params, index * sizeof(VMValue) + offsetof(VMValue, a)), stackPtr);
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_POINTER);
break;
case REGT_POINTER | REGT_KONST:
tmp = cc.newIntPtr();
tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(konsta[C].v));
cc.mov(x86::ptr(params, index * sizeof(VMValue) + offsetof(VMValue, a)), tmp);
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_POINTER);
@ -88,15 +88,15 @@ void JitCompiler::EmitPARAM()
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_FLOAT);
break;
case REGT_FLOAT | REGT_ADDROF:
stackPtr = cc.newIntPtr();
stackPtr = newTempIntPtr();
cc.mov(stackPtr, frameF);
cc.add(stackPtr, (int)(C * sizeof(double)));
cc.mov(x86::ptr(params, index * sizeof(VMValue) + offsetof(VMValue, a)), stackPtr);
cc.mov(x86::byte_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, Type)), (int)REGT_POINTER);
break;
case REGT_FLOAT | REGT_KONST:
tmp = cc.newIntPtr();
tmp2 = cc.newXmmSd();
tmp = newTempIntPtr();
tmp2 = newTempXmmSd();
cc.mov(tmp, asmjit::imm_ptr(konstf + C));
cc.movsd(tmp2, asmjit::x86::qword_ptr(tmp));
cc.movsd(x86::qword_ptr(params, index * sizeof(VMValue) + offsetof(VMValue, f)), tmp2);
@ -131,7 +131,7 @@ void JitCompiler::EmitCALL()
void JitCompiler::EmitCALL_K()
{
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.mov(ptr, asmjit::imm_ptr(konsta[A].o));
EmitDoCall(ptr);
}
@ -143,7 +143,7 @@ void JitCompiler::EmitTAIL()
void JitCompiler::EmitTAIL_K()
{
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.mov(ptr, asmjit::imm_ptr(konsta[A].o));
EmitDoTail(ptr);
}
@ -161,7 +161,7 @@ void JitCompiler::EmitDoCall(asmjit::X86Gp ptr)
X86Gp paramsptr;
if (B != NumParam)
{
paramsptr = cc.newIntPtr();
paramsptr = newTempIntPtr();
cc.lea(paramsptr, x86::ptr(params, (int)((NumParam - B) * sizeof(VMValue))));
}
else
@ -169,7 +169,7 @@ void JitCompiler::EmitDoCall(asmjit::X86Gp ptr)
paramsptr = params;
}
auto result = cc.newInt32();
auto result = newResultInt32();
auto call = CreateCall<int, VMFrameStack*, VMFunction*, int, int, VMValue*, VMReturn*, JitExceptionInfo*>(&JitCompiler::DoCall);
call->setRet(0, result);
call->setArg(0, stack);
@ -181,11 +181,11 @@ void JitCompiler::EmitDoCall(asmjit::X86Gp ptr)
call->setArg(6, exceptInfo);
auto noexception = cc.newLabel();
auto exceptResult = cc.newInt32();
auto exceptResult = newTempInt32();
cc.mov(exceptResult, x86::dword_ptr(exceptInfo, 0 * 4));
cc.cmp(exceptResult, (int)-1);
cc.je(noexception);
X86Gp vReg = cc.newInt32();
X86Gp vReg = newTempInt32();
cc.mov(vReg, 0);
cc.ret(vReg);
cc.bind(noexception);
@ -214,7 +214,7 @@ void JitCompiler::EmitDoTail(asmjit::X86Gp ptr)
X86Gp paramsptr;
if (B != NumParam)
{
paramsptr = cc.newIntPtr();
paramsptr = newTempIntPtr();
cc.lea(paramsptr, x86::ptr(params, (int)((NumParam - B) * sizeof(VMValue))));
}
else
@ -222,7 +222,7 @@ void JitCompiler::EmitDoTail(asmjit::X86Gp ptr)
paramsptr = params;
}
auto result = cc.newInt32();
auto result = newResultInt32();
auto call = CreateCall<int, VMFrameStack*, VMFunction*, int, int, VMValue*, VMReturn*, JitExceptionInfo*>(&JitCompiler::DoCall);
call->setRet(0, result);
call->setArg(0, stack);
@ -249,7 +249,7 @@ void JitCompiler::StoreInOuts(int b)
switch (ParamOpcodes[i]->b)
{
case REGT_INT | REGT_ADDROF:
stackPtr = cc.newIntPtr();
stackPtr = newTempIntPtr();
cc.mov(stackPtr, frameD);
cc.add(stackPtr, (int)(C * sizeof(int32_t)));
cc.mov(x86::dword_ptr(stackPtr), regD[C]);
@ -258,13 +258,13 @@ void JitCompiler::StoreInOuts(int b)
// We don't have to do anything in this case. String values are never moved to virtual registers.
break;
case REGT_POINTER | REGT_ADDROF:
stackPtr = cc.newIntPtr();
stackPtr = newTempIntPtr();
cc.mov(stackPtr, frameA);
cc.add(stackPtr, (int)(C * sizeof(void*)));
cc.mov(x86::ptr(stackPtr), regA[C]);
break;
case REGT_FLOAT | REGT_ADDROF:
stackPtr = cc.newIntPtr();
stackPtr = newTempIntPtr();
cc.mov(stackPtr, frameF);
cc.add(stackPtr, (int)(C * sizeof(double)));
cc.movsd(x86::qword_ptr(stackPtr), regF[C]);
@ -342,7 +342,7 @@ void JitCompiler::FillReturns(const VMOP *retval, int numret)
I_FatalError("OP_RESULT with REGT_KONST is not allowed\n");
}
auto regPtr = cc.newIntPtr();
auto regPtr = newTempIntPtr();
switch (type & REGT_TYPE)
{

View file

@ -28,7 +28,7 @@ void JitCompiler::EmitIJMP()
// This uses the whole function as potential jump targets. Can the range be reduced?
int i = (int)(ptrdiff_t)(pc - sfunc->Code);
auto val = cc.newInt32();
auto val = newTempInt32();
cc.mov(val, regD[A]);
cc.add(val, i + (int)BCs + 1);
@ -56,7 +56,7 @@ void JitCompiler::EmitVTBL()
EmitThrowException(X_READ_NIL);
cc.bind(notnull);
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<VMFunction*, DObject*, int>([](DObject *o, int c) -> VMFunction* {
auto p = o->GetClass();
assert(c < (int)p->Virtuals.Size());
@ -76,10 +76,10 @@ void JitCompiler::EmitSCOPE()
EmitThrowException(X_READ_NIL);
cc.bind(notnull);
auto f = cc.newIntPtr();
auto f = newTempIntPtr();
cc.mov(f, asmjit::imm_ptr(konsta[C].v));
auto result = cc.newInt32();
auto result = newResultInt32();
typedef int(*FuncPtr)(DObject*, VMFunction*, int);
auto call = CreateCall<int, DObject*, VMFunction*, int>([](DObject *o, VMFunction *f, int b) -> int {
try
@ -110,7 +110,7 @@ void JitCompiler::EmitRET()
using namespace asmjit;
if (B == REGT_NIL)
{
X86Gp vReg = cc.newInt32();
X86Gp vReg = newTempInt32();
cc.mov(vReg, 0);
cc.ret(vReg);
}
@ -119,8 +119,8 @@ void JitCompiler::EmitRET()
int a = A;
int retnum = a & ~RET_FINAL;
X86Gp reg_retnum = cc.newInt32();
X86Gp location = cc.newIntPtr();
X86Gp reg_retnum = newTempInt32();
X86Gp location = newTempIntPtr();
Label L_endif = cc.newLabel();
cc.mov(reg_retnum, retnum);
@ -142,7 +142,7 @@ void JitCompiler::EmitRET()
case REGT_FLOAT:
if (regtype & REGT_KONST)
{
auto tmp = cc.newInt64();
auto tmp = newTempInt64();
if (regtype & REGT_MULTIREG3)
{
cc.mov(tmp, (((int64_t *)konstf)[regnum]));
@ -189,7 +189,7 @@ void JitCompiler::EmitRET()
break;
case REGT_STRING:
{
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.mov(ptr, ret);
cc.add(ptr, (int)(retnum * sizeof(VMReturn)));
auto call = CreateCall<void, VMReturn*, FString*>([](VMReturn* ret, FString* str) -> void {
@ -234,8 +234,8 @@ void JitCompiler::EmitRETI()
int a = A;
int retnum = a & ~RET_FINAL;
X86Gp reg_retnum = cc.newInt32();
X86Gp location = cc.newIntPtr();
X86Gp reg_retnum = newTempInt32();
X86Gp location = newTempIntPtr();
Label L_endif = cc.newLabel();
cc.mov(reg_retnum, retnum);
@ -258,7 +258,7 @@ void JitCompiler::EmitRETI()
void JitCompiler::EmitNEW()
{
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<DObject*, PClass*, int>([](PClass *cls, int c) -> DObject* {
try
{
@ -314,8 +314,8 @@ void JitCompiler::EmitNEW_K()
}
else
{
auto result = cc.newIntPtr();
auto regcls = cc.newIntPtr();
auto result = newResultIntPtr();
auto regcls = newTempIntPtr();
cc.mov(regcls, asmjit::imm_ptr(konsta[B].v));
auto call = CreateCall<DObject*, PClass*, int>([](PClass *cls, int c) -> DObject* {
try

View file

@ -16,7 +16,7 @@ void JitCompiler::EmitLK()
void JitCompiler::EmitLKF()
{
auto base = cc.newIntPtr();
auto base = newTempIntPtr();
cc.mov(base, asmjit::imm_ptr(konstf + BC));
cc.movsd(regF[A], asmjit::x86::qword_ptr(base));
}
@ -35,23 +35,23 @@ void JitCompiler::EmitLKP()
void JitCompiler::EmitLK_R()
{
auto base = cc.newIntPtr();
auto base = newTempIntPtr();
cc.mov(base, asmjit::imm_ptr(konstd + C));
cc.mov(regD[A], asmjit::x86::ptr(base, regD[B], 2));
}
void JitCompiler::EmitLKF_R()
{
auto base = cc.newIntPtr();
auto base = newTempIntPtr();
cc.mov(base, asmjit::imm_ptr(konstf + C));
cc.movsd(regF[A], asmjit::x86::qword_ptr(base, regD[B], 3));
}
void JitCompiler::EmitLKS_R()
{
auto base = cc.newIntPtr();
auto base = newTempIntPtr();
cc.mov(base, asmjit::imm_ptr(konsts + C));
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
#ifdef ASMJIT_ARCH_64BIT
static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 8");
cc.lea(ptr, asmjit::x86::ptr(base, regD[B], 3));
@ -66,7 +66,7 @@ void JitCompiler::EmitLKS_R()
void JitCompiler::EmitLKP_R()
{
auto base = cc.newIntPtr();
auto base = newTempIntPtr();
cc.mov(base, asmjit::imm_ptr(konsta + C));
#ifdef ASMJIT_ARCH_64BIT
static_assert(sizeof(FVoidObj) == 8, "sizeof(FVoidObj) needs to be 8");
@ -90,7 +90,7 @@ void JitCompiler::EmitMETA()
EmitThrowException(X_READ_NIL);
cc.bind(label);
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<uint8_t*, DObject*>([](DObject *o) { return o->GetClass()->Meta; });
call->setRet(0, result);
call->setArg(0, regA[B]);
@ -105,7 +105,7 @@ void JitCompiler::EmitCLSS()
EmitThrowException(X_READ_NIL);
cc.bind(label);
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<PClass*, DObject*>([](DObject *o) { return o->GetClass(); });
call->setRet(0, result);
call->setArg(0, regA[B]);
@ -202,7 +202,7 @@ void JitCompiler::EmitLDP_R()
void JitCompiler::EmitLS()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.lea(ptr, asmjit::x86::ptr(regA[B], konstd[C]));
auto call = CreateCall<void, FString*, FString*>(&JitCompiler::CallAssignString);
call->setArg(0, regS[A]);
@ -212,7 +212,7 @@ void JitCompiler::EmitLS()
void JitCompiler::EmitLS_R()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.lea(ptr, asmjit::x86::ptr(regA[B], regD[C]));
auto call = CreateCall<void, FString*, FString*>(&JitCompiler::CallAssignString);
call->setArg(0, regS[A]);
@ -223,10 +223,10 @@ void JitCompiler::EmitLO()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.mov(ptr, asmjit::x86::ptr(regA[B], konstd[C]));
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<DObject*,DObject*>([](DObject *p) { return GC::ReadBarrier(p); });
call->setRet(0, result);
call->setArg(0, ptr);
@ -237,10 +237,10 @@ void JitCompiler::EmitLO_R()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.mov(ptr, asmjit::x86::ptr(regA[B], regD[C]));
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<DObject*, DObject*>([](DObject *p) { return GC::ReadBarrier(p); });
call->setRet(0, result);
call->setArg(0, ptr);
@ -262,7 +262,7 @@ void JitCompiler::EmitLP_R()
void JitCompiler::EmitLV2()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, konstd[C]);
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -272,7 +272,7 @@ void JitCompiler::EmitLV2()
void JitCompiler::EmitLV2_R()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, regD[C]);
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -282,7 +282,7 @@ void JitCompiler::EmitLV2_R()
void JitCompiler::EmitLV3()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, konstd[C]);
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -293,7 +293,7 @@ void JitCompiler::EmitLV3()
void JitCompiler::EmitLV3_R()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, regD[C]);
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -304,7 +304,7 @@ void JitCompiler::EmitLV3_R()
void JitCompiler::EmitLCS()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.lea(ptr, asmjit::x86::ptr(regA[B], konstd[C]));
auto call = CreateCall<void, FString*, char**>([](FString* to, char** from) { *to = *from; });
call->setArg(0, regS[A]);
@ -314,7 +314,7 @@ void JitCompiler::EmitLCS()
void JitCompiler::EmitLCS_R()
{
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.lea(ptr, asmjit::x86::ptr(regA[B], regD[C]));
auto call = CreateCall<void, FString*, char**>([](FString* to, char** from) { *to = *from; });
call->setArg(0, regS[A]);

View file

@ -17,7 +17,7 @@ void JitCompiler::EmitCONCAT()
void JitCompiler::EmitLENS()
{
auto result = cc.newInt32();
auto result = newResultInt32();
auto call = CreateCall<int, FString*>([](FString* str) -> int {
return static_cast<int>(str->Len());
});
@ -40,7 +40,7 @@ void JitCompiler::EmitCMPS()
CreateCall<int, FString*, FString*>(compareNoCaseLambda) :
CreateCall<int, FString*, FString*>(compareLambda);
auto result = cc.newInt32();
auto result = newResultInt32();
call->setRet(0, result);
if (static_cast<bool>(A & CMP_BK)) call->setArg(0, asmjit::imm_ptr(&konsts[B]));
@ -198,8 +198,8 @@ void JitCompiler::EmitMUL_RK()
void JitCompiler::EmitDIV_RR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -218,9 +218,9 @@ void JitCompiler::EmitDIV_RK()
{
if (konstd[C] != 0)
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto konstTmp = cc.newIntPtr();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto konstTmp = newTempIntPtr();
cc.mov(tmp0, regD[B]);
cc.cdq(tmp1, tmp0);
cc.mov(konstTmp, asmjit::imm_ptr(&konstd[C]));
@ -232,8 +232,8 @@ void JitCompiler::EmitDIV_RK()
void JitCompiler::EmitDIV_KR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -250,8 +250,8 @@ void JitCompiler::EmitDIV_KR()
void JitCompiler::EmitDIVU_RR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -270,9 +270,9 @@ void JitCompiler::EmitDIVU_RK()
{
if (konstd[C] != 0)
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto konstTmp = cc.newIntPtr();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto konstTmp = newTempIntPtr();
cc.mov(tmp0, regD[B]);
cc.mov(tmp1, 0);
cc.mov(konstTmp, asmjit::imm_ptr(&konstd[C]));
@ -284,8 +284,8 @@ void JitCompiler::EmitDIVU_RK()
void JitCompiler::EmitDIVU_KR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -302,8 +302,8 @@ void JitCompiler::EmitDIVU_KR()
void JitCompiler::EmitMOD_RR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -322,9 +322,9 @@ void JitCompiler::EmitMOD_RK()
{
if (konstd[C] != 0)
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto konstTmp = cc.newIntPtr();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto konstTmp = newTempIntPtr();
cc.mov(tmp0, regD[B]);
cc.cdq(tmp1, tmp0);
cc.mov(konstTmp, asmjit::imm_ptr(&konstd[C]));
@ -336,8 +336,8 @@ void JitCompiler::EmitMOD_RK()
void JitCompiler::EmitMOD_KR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -354,8 +354,8 @@ void JitCompiler::EmitMOD_KR()
void JitCompiler::EmitMODU_RR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -374,9 +374,9 @@ void JitCompiler::EmitMODU_RK()
{
if (konstd[C] != 0)
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto konstTmp = cc.newIntPtr();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto konstTmp = newTempIntPtr();
cc.mov(tmp0, regD[B]);
cc.mov(tmp1, 0);
cc.mov(konstTmp, asmjit::imm_ptr(&konstd[C]));
@ -388,8 +388,8 @@ void JitCompiler::EmitMODU_RK()
void JitCompiler::EmitMODU_KR()
{
auto tmp0 = cc.newInt32();
auto tmp1 = cc.newInt32();
auto tmp0 = newTempInt32();
auto tmp1 = newTempInt32();
auto label = cc.newLabel();
cc.test(regD[C], regD[C]);
@ -451,8 +451,8 @@ void JitCompiler::EmitXOR_RK()
void JitCompiler::EmitMIN_RR()
{
auto tmp0 = cc.newXmmSs();
auto tmp1 = cc.newXmmSs();
auto tmp0 = newTempXmmSs();
auto tmp1 = newTempXmmSs();
cc.movd(tmp0, regD[B]);
cc.movd(tmp1, regD[C]);
cc.pminsd(tmp0, tmp1);
@ -461,9 +461,9 @@ void JitCompiler::EmitMIN_RR()
void JitCompiler::EmitMIN_RK()
{
auto tmp0 = cc.newXmmSs();
auto tmp1 = cc.newXmmSs();
auto konstTmp = cc.newIntPtr();
auto tmp0 = newTempXmmSs();
auto tmp1 = newTempXmmSs();
auto konstTmp = newTempIntPtr();
cc.mov(konstTmp, asmjit::imm_ptr(&konstd[C]));
cc.movd(tmp0, regD[B]);
cc.movss(tmp1, asmjit::x86::dword_ptr(konstTmp));
@ -473,8 +473,8 @@ void JitCompiler::EmitMIN_RK()
void JitCompiler::EmitMAX_RR()
{
auto tmp0 = cc.newXmmSs();
auto tmp1 = cc.newXmmSs();
auto tmp0 = newTempXmmSs();
auto tmp1 = newTempXmmSs();
cc.movd(tmp0, regD[B]);
cc.movd(tmp1, regD[C]);
cc.pmaxsd(tmp0, tmp1);
@ -483,9 +483,9 @@ void JitCompiler::EmitMAX_RR()
void JitCompiler::EmitMAX_RK()
{
auto tmp0 = cc.newXmmSs();
auto tmp1 = cc.newXmmSs();
auto konstTmp = cc.newIntPtr();
auto tmp0 = newTempXmmSs();
auto tmp1 = newTempXmmSs();
auto konstTmp = newTempIntPtr();
cc.mov(konstTmp, asmjit::imm_ptr(&konstd[C]));
cc.movd(tmp0, regD[B]);
cc.movss(tmp1, asmjit::x86::dword_ptr(konstTmp));
@ -496,7 +496,7 @@ void JitCompiler::EmitMAX_RK()
void JitCompiler::EmitABS()
{
auto srcB = CheckRegD(B, A);
auto tmp = cc.newInt32();
auto tmp = newTempInt32();
cc.mov(tmp, regD[B]);
cc.sar(tmp, 31);
cc.mov(regD[A], tmp);
@ -557,7 +557,7 @@ void JitCompiler::EmitLT_RK()
void JitCompiler::EmitLT_KR()
{
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstd[B]));
cc.cmp(asmjit::x86::ptr(tmp), regD[C]);
if (check) cc.jl(fail);
@ -586,7 +586,7 @@ void JitCompiler::EmitLE_RK()
void JitCompiler::EmitLE_KR()
{
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstd[B]));
cc.cmp(asmjit::x86::ptr(tmp), regD[C]);
if (check) cc.jle(fail);
@ -615,7 +615,7 @@ void JitCompiler::EmitLTU_RK()
void JitCompiler::EmitLTU_KR()
{
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstd[B]));
cc.cmp(asmjit::x86::ptr(tmp), regD[C]);
if (check) cc.jb(fail);
@ -644,7 +644,7 @@ void JitCompiler::EmitLEU_RK()
void JitCompiler::EmitLEU_KR()
{
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstd[B]));
cc.cmp(asmjit::x86::ptr(tmp), regD[C]);
if (check) cc.jbe(fail);
@ -665,7 +665,7 @@ void JitCompiler::EmitADDF_RR()
void JitCompiler::EmitADDF_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
if (A != B)
cc.movsd(regF[A], regF[B]);
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
@ -682,7 +682,7 @@ void JitCompiler::EmitSUBF_RR()
void JitCompiler::EmitSUBF_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
if (A != B)
cc.movsd(regF[A], regF[B]);
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
@ -692,7 +692,7 @@ void JitCompiler::EmitSUBF_RK()
void JitCompiler::EmitSUBF_KR()
{
auto rc = CheckRegF(C, A);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstf[B]));
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
cc.subsd(regF[A], rc);
@ -708,7 +708,7 @@ void JitCompiler::EmitMULF_RR()
void JitCompiler::EmitMULF_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
if (A != B)
cc.movsd(regF[A], regF[B]);
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
@ -735,7 +735,7 @@ void JitCompiler::EmitDIVF_RK()
}
else
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.movsd(regF[A], regF[B]);
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
cc.divsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -745,7 +745,7 @@ void JitCompiler::EmitDIVF_RK()
void JitCompiler::EmitDIVF_KR()
{
auto rc = CheckRegF(C, A);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstf[B]));
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
cc.divsd(regF[A], rc);
@ -759,7 +759,7 @@ void JitCompiler::EmitMODF_RR()
EmitThrowException(X_DIVISION_BY_ZERO);
cc.bind(label);
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>([](double a, double b) -> double
{
return a - floor(a / b) * b;
@ -778,10 +778,10 @@ void JitCompiler::EmitMODF_RK()
EmitThrowException(X_DIVISION_BY_ZERO);
cc.bind(label);
auto tmp = cc.newXmm();
auto tmp = newTempXmmSd();
cc.movsd(tmp, asmjit::x86::ptr(ToMemAddress(&konstf[C])));
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>([](double a, double b) -> double {
return a - floor(a / b) * b;
});
@ -801,10 +801,10 @@ void JitCompiler::EmitMODF_KR()
EmitThrowException(X_DIVISION_BY_ZERO);
cc.bind(label);
auto tmp = cc.newXmm();
auto tmp = newTempXmmSd();
cc.movsd(tmp, x86::ptr(ToMemAddress(&konstf[B])));
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>([](double a, double b) -> double {
return a - floor(a / b) * b;
});
@ -816,7 +816,7 @@ void JitCompiler::EmitMODF_KR()
void JitCompiler::EmitPOWF_RR()
{
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>(g_pow);
call->setRet(0, result);
call->setArg(0, regF[B]);
@ -826,12 +826,12 @@ void JitCompiler::EmitPOWF_RR()
void JitCompiler::EmitPOWF_RK()
{
auto tmp = cc.newIntPtr();
auto tmp2 = cc.newXmm();
auto tmp = newTempIntPtr();
auto tmp2 = newTempXmmSd();
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
cc.movsd(tmp2, asmjit::x86::qword_ptr(tmp));
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>(g_pow);
call->setRet(0, result);
call->setArg(0, regF[B]);
@ -841,12 +841,12 @@ void JitCompiler::EmitPOWF_RK()
void JitCompiler::EmitPOWF_KR()
{
auto tmp = cc.newIntPtr();
auto tmp2 = cc.newXmm();
auto tmp = newTempIntPtr();
auto tmp2 = newTempXmmSd();
cc.mov(tmp, asmjit::imm_ptr(&konstf[B]));
cc.movsd(tmp2, asmjit::x86::qword_ptr(tmp));
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>(g_pow);
call->setRet(0, result);
call->setArg(0, tmp2);
@ -865,7 +865,7 @@ void JitCompiler::EmitMINF_RR()
void JitCompiler::EmitMINF_RK()
{
auto rb = CheckRegF(B, A);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
cc.minsd(regF[A], rb);
@ -882,7 +882,7 @@ void JitCompiler::EmitMAXF_RR()
void JitCompiler::EmitMAXF_RK()
{
auto rb = CheckRegF(B, A);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp));
cc.maxsd(regF[A], rb);
@ -890,7 +890,7 @@ void JitCompiler::EmitMAXF_RK()
void JitCompiler::EmitATAN2()
{
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>(g_atan2);
call->setRet(0, result);
call->setArg(0, regF[B]);
@ -898,7 +898,7 @@ void JitCompiler::EmitATAN2()
cc.movsd(regF[A], result);
static const double constant = 180 / M_PI;
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&constant));
cc.mulsd(regF[A], asmjit::x86::qword_ptr(tmp));
}
@ -908,7 +908,7 @@ void JitCompiler::EmitFLOP()
if (C == FLOP_NEG)
{
auto mask = cc.newDoubleConst(asmjit::kConstScopeLocal, -0.0);
auto maskXmm = cc.newXmmSd();
auto maskXmm = newTempXmmSd();
cc.movsd(maskXmm, mask);
if (A != B)
cc.movsd(regF[A], regF[B]);
@ -916,13 +916,13 @@ void JitCompiler::EmitFLOP()
}
else
{
auto v = cc.newXmm();
auto v = newTempXmmSd();
cc.movsd(v, regF[B]);
if (C == FLOP_TAN_DEG)
{
static const double constant = M_PI / 180;
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&constant));
cc.mulsd(v, asmjit::x86::qword_ptr(tmp));
}
@ -956,7 +956,7 @@ void JitCompiler::EmitFLOP()
case FLOP_TANH: func = g_tanh; break;
}
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double>(func);
call->setRet(0, result);
call->setArg(0, v);
@ -965,7 +965,7 @@ void JitCompiler::EmitFLOP()
if (C == FLOP_ACOS_DEG || C == FLOP_ASIN_DEG || C == FLOP_ATAN_DEG)
{
static const double constant = 180 / M_PI;
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&constant));
cc.mulsd(regF[A], asmjit::x86::qword_ptr(tmp));
}
@ -990,14 +990,14 @@ void JitCompiler::EmitEQF_R()
}
else
{
auto tmp = cc.newXmmSd();
auto tmp = newTempXmmSd();
const int64_t absMaskInt = 0x7FFFFFFFFFFFFFFF;
auto absMask = cc.newDoubleConst(asmjit::kConstScopeLocal, reinterpret_cast<const double&>(absMaskInt));
auto absMaskXmm = cc.newXmmPd();
auto absMaskXmm = newTempXmmPd();
auto epsilon = cc.newDoubleConst(asmjit::kConstScopeLocal, VM_EPSILON);
auto epsilonXmm = cc.newXmmSd();
auto epsilonXmm = newTempXmmSd();
cc.movsd(tmp, regF[B]);
cc.subsd(tmp, regF[C]);
@ -1018,7 +1018,7 @@ void JitCompiler::EmitEQF_K()
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
bool approx = static_cast<bool>(A & CMP_APPROX);
if (!approx) {
auto konstTmp = cc.newIntPtr();
auto konstTmp = newTempIntPtr();
cc.mov(konstTmp, asmjit::imm_ptr(&konstf[C]));
cc.ucomisd(regF[B], x86::qword_ptr(konstTmp));
if (check) {
@ -1031,15 +1031,15 @@ void JitCompiler::EmitEQF_K()
}
}
else {
auto konstTmp = cc.newIntPtr();
auto subTmp = cc.newXmmSd();
auto konstTmp = newTempIntPtr();
auto subTmp = newTempXmmSd();
const int64_t absMaskInt = 0x7FFFFFFFFFFFFFFF;
auto absMask = cc.newDoubleConst(kConstScopeLocal, reinterpret_cast<const double&>(absMaskInt));
auto absMaskXmm = cc.newXmmPd();
auto absMaskXmm = newTempXmmPd();
auto epsilon = cc.newDoubleConst(kConstScopeLocal, VM_EPSILON);
auto epsilonXmm = cc.newXmmSd();
auto epsilonXmm = newTempXmmSd();
cc.mov(konstTmp, asmjit::imm_ptr(&konstf[C]));
@ -1072,8 +1072,8 @@ void JitCompiler::EmitLTF_RK()
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
if (static_cast<bool>(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_RK.\n");
auto constTmp = cc.newIntPtr();
auto xmmTmp = cc.newXmmSd();
auto constTmp = newTempIntPtr();
auto xmmTmp = newTempXmmSd();
cc.mov(constTmp, asmjit::imm_ptr(&konstf[C]));
cc.movsd(xmmTmp, asmjit::x86::qword_ptr(constTmp));
@ -1088,7 +1088,7 @@ void JitCompiler::EmitLTF_KR()
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
if (static_cast<bool>(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_KR.\n");
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstf[B]));
cc.ucomisd(regF[C], asmjit::x86::qword_ptr(tmp));
@ -1113,8 +1113,8 @@ void JitCompiler::EmitLEF_RK()
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
if (static_cast<bool>(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LEF_RK.\n");
auto constTmp = cc.newIntPtr();
auto xmmTmp = cc.newXmmSd();
auto constTmp = newTempIntPtr();
auto xmmTmp = newTempXmmSd();
cc.mov(constTmp, asmjit::imm_ptr(&konstf[C]));
cc.movsd(xmmTmp, asmjit::x86::qword_ptr(constTmp));
@ -1129,7 +1129,7 @@ void JitCompiler::EmitLEF_KR()
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
if (static_cast<bool>(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LEF_KR.\n");
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(&konstf[B]));
cc.ucomisd(regF[C], asmjit::x86::qword_ptr(tmp));
@ -1144,7 +1144,7 @@ void JitCompiler::EmitLEF_KR()
void JitCompiler::EmitNEGV2()
{
auto mask = cc.newDoubleConst(asmjit::kConstScopeLocal, -0.0);
auto maskXmm = cc.newXmmSd();
auto maskXmm = newTempXmmSd();
cc.movsd(maskXmm, mask);
cc.movsd(regF[A], regF[B]);
cc.xorpd(regF[A], maskXmm);
@ -1176,7 +1176,7 @@ void JitCompiler::EmitDOTV2_RR()
{
auto rc0 = CheckRegF(C, A);
auto rc1 = CheckRegF(C + 1, A);
auto tmp = cc.newXmmSd();
auto tmp = newTempXmmSd();
cc.movsd(regF[A], regF[B]);
cc.mulsd(regF[A], rc0);
cc.movsd(tmp, regF[B + 1]);
@ -1195,7 +1195,7 @@ void JitCompiler::EmitMULVF2_RR()
void JitCompiler::EmitMULVF2_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.movsd(regF[A], regF[B]);
cc.movsd(regF[A + 1], regF[B + 1]);
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
@ -1214,7 +1214,7 @@ void JitCompiler::EmitDIVVF2_RR()
void JitCompiler::EmitDIVVF2_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.movsd(regF[A], regF[B]);
cc.movsd(regF[A + 1], regF[B + 1]);
cc.mov(tmp, asmjit::imm_ptr(&konstf[C]));
@ -1226,7 +1226,7 @@ void JitCompiler::EmitLENV2()
{
auto rb0 = CheckRegF(B, A);
auto rb1 = CheckRegF(B + 1, A);
auto tmp = cc.newXmmSd();
auto tmp = newTempXmmSd();
cc.movsd(regF[A], regF[B]);
cc.mulsd(regF[A], rb0);
cc.movsd(tmp, rb1);
@ -1273,7 +1273,7 @@ void JitCompiler::EmitEQV2_K()
void JitCompiler::EmitNEGV3()
{
auto mask = cc.newDoubleConst(asmjit::kConstScopeLocal, -0.0);
auto maskXmm = cc.newXmmSd();
auto maskXmm = newTempXmmSd();
cc.movsd(maskXmm, mask);
cc.movsd(regF[A], regF[B]);
cc.xorpd(regF[A], maskXmm);
@ -1316,7 +1316,7 @@ void JitCompiler::EmitDOTV3_RR()
auto rc0 = CheckRegF(C, A);
auto rc1 = CheckRegF(C + 1, A);
auto rc2 = CheckRegF(C + 2, A);
auto tmp = cc.newXmmSd();
auto tmp = newTempXmmSd();
cc.movsd(regF[A], regF[B]);
cc.mulsd(regF[A], rc0);
cc.movsd(tmp, rb1);
@ -1329,7 +1329,7 @@ void JitCompiler::EmitDOTV3_RR()
void JitCompiler::EmitCROSSV_RR()
{
auto tmp = cc.newXmmSd();
auto tmp = newTempXmmSd();
auto a0 = CheckRegF(B, A);
auto a1 = CheckRegF(B + 1, A + 1);
@ -1373,7 +1373,7 @@ void JitCompiler::EmitMULVF3_RR()
void JitCompiler::EmitMULVF3_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.movsd(regF[A], regF[B]);
cc.movsd(regF[A + 1], regF[B + 1]);
cc.movsd(regF[A + 2], regF[B + 2]);
@ -1396,7 +1396,7 @@ void JitCompiler::EmitDIVVF3_RR()
void JitCompiler::EmitDIVVF3_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.movsd(regF[A], regF[B]);
cc.movsd(regF[A + 1], regF[B + 1]);
cc.movsd(regF[A + 2], regF[B + 2]);
@ -1410,7 +1410,7 @@ void JitCompiler::EmitLENV3()
{
auto rb1 = CheckRegF(B + 1, A);
auto rb2 = CheckRegF(B + 2, A);
auto tmp = cc.newXmmSd();
auto tmp = newTempXmmSd();
cc.movsd(regF[A], regF[B]);
cc.mulsd(regF[A], regF[B]);
cc.movsd(tmp, rb1);
@ -1469,7 +1469,7 @@ void JitCompiler::EmitEQV3_K()
void JitCompiler::EmitADDA_RR()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
auto label = cc.newLabel();
cc.mov(tmp, regA[B]);
@ -1478,7 +1478,7 @@ void JitCompiler::EmitADDA_RR()
cc.cmp(tmp, 0);
cc.je(label);
auto tmpptr = cc.newIntPtr();
auto tmpptr = newTempIntPtr();
cc.mov(tmpptr, regD[C]);
cc.add(tmp, tmpptr);
@ -1488,7 +1488,7 @@ void JitCompiler::EmitADDA_RR()
void JitCompiler::EmitADDA_RK()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
auto label = cc.newLabel();
cc.mov(tmp, regA[B]);
@ -1505,7 +1505,7 @@ void JitCompiler::EmitADDA_RK()
void JitCompiler::EmitSUBA()
{
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.sub(tmp, regD[C]);
cc.mov(regA[A], tmp);
@ -1523,7 +1523,7 @@ void JitCompiler::EmitEQA_R()
void JitCompiler::EmitEQA_K()
{
EmitComparisonOpcode([&](bool check, asmjit::Label& fail, asmjit::Label& success) {
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, asmjit::imm_ptr(konsta[C].v));
cc.cmp(regA[B], tmp);
if (check) cc.je(fail);
@ -1533,7 +1533,7 @@ void JitCompiler::EmitEQA_K()
void JitCompiler::CallSqrt(const asmjit::X86Xmm &a, const asmjit::X86Xmm &b)
{
auto result = cc.newXmmSd();
auto result = newResultXmmSd();
auto call = CreateCall<double, double>(g_sqrt);
call->setRet(0, result);
call->setArg(0, b);

View file

@ -50,7 +50,7 @@ void JitCompiler::EmitCAST()
cc.cvtsi2sd(regF[A], regD[B]);
break;
case CAST_U2F:
tmp = cc.newInt64();
tmp = newTempInt64();
cc.xor_(tmp, tmp);
cc.mov(tmp.r32(), regD[B]);
cc.cvtsi2sd(regF[A], tmp);
@ -59,7 +59,7 @@ void JitCompiler::EmitCAST()
cc.cvttsd2si(regD[A], regF[B]);
break;
case CAST_F2U:
tmp = cc.newInt64();
tmp = newTempInt64();
cc.cvttsd2si(tmp, regF[B]);
cc.mov(regD[A], tmp.r32());
break;
@ -97,21 +97,21 @@ void JitCompiler::EmitCAST()
call->setArg(1, regA[B]);
break;
case CAST_S2I:
resultD = cc.newInt32();
resultD = newResultInt32();
call = CreateCall<int, FString*>([](FString *b) -> int { return (VM_SWORD)b->ToLong(); });
call->setRet(0, resultD);
call->setArg(0, regS[B]);
cc.mov(regD[A], resultD);
break;
case CAST_S2F:
resultF = cc.newXmmSd();
resultF = newResultXmmSd();
call = CreateCall<double, FString*>([](FString *b) -> double { return b->ToDouble(); });
call->setRet(0, resultF);
call->setArg(0, regS[B]);
cc.movsd(regF[A], resultF);
break;
case CAST_S2N:
resultD = cc.newInt32();
resultD = newResultInt32();
call = CreateCall<int, FString*>([](FString *b) -> int { return b->Len() == 0 ? FName(NAME_None) : FName(*b); });
call->setRet(0, resultD);
call->setArg(0, regS[B]);
@ -123,7 +123,7 @@ void JitCompiler::EmitCAST()
call->setArg(1, regD[B]);
break;
case CAST_S2Co:
resultD = cc.newInt32();
resultD = newResultInt32();
call = CreateCall<int, FString*>([](FString *b) -> int { return V_GetColor(nullptr, *b); });
call->setRet(0, resultD);
call->setArg(0, regS[B]);
@ -135,7 +135,7 @@ void JitCompiler::EmitCAST()
call->setArg(1, regD[B]);
break;
case CAST_S2So:
resultD = cc.newInt32();
resultD = newResultInt32();
call = CreateCall<int, FString*>([](FString *b) -> int { return FSoundID(*b); });
call->setRet(0, resultD);
call->setArg(0, regS[B]);
@ -170,8 +170,8 @@ void JitCompiler::EmitCASTB()
}
else if (C == CASTB_F)
{
auto zero = cc.newXmm();
auto one = cc.newInt32();
auto zero = newTempXmmSd();
auto one = newTempInt32();
cc.xorpd(zero, zero);
cc.mov(one, 1);
cc.ucomisd(regF[A], zero);
@ -185,7 +185,7 @@ void JitCompiler::EmitCASTB()
}
else
{
auto result = cc.newInt32();
auto result = newResultInt32();
auto call = CreateCall<int, FString*>([](FString *s) -> int { return s->Len() > 0; });
call->setRet(0, result);
call->setArg(0, regS[B]);
@ -195,7 +195,7 @@ void JitCompiler::EmitCASTB()
void JitCompiler::EmitDYNCAST_R()
{
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<DObject*, DObject*, PClass*>([](DObject *obj, PClass *cls) -> DObject* {
return (obj && obj->IsKindOf(cls)) ? obj : nullptr;
});
@ -207,8 +207,8 @@ void JitCompiler::EmitDYNCAST_R()
void JitCompiler::EmitDYNCAST_K()
{
auto result = cc.newIntPtr();
auto c = cc.newIntPtr();
auto result = newResultIntPtr();
auto c = newTempIntPtr();
cc.mov(c, asmjit::imm_ptr(konsta[C].o));
auto call = CreateCall<DObject*, DObject*, PClass*>([](DObject *obj, PClass *cls) -> DObject* {
return (obj && obj->IsKindOf(cls)) ? obj : nullptr;
@ -221,7 +221,7 @@ void JitCompiler::EmitDYNCAST_K()
void JitCompiler::EmitDYNCASTC_R()
{
auto result = cc.newIntPtr();
auto result = newResultIntPtr();
auto call = CreateCall<PClass*, PClass*, PClass*>([](PClass *cls1, PClass *cls2) -> PClass* {
return (cls1 && cls1->IsDescendantOf(cls2)) ? cls1 : nullptr;
});
@ -234,8 +234,8 @@ void JitCompiler::EmitDYNCASTC_R()
void JitCompiler::EmitDYNCASTC_K()
{
using namespace asmjit;
auto result = cc.newIntPtr();
auto c = cc.newIntPtr();
auto result = newResultIntPtr();
auto c = newTempIntPtr();
cc.mov(c, asmjit::imm_ptr(konsta[C].o));
typedef PClass*(*FuncPtr)(PClass*, PClass*);
auto call = CreateCall<PClass*, PClass*, PClass*>([](PClass *cls1, PClass *cls2) -> PClass* {

View file

@ -64,7 +64,7 @@ void JitCompiler::EmitSDP_R()
void JitCompiler::EmitSS()
{
EmitNullPointerThrow(A, X_WRITE_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.lea(ptr, asmjit::x86::ptr(regA[A], konstd[C]));
auto call = CreateCall<void, FString*, FString*>(&JitCompiler::CallAssignString);
call->setArg(0, ptr);
@ -74,7 +74,7 @@ void JitCompiler::EmitSS()
void JitCompiler::EmitSS_R()
{
EmitNullPointerThrow(A, X_WRITE_NIL);
auto ptr = cc.newIntPtr();
auto ptr = newTempIntPtr();
cc.lea(ptr, asmjit::x86::ptr(regA[A], regD[C]));
auto call = CreateCall<void, FString*, FString*>(&JitCompiler::CallAssignString);
call->setArg(0, ptr);
@ -112,7 +112,7 @@ void JitCompiler::EmitSP_R()
void JitCompiler::EmitSV2()
{
EmitNullPointerThrow(B, X_WRITE_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, konstd[C]);
cc.movsd(asmjit::x86::qword_ptr(tmp), regF[B]);
@ -122,7 +122,7 @@ void JitCompiler::EmitSV2()
void JitCompiler::EmitSV2_R()
{
EmitNullPointerThrow(B, X_WRITE_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, regD[C]);
cc.movsd(asmjit::x86::qword_ptr(tmp), regF[B]);
@ -132,7 +132,7 @@ void JitCompiler::EmitSV2_R()
void JitCompiler::EmitSV3()
{
EmitNullPointerThrow(B, X_WRITE_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, konstd[C]);
cc.movsd(asmjit::x86::qword_ptr(tmp), regF[B]);
@ -143,7 +143,7 @@ void JitCompiler::EmitSV3()
void JitCompiler::EmitSV3_R()
{
EmitNullPointerThrow(B, X_WRITE_NIL);
auto tmp = cc.newIntPtr();
auto tmp = newTempIntPtr();
cc.mov(tmp, regA[B]);
cc.add(tmp, regD[C]);
cc.movsd(asmjit::x86::qword_ptr(tmp), regF[B]);
@ -154,8 +154,8 @@ void JitCompiler::EmitSV3_R()
void JitCompiler::EmitSBIT()
{
EmitNullPointerThrow(B, X_WRITE_NIL);
auto tmp1 = cc.newInt32();
auto tmp2 = cc.newInt32();
auto tmp1 = newTempInt32();
auto tmp2 = newTempInt32();
cc.mov(tmp1, asmjit::x86::byte_ptr(regA[A]));
cc.mov(tmp2, tmp1);
cc.or_(tmp1, (int)C);

View file

@ -100,6 +100,34 @@ private:
template<typename RetType, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
asmjit::CCFuncCall *CreateCall(RetType(*func)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)) { return cc.call(asmjit::imm_ptr(reinterpret_cast<void*>(static_cast<RetType(*)(P1, P2, P3, P4, P5, P6, P7)>(func))), asmjit::FuncSignature7<RetType, P1, P2, P3, P4, P5, P6, P7>()); }
size_t tmpPosInt32, tmpPosInt64, tmpPosIntPtr, tmpPosXmmSd, tmpPosXmmSs, tmpPosXmmPd, resultPosInt32, resultPosIntPtr, resultPosXmmSd;
std::vector<asmjit::X86Gp> regTmpInt32, regTmpInt64, regTmpIntPtr, regResultInt32, regResultIntPtr;
std::vector<asmjit::X86Xmm> regTmpXmmSd, regTmpXmmSs, regTmpXmmPd, regResultXmmSd;
void ResetTemp()
{
tmpPosInt32 = 0;
tmpPosInt64 = 0;
tmpPosIntPtr = 0;
tmpPosXmmSd = 0;
tmpPosXmmSs = 0;
tmpPosXmmPd = 0;
resultPosInt32 = 0;
resultPosIntPtr = 0;
resultPosXmmSd = 0;
}
asmjit::X86Gp newTempInt32() { if (tmpPosInt32 == regTmpInt32.size()) regTmpInt32.push_back(cc.newInt32()); return regTmpInt32[tmpPosInt32++]; }
asmjit::X86Gp newTempInt64() { if (tmpPosInt64 == regTmpInt64.size()) regTmpInt64.push_back(cc.newInt64()); return regTmpInt64[tmpPosInt64++]; }
asmjit::X86Gp newTempIntPtr() { if (tmpPosIntPtr == regTmpIntPtr.size()) regTmpIntPtr.push_back(cc.newIntPtr()); return regTmpIntPtr[tmpPosIntPtr++]; }
asmjit::X86Xmm newTempXmmSd() { if (tmpPosXmmSd == regTmpXmmSd.size()) regTmpXmmSd.push_back(cc.newXmmSd()); return regTmpXmmSd[tmpPosXmmSd++]; }
asmjit::X86Xmm newTempXmmSs() { if (tmpPosXmmSs == regTmpXmmSs.size()) regTmpXmmSs.push_back(cc.newXmmSs()); return regTmpXmmSs[tmpPosXmmSs++]; }
asmjit::X86Xmm newTempXmmPd() { if (tmpPosXmmPd == regTmpXmmPd.size()) regTmpXmmPd.push_back(cc.newXmmPd()); return regTmpXmmPd[tmpPosXmmPd++]; }
asmjit::X86Gp newResultInt32() { if (resultPosInt32 == regResultInt32.size()) regResultInt32.push_back(cc.newInt32()); return regResultInt32[resultPosInt32++]; }
asmjit::X86Gp newResultIntPtr() { if (resultPosIntPtr == regResultIntPtr.size()) regResultIntPtr.push_back(cc.newIntPtr()); return regResultIntPtr[resultPosIntPtr++]; }
asmjit::X86Xmm newResultXmmSd() { if (resultPosXmmSd == regResultXmmSd.size()) regResultXmmSd.push_back(cc.newXmmSd()); return regResultXmmSd[resultPosXmmSd++]; }
void EmitNullPointerThrow(int index, EVMAbortException reason);
void EmitThrowException(EVMAbortException reason);
void EmitThrowException(EVMAbortException reason, asmjit::X86Gp arg1);