Merge pull request #575 from Gutawer/asmjit

Implemented SS_R, LCS_R, and LKS_R
This commit is contained in:
Magnus Norddahl 2018-09-15 13:09:07 +02:00 committed by GitHub
commit c505e4eb79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 5 deletions

View File

@ -150,10 +150,7 @@ bool JitCompiler::CanJit(VMScriptFunction *sfunc)
{
default:
break;
case OP_LKS_R:
case OP_LFP:
case OP_LCS_R:
case OP_SS_R:
case OP_IJMP:
case OP_TAIL:
case OP_TAIL_K:

View File

@ -48,7 +48,22 @@ void JitCompiler::EmitLKF_R()
void JitCompiler::EmitLKS_R()
{
I_FatalError("EmitLKS_R not implemented\n");
auto ptr = cc.newIntPtr();
cc.mov(ptr, ToMemAddress(konsts));
auto offset = cc.newIntPtr();
cc.mov(offset, regD[B]);
#ifdef ASMJIT_ARCH_X64
static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 8");
cc.shl(offset, 3);
#else
static_assert(sizeof(FString) == 4, "sizeof(FString) needs to be 4");
cc.shl(offset, 2);
#endif
cc.add(ptr, offset);
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))),
asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, regS[A]);
call->setArg(1, ptr);
}
void JitCompiler::EmitLKP_R()
@ -315,7 +330,19 @@ void JitCompiler::EmitLCS()
void JitCompiler::EmitLCS_R()
{
I_FatalError("EmitLCS_R not implemented\n");
EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[B]);
auto tmp = cc.newIntPtr();
cc.mov(tmp, regD[C]);
cc.add(ptr, tmp);
auto loadLambda = [](FString* to, char** from) -> void {
*to = *from;
};
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, char**)>(loadLambda))),
asmjit::FuncSignature2<void, FString*, char**>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, regS[A]);
call->setArg(1, ptr);
}
void JitCompiler::EmitLBIT()