1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Remove unnecessary asmjit::imm_ptr

This commit is contained in:
Nekotekina 2022-01-17 19:24:53 +03:00
parent 14cca55b50
commit 4704367382
7 changed files with 38 additions and 40 deletions

View File

@ -211,8 +211,6 @@ namespace asmjit
static_cast<void>(args); static_cast<void>(args);
#endif #endif
} }
using imm_ptr = Imm;
} }
// Build runtime function with asmjit::X86Assembler // Build runtime function with asmjit::X86Assembler

View File

@ -2260,17 +2260,17 @@ thread_base::native_entry thread_base::make_trampoline(u64(*entry)(thread_base*
c.sub(x86::rsp, 0x20); c.sub(x86::rsp, 0x20);
// Call entry point (TODO: support for detached threads missing?) // Call entry point (TODO: support for detached threads missing?)
c.call(imm_ptr(entry)); c.call(entry);
// Call finalize, return if zero // Call finalize, return if zero
c.mov(args[0], x86::rax); c.mov(args[0], x86::rax);
c.call(imm_ptr(static_cast<native_entry(*)(u64)>(&finalize))); c.call(static_cast<native_entry(*)(u64)>(&finalize));
c.test(x86::rax, x86::rax); c.test(x86::rax, x86::rax);
c.jz(_ret); c.jz(_ret);
// Otherwise, call it as an entry point with first arg = new current thread // Otherwise, call it as an entry point with first arg = new current thread
c.mov(x86::rbp, x86::rax); c.mov(x86::rbp, x86::rax);
c.call(imm_ptr(thread_ctrl::get_current)); c.call(thread_ctrl::get_current);
c.mov(args[0], x86::rax); c.mov(args[0], x86::rax);
c.add(x86::rsp, 0x28); c.add(x86::rsp, 0x28);
c.jmp(x86::rbp); c.jmp(x86::rbp);

View File

@ -1918,7 +1918,7 @@ std::vector<ppu_intrp_func_t>& ppu_function_manager::access(bool ghc)
c.mov(args[0], x86::rbp); c.mov(args[0], x86::rbp);
c.mov(args[2].r32(), x86::dword_ptr(args[0], ::offset32(&ppu_thread::cia))); c.mov(args[2].r32(), x86::dword_ptr(args[0], ::offset32(&ppu_thread::cia)));
c.add(args[2], x86::qword_ptr(reinterpret_cast<u64>(&vm::g_base_addr))); c.add(args[2], x86::qword_ptr(reinterpret_cast<u64>(&vm::g_base_addr)));
c.jmp(imm_ptr(list[0])); c.jmp(list[0]);
}), }),
build_function_asm<ppu_intrp_func_t>("ppu_return", [](native_asm& c, auto& args) build_function_asm<ppu_intrp_func_t>("ppu_return", [](native_asm& c, auto& args)
{ {
@ -1928,7 +1928,7 @@ std::vector<ppu_intrp_func_t>& ppu_function_manager::access(bool ghc)
c.mov(args[0], x86::rbp); c.mov(args[0], x86::rbp);
c.mov(args[2].r32(), x86::dword_ptr(args[0], ::offset32(&ppu_thread::cia))); c.mov(args[2].r32(), x86::dword_ptr(args[0], ::offset32(&ppu_thread::cia)));
c.add(args[2], x86::qword_ptr(reinterpret_cast<u64>(&vm::g_base_addr))); c.add(args[2], x86::qword_ptr(reinterpret_cast<u64>(&vm::g_base_addr)));
c.jmp(imm_ptr(list[1])); c.jmp(list[1]);
}), }),
}; };
#elif defined(ARCH_ARM64) #elif defined(ARCH_ARM64)
@ -1955,7 +1955,7 @@ u32 ppu_function_manager::add_function(ppu_intrp_func_t function)
c.mov(args[0], x86::rbp); c.mov(args[0], x86::rbp);
c.mov(args[2].r32(), x86::dword_ptr(args[0], ::offset32(&ppu_thread::cia))); c.mov(args[2].r32(), x86::dword_ptr(args[0], ::offset32(&ppu_thread::cia)));
c.add(args[2], x86::qword_ptr(reinterpret_cast<u64>(&vm::g_base_addr))); c.add(args[2], x86::qword_ptr(reinterpret_cast<u64>(&vm::g_base_addr)));
c.jmp(imm_ptr(function)); c.jmp(function);
})); }));
#elif defined(ARCH_ARM64) #elif defined(ARCH_ARM64)
list2.push_back(function); list2.push_back(function);

View File

@ -273,7 +273,7 @@ const auto ppu_recompiler_fallback_ghc = build_function_asm<void(*)(ppu_thread&
using namespace asmjit; using namespace asmjit;
c.mov(args[0], x86::rbp); c.mov(args[0], x86::rbp);
c.jmp(imm_ptr(ppu_recompiler_fallback)); c.jmp(ppu_recompiler_fallback);
}); });
#elif defined(ARCH_ARM64) #elif defined(ARCH_ARM64)
const auto ppu_recompiler_fallback_ghc = &ppu_recompiler_fallback; const auto ppu_recompiler_fallback_ghc = &ppu_recompiler_fallback;

View File

@ -843,7 +843,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
c->bind(label_diff); c->bind(label_diff);
c->inc(SPU_OFF_64(block_failure)); c->inc(SPU_OFF_64(block_failure));
c->add(x86::rsp, 0x28); c->add(x86::rsp, 0x28);
c->jmp(imm_ptr(spu_runtime::tr_dispatch)); c->jmp(spu_runtime::tr_dispatch);
} }
for (auto&& work : ::as_rvalue(std::move(after))) for (auto&& work : ::as_rvalue(std::move(after)))
@ -1014,7 +1014,7 @@ void spu_recompiler::branch_fixed(u32 target, bool absolute)
c->and_(*addr, 0x3fffc); c->and_(*addr, 0x3fffc);
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(&check_state)); c->call(&check_state);
c->jmp(local->second); c->jmp(local->second);
if (absolute) if (absolute)
@ -1047,7 +1047,7 @@ void spu_recompiler::branch_fixed(u32 target, bool absolute)
if (ppptr) if (ppptr)
{ {
c->add(x86::rsp, 0x28); c->add(x86::rsp, 0x28);
c->jmp(imm_ptr(ppptr)); c->jmp(ppptr);
} }
else else
{ {
@ -1092,7 +1092,7 @@ void spu_recompiler::branch_indirect(spu_opcode_t op, bool jt, bool ret)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->add(x86::rsp, 0x28); c->add(x86::rsp, 0x28);
c->jmp(imm_ptr(+_throw)); c->jmp(+_throw);
// Save addr in srr0 and disable interrupts // Save addr in srr0 and disable interrupts
c->bind(intr); c->bind(intr);
@ -1159,7 +1159,7 @@ void spu_recompiler::branch_indirect(spu_opcode_t op, bool jt, bool ret)
if (ppptr) if (ppptr)
{ {
c->add(x86::rsp, 0x28); c->add(x86::rsp, 0x28);
c->jmp(imm_ptr(ppptr)); c->jmp(ppptr);
} }
else else
{ {
@ -1230,9 +1230,9 @@ void spu_recompiler::fall(spu_opcode_t op)
c->and_(*addr, 0x3fffc); c->and_(*addr, 0x3fffc);
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), op.opcode); c->mov(arg1->r32(), op.opcode);
c->mov(*qw0, asmjit::imm_ptr(g_fxo->get<spu_interpreter_rt>().decode(op.opcode))); c->mov(*qw0, g_fxo->get<spu_interpreter_rt>().decode(op.opcode));
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(asmjit::imm_ptr(+gate)); c->call(+gate);
} }
void spu_recompiler::UNK(spu_opcode_t op) void spu_recompiler::UNK(spu_opcode_t op)
@ -1250,7 +1250,7 @@ void spu_recompiler::UNK(spu_opcode_t op)
c->mov(arg1->r32(), op.opcode); c->mov(arg1->r32(), op.opcode);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->add(asmjit::x86::rsp, 0x28); c->add(asmjit::x86::rsp, 0x28);
c->jmp(asmjit::imm_ptr(+gate)); c->jmp(+gate);
m_pos = -1; m_pos = -1;
} }
@ -1278,7 +1278,7 @@ void spu_recompiler::STOP(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), op.opcode & 0x3fff); c->mov(arg1->r32(), op.opcode & 0x3fff);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_stop)); c->call(spu_stop);
c->align(AlignMode::kCode, 16); c->align(AlignMode::kCode, 16);
c->bind(ret); c->bind(ret);
@ -1366,7 +1366,7 @@ void spu_recompiler::RDCH(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), +op.ra); c->mov(arg1->r32(), +op.ra);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_rdch)); c->call(spu_rdch);
c->jmp(ret); c->jmp(ret);
}); });
@ -1471,7 +1471,7 @@ void spu_recompiler::RDCH(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->lea(*arg1, SPU_OFF_128(gpr, op.rt)); c->lea(*arg1, SPU_OFF_128(gpr, op.rt));
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(asmjit::imm_ptr(g_cfg.core.spu_loop_detection ? +sub1 : +sub2)); c->call(g_cfg.core.spu_loop_detection ? +sub1 : +sub2);
return; return;
} }
case SPU_RdEventMask: case SPU_RdEventMask:
@ -1508,7 +1508,7 @@ void spu_recompiler::RDCH(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), +op.ra); c->mov(arg1->r32(), +op.ra);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_rdch)); c->call(spu_rdch);
c->movd(x86::xmm0, *addr); c->movd(x86::xmm0, *addr);
c->pslldq(x86::xmm0, 12); c->pslldq(x86::xmm0, 12);
c->movdqa(SPU_OFF_128(gpr, op.rt), x86::xmm0); c->movdqa(SPU_OFF_128(gpr, op.rt), x86::xmm0);
@ -1616,7 +1616,7 @@ void spu_recompiler::RCHCNT(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), +op.ra); c->mov(arg1->r32(), +op.ra);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_rchcnt)); c->call(spu_rchcnt);
break; break;
} }
} }
@ -2317,7 +2317,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), +op.ra); c->mov(arg1->r32(), +op.ra);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_wrch)); c->call(spu_wrch);
c->jmp(ret); c->jmp(ret);
}); });
@ -2344,7 +2344,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), MFC_WrTagMask); c->mov(arg1->r32(), MFC_WrTagMask);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_wrch)); c->call(spu_wrch);
c->jmp(ret); c->jmp(ret);
}); });
@ -2368,7 +2368,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(arg1->r32(), +op.ra); c->mov(arg1->r32(), +op.ra);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_wrch)); c->call(spu_wrch);
c->jmp(ret); c->jmp(ret);
c->bind(zero); c->bind(zero);
@ -2434,7 +2434,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
c->and_(*addr, 0x3fffc); c->and_(*addr, 0x3fffc);
c->mov(SPU_OFF_32(pc), *addr); c->mov(SPU_OFF_32(pc), *addr);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_wrch_mfc)); c->call(spu_wrch_mfc);
return; return;
} }
case MFC_WrListStallAck: case MFC_WrListStallAck:
@ -2459,7 +2459,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
c->btr(SPU_OFF_32(ch_stall_mask), arg1->r32()); c->btr(SPU_OFF_32(ch_stall_mask), arg1->r32());
c->jnc(ret); c->jnc(ret);
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(+sub)); c->call(+sub);
c->bind(ret); c->bind(ret);
return; return;
} }
@ -2471,7 +2471,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
}; };
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(+sub)); c->call(+sub);
c->mov(qw0->r32(), SPU_OFF_32(gpr, op.rt, &v128::_u32, 3)); c->mov(qw0->r32(), SPU_OFF_32(gpr, op.rt, &v128::_u32, 3));
c->mov(SPU_OFF_32(ch_dec_value), qw0->r32()); c->mov(SPU_OFF_32(ch_dec_value), qw0->r32());
return; return;
@ -2501,7 +2501,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
c->mov(arg1->r32(), +op.ra); c->mov(arg1->r32(), +op.ra);
c->mov(qw0->r32(), SPU_OFF_32(gpr, op.rt, &v128::_u32, 3)); c->mov(qw0->r32(), SPU_OFF_32(gpr, op.rt, &v128::_u32, 3));
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(imm_ptr(spu_wrch)); c->call(spu_wrch);
} }
void spu_recompiler::BIZ(spu_opcode_t op) void spu_recompiler::BIZ(spu_opcode_t op)
@ -2652,7 +2652,7 @@ void spu_recompiler::BISLED(spu_opcode_t op)
asmjit::Label branch_label = c->newLabel(); asmjit::Label branch_label = c->newLabel();
c->mov(*arg0, *cpu); c->mov(*arg0, *cpu);
c->call(asmjit::imm_ptr(+get_events)); c->call(+get_events);
c->test(*addr, 1); c->test(*addr, 1);
c->jne(branch_label); c->jne(branch_label);
@ -2792,7 +2792,7 @@ void spu_recompiler::ROTQBYBI(spu_opcode_t op)
} }
const XmmLink& va = XmmGet(op.ra, XmmType::Int); const XmmLink& va = XmmGet(op.ra, XmmType::Int);
c->mov(*qw0, asmjit::imm_ptr(+g_spu_imm.rldq_pshufb)); c->mov(*qw0, +g_spu_imm.rldq_pshufb);
c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3)); c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3));
c->and_(*addr, 0xf << 3); c->and_(*addr, 0xf << 3);
c->pshufb(va, asmjit::x86::oword_ptr(*qw0, addr->r64(), 1)); c->pshufb(va, asmjit::x86::oword_ptr(*qw0, addr->r64(), 1));
@ -2807,7 +2807,7 @@ void spu_recompiler::ROTQMBYBI(spu_opcode_t op)
} }
const XmmLink& va = XmmGet(op.ra, XmmType::Int); const XmmLink& va = XmmGet(op.ra, XmmType::Int);
c->mov(*qw0, asmjit::imm_ptr(+g_spu_imm.srdq_pshufb)); c->mov(*qw0, +g_spu_imm.srdq_pshufb);
c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3)); c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3));
c->and_(*addr, 0x1f << 3); c->and_(*addr, 0x1f << 3);
c->pshufb(va, asmjit::x86::oword_ptr(*qw0, addr->r64(), 1)); c->pshufb(va, asmjit::x86::oword_ptr(*qw0, addr->r64(), 1));
@ -2822,7 +2822,7 @@ void spu_recompiler::SHLQBYBI(spu_opcode_t op)
} }
const XmmLink& va = XmmGet(op.ra, XmmType::Int); const XmmLink& va = XmmGet(op.ra, XmmType::Int);
c->mov(*qw0, asmjit::imm_ptr(+g_spu_imm.sldq_pshufb)); c->mov(*qw0, +g_spu_imm.sldq_pshufb);
c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3)); c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3));
c->and_(*addr, 0x1f << 3); c->and_(*addr, 0x1f << 3);
c->pshufb(va, asmjit::x86::oword_ptr(*qw0, addr->r64(), 1)); c->pshufb(va, asmjit::x86::oword_ptr(*qw0, addr->r64(), 1));
@ -2945,7 +2945,7 @@ void spu_recompiler::ROTQBY(spu_opcode_t op)
} }
const XmmLink& va = XmmGet(op.ra, XmmType::Int); const XmmLink& va = XmmGet(op.ra, XmmType::Int);
c->mov(*qw0, asmjit::imm_ptr(+g_spu_imm.rldq_pshufb)); c->mov(*qw0, +g_spu_imm.rldq_pshufb);
c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3)); c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3));
c->and_(*addr, 0xf); c->and_(*addr, 0xf);
c->shl(*addr, 4); c->shl(*addr, 4);
@ -2961,7 +2961,7 @@ void spu_recompiler::ROTQMBY(spu_opcode_t op)
} }
const XmmLink& va = XmmGet(op.ra, XmmType::Int); const XmmLink& va = XmmGet(op.ra, XmmType::Int);
c->mov(*qw0, asmjit::imm_ptr(+g_spu_imm.srdq_pshufb)); c->mov(*qw0, +g_spu_imm.srdq_pshufb);
c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3)); c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3));
c->and_(*addr, 0x1f); c->and_(*addr, 0x1f);
c->shl(*addr, 4); c->shl(*addr, 4);
@ -2977,7 +2977,7 @@ void spu_recompiler::SHLQBY(spu_opcode_t op)
} }
const XmmLink& va = XmmGet(op.ra, XmmType::Int); const XmmLink& va = XmmGet(op.ra, XmmType::Int);
c->mov(*qw0, asmjit::imm_ptr(+g_spu_imm.sldq_pshufb)); c->mov(*qw0, +g_spu_imm.sldq_pshufb);
c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3)); c->mov(*addr, SPU_OFF_32(gpr, op.rb, &v128::_u32, 3));
c->and_(*addr, 0x1f); c->and_(*addr, 0x1f);
c->shl(*addr, 4); c->shl(*addr, 4);

View File

@ -207,7 +207,7 @@ DECLARE(spu_runtime::g_gateway) = built_function<spu_function_t>("spu_gateway",
c.vzeroupper(); c.vzeroupper();
} }
c.call(asmjit::imm_ptr(spu_runtime::tr_all)); c.call(spu_runtime::tr_all);
if (utils::has_avx()) if (utils::has_avx())
{ {

View File

@ -269,17 +269,17 @@ namespace
if (utils::has_ssse3()) if (utils::has_ssse3())
{ {
c.jmp(asmjit::imm_ptr(&copy_data_swap_u32_ssse3<Compare>)); c.jmp(&copy_data_swap_u32_ssse3<Compare>);
return; return;
} }
c.jmp(asmjit::imm_ptr(&copy_data_swap_u32_naive<Compare>)); c.jmp(&copy_data_swap_u32_naive<Compare>);
} }
#elif defined(ARCH_ARM64) #elif defined(ARCH_ARM64)
template <bool Compare> template <bool Compare>
void build_copy_data_swap_u32(native_asm& c, native_args& args) void build_copy_data_swap_u32(native_asm& c, native_args& args)
{ {
c.b(asmjit::imm_ptr(&copy_data_swap_u32_naive<Compare>)); c.b(&copy_data_swap_u32_naive<Compare>);
} }
#endif #endif
} }