diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index 8836cf8fc2..1070c15660 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -265,8 +265,7 @@ void JitCompiler::Setup() FString regname; regname.Format("regS%d", i); regS[i] = cc.newIntPtr(regname.GetChars()); - cc.mov(regS[i], frameS); - if (i != 0) cc.add(regS[i], (int)(i * sizeof(FString))); + cc.lea(regS[i], x86::ptr(frameS, i * sizeof(FString))); } } if (sfunc->NumRegA > 0) diff --git a/src/scripting/vm/jit_load.cpp b/src/scripting/vm/jit_load.cpp index 81035f5b82..44fff4d1c1 100644 --- a/src/scripting/vm/jit_load.cpp +++ b/src/scripting/vm/jit_load.cpp @@ -50,18 +50,16 @@ void JitCompiler::EmitLKF_R() void JitCompiler::EmitLKS_R() { + auto base = cc.newIntPtr(); + cc.mov(base, ToMemAddress(konsts + C)); auto ptr = cc.newIntPtr(); - cc.mov(ptr, ToMemAddress(konsts + C)); - 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); + cc.lea(ptr, asmjit::x86::ptr(base, regD[B], 3)); #else 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 - cc.add(ptr, offset); auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(CallAssignString))), asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); call->setArg(0, regS[A]); @@ -213,8 +211,7 @@ void JitCompiler::EmitLS() { EmitNullPointerThrow(B, X_READ_NIL); auto ptr = cc.newIntPtr(); - cc.mov(ptr, regA[B]); - cc.add(ptr, konstd[C]); + cc.lea(ptr, asmjit::x86::ptr(regA[B], konstd[C])); auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(CallAssignString))), asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); call->setArg(0, regS[A]); @@ -225,10 +222,7 @@ void JitCompiler::EmitLS_R() { 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); + cc.lea(ptr, asmjit::x86::ptr(regA[B], regD[C])); auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(CallAssignString))), asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); call->setArg(0, regS[A]); @@ -327,8 +321,7 @@ void JitCompiler::EmitLCS() { EmitNullPointerThrow(B, X_READ_NIL); auto ptr = cc.newIntPtr(); - cc.mov(ptr, regA[B]); - cc.add(ptr, konstd[C]); + cc.lea(ptr, asmjit::x86::ptr(regA[B], konstd[C])); auto loadLambda = [](FString* to, char** from) -> void { *to = *from; }; @@ -342,10 +335,7 @@ void JitCompiler::EmitLCS_R() { 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); + cc.lea(ptr, asmjit::x86::ptr(regA[B], regD[C])); auto loadLambda = [](FString* to, char** from) -> void { *to = *from; }; diff --git a/src/scripting/vm/jit_store.cpp b/src/scripting/vm/jit_store.cpp index 1584d0afe3..2ea845801d 100644 --- a/src/scripting/vm/jit_store.cpp +++ b/src/scripting/vm/jit_store.cpp @@ -65,22 +65,18 @@ void JitCompiler::EmitSS() { EmitNullPointerThrow(A, X_WRITE_NIL); auto ptr = cc.newIntPtr(); - cc.mov(ptr, regA[A]); - cc.add(ptr, konstd[C]); + cc.lea(ptr, asmjit::x86::ptr(regA[A], konstd[C])); auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(CallAssignString))), asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); call->setArg(0, ptr); call->setArg(1, regS[B]); } - + void JitCompiler::EmitSS_R() { EmitNullPointerThrow(A, X_WRITE_NIL); auto ptr = cc.newIntPtr(); - cc.mov(ptr, regA[A]); - auto tmp = cc.newIntPtr(); - cc.mov(tmp, regD[C]); - cc.add(ptr, tmp); + cc.lea(ptr, asmjit::x86::ptr(regA[A], regD[C])); auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(CallAssignString))), asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); call->setArg(0, ptr);