mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 23:12:24 +00:00
Merge pull request #581 from Gutawer/asmjit
Changed a bunch of manual address additions in string opcodes to leas
This commit is contained in:
commit
30fb6268bd
3 changed files with 12 additions and 27 deletions
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue