Merge pull request #581 from Gutawer/asmjit

Changed a bunch of manual address additions in string opcodes to leas
This commit is contained in:
Magnus Norddahl 2018-09-15 23:57:08 +02:00 committed by GitHub
commit 30fb6268bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 27 deletions

View file

@ -265,8 +265,7 @@ void JitCompiler::Setup()
FString regname; FString regname;
regname.Format("regS%d", i); regname.Format("regS%d", i);
regS[i] = cc.newIntPtr(regname.GetChars()); regS[i] = cc.newIntPtr(regname.GetChars());
cc.mov(regS[i], frameS); cc.lea(regS[i], x86::ptr(frameS, i * sizeof(FString)));
if (i != 0) cc.add(regS[i], (int)(i * sizeof(FString)));
} }
} }
if (sfunc->NumRegA > 0) if (sfunc->NumRegA > 0)

View file

@ -50,18 +50,16 @@ void JitCompiler::EmitLKF_R()
void JitCompiler::EmitLKS_R() void JitCompiler::EmitLKS_R()
{ {
auto base = cc.newIntPtr();
cc.mov(base, ToMemAddress(konsts + C));
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, ToMemAddress(konsts + C));
auto offset = cc.newIntPtr();
cc.mov(offset, regD[B]);
#ifdef ASMJIT_ARCH_X64 #ifdef ASMJIT_ARCH_X64
static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 8"); static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 8");
cc.shl(offset, 3); cc.lea(ptr, asmjit::x86::ptr(base, regD[B], 3));
#else #else
static_assert(sizeof(FString) == 4, "sizeof(FString) needs to be 4"); static_assert(sizeof(FString) == 4, "sizeof(FString) needs to be 4");
cc.shl(offset, 2); cc.lea(ptr, asmjit::x86::ptr(base, regD[B], 2));
#endif #endif
cc.add(ptr, offset);
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))), auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))),
asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl)); asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, regS[A]); call->setArg(0, regS[A]);
@ -213,8 +211,7 @@ void JitCompiler::EmitLS()
{ {
EmitNullPointerThrow(B, X_READ_NIL); EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[B]); cc.lea(ptr, asmjit::x86::ptr(regA[B], konstd[C]));
cc.add(ptr, konstd[C]);
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))), auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))),
asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl)); asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, regS[A]); call->setArg(0, regS[A]);
@ -225,10 +222,7 @@ void JitCompiler::EmitLS_R()
{ {
EmitNullPointerThrow(B, X_READ_NIL); EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[B]); cc.lea(ptr, asmjit::x86::ptr(regA[B], regD[C]));
auto tmp = cc.newIntPtr();
cc.mov(tmp, regD[C]);
cc.add(ptr, tmp);
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))), auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))),
asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl)); asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, regS[A]); call->setArg(0, regS[A]);
@ -327,8 +321,7 @@ void JitCompiler::EmitLCS()
{ {
EmitNullPointerThrow(B, X_READ_NIL); EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[B]); cc.lea(ptr, asmjit::x86::ptr(regA[B], konstd[C]));
cc.add(ptr, konstd[C]);
auto loadLambda = [](FString* to, char** from) -> void { auto loadLambda = [](FString* to, char** from) -> void {
*to = *from; *to = *from;
}; };
@ -342,10 +335,7 @@ void JitCompiler::EmitLCS_R()
{ {
EmitNullPointerThrow(B, X_READ_NIL); EmitNullPointerThrow(B, X_READ_NIL);
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[B]); cc.lea(ptr, asmjit::x86::ptr(regA[B], regD[C]));
auto tmp = cc.newIntPtr();
cc.mov(tmp, regD[C]);
cc.add(ptr, tmp);
auto loadLambda = [](FString* to, char** from) -> void { auto loadLambda = [](FString* to, char** from) -> void {
*to = *from; *to = *from;
}; };

View file

@ -65,8 +65,7 @@ void JitCompiler::EmitSS()
{ {
EmitNullPointerThrow(A, X_WRITE_NIL); EmitNullPointerThrow(A, X_WRITE_NIL);
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[A]); cc.lea(ptr, asmjit::x86::ptr(regA[A], konstd[C]));
cc.add(ptr, konstd[C]);
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))), auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))),
asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl)); asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, ptr); call->setArg(0, ptr);
@ -77,10 +76,7 @@ void JitCompiler::EmitSS_R()
{ {
EmitNullPointerThrow(A, X_WRITE_NIL); EmitNullPointerThrow(A, X_WRITE_NIL);
auto ptr = cc.newIntPtr(); auto ptr = cc.newIntPtr();
cc.mov(ptr, regA[A]); cc.lea(ptr, asmjit::x86::ptr(regA[A], regD[C]));
auto tmp = cc.newIntPtr();
cc.mov(tmp, regD[C]);
cc.add(ptr, tmp);
auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))), auto call = cc.call(ToMemAddress(reinterpret_cast<void*>(static_cast<void(*)(FString*, FString*)>(CallAssignString))),
asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl)); asmjit::FuncSignature2<void, FString*, FString*>(asmjit::CallConv::kIdHostCDecl));
call->setArg(0, ptr); call->setArg(0, ptr);