Skip to content

Commit

Permalink
Fixed various recompiler issues and added functionality: (#13108)
Browse files Browse the repository at this point in the history
* cpu/uml.cpp: Added BREAK, SETFLGS, MULSLW and MULULW opcodes.
* cpu/uml.cpp: Limit range of immediate shift count arguments for consistency.
* cpu/uml.cpp: Fix simplification of multiplication and division operations.
* cpu/drcbec.cpp: Added more methods of accessing OP_CARRY.
* cpu/drcbec.cpp: Fixed flag calculation for BSWAP and MULS opcodes.
* cpu/drcbec.cpp: Made calculation for shift and rotation opcodes consistent.
* cpu/drcbec.cpp: Return mapvar register ID instead of value for mapvars.
* cpu/drcbex64.cpp, cpu/drcbex86.cpp: Fixed bugs in various opcodes to make them behave like the C backend.
* cpu/drcbex64.cpp: Fixed SAVE, RESTORE and SETFMOD.
* cpu/powerpc: Implement MULLWx and MULLWOx using the new MULSLW opcode.
  • Loading branch information
987123879113 authored Dec 28, 2024
1 parent ea130bc commit 2a0ae18
Show file tree
Hide file tree
Showing 9 changed files with 1,743 additions and 874 deletions.
179 changes: 132 additions & 47 deletions src/devices/cpu/drcbec.cpp

Large diffs are not rendered by default.

1,015 changes: 615 additions & 400 deletions src/devices/cpu/drcbex64.cpp

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/devices/cpu/drcbex64.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class drcbe_x64 : public drcbe_interface
void op_mapvar(asmjit::x86::Assembler &a, const uml::instruction &inst);

void op_nop(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_break(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_debug(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_exit(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_hashjmp(asmjit::x86::Assembler &a, const uml::instruction &inst);
Expand All @@ -149,6 +150,7 @@ class drcbe_x64 : public drcbe_interface
void op_getfmod(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_getexp(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_getflgs(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_setflgs(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_save(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_restore(asmjit::x86::Assembler &a, const uml::instruction &inst);

Expand All @@ -171,7 +173,9 @@ class drcbe_x64 : public drcbe_interface
void op_subc(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_cmp(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_mulu(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_mululw(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_muls(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_mulslw(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_divu(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_divs(asmjit::x86::Assembler &a, const uml::instruction &inst);
void op_and(asmjit::x86::Assembler &a, const uml::instruction &inst);
Expand Down Expand Up @@ -208,7 +212,7 @@ class drcbe_x64 : public drcbe_interface
// alu and shift operation helpers
static bool ones(u64 const value, unsigned const size) noexcept { return (size == 4) ? u32(value) == 0xffffffffU : value == 0xffffffff'ffffffffULL; }
void alu_op_param(asmjit::x86::Assembler &a, asmjit::x86::Inst::Id const opcode, asmjit::Operand const &dst, be_parameter const &param, std::function<bool(asmjit::x86::Assembler &a, asmjit::Operand const &dst, be_parameter const &src)> optimize = [](asmjit::x86::Assembler &a, asmjit::Operand dst, be_parameter const &src) { return false; });
void shift_op_param(asmjit::x86::Assembler &a, asmjit::x86::Inst::Id const opcode, asmjit::Operand const &dst, be_parameter const &param);
void shift_op_param(asmjit::x86::Assembler &a, asmjit::x86::Inst::Id const opcode, size_t opsize, asmjit::Operand const &dst, be_parameter const &param, bool update_flags);

// parameter helpers
void mov_reg_param(asmjit::x86::Assembler &a, asmjit::x86::Gp const &reg, be_parameter const &param, bool const keepflags = false);
Expand All @@ -225,6 +229,10 @@ class drcbe_x64 : public drcbe_interface
void movsd_r128_p64(asmjit::x86::Assembler &a, asmjit::x86::Xmm const &reg, be_parameter const &param);
void movsd_p64_r128(asmjit::x86::Assembler &a, be_parameter const &param, asmjit::x86::Xmm const &reg);

void calculate_status_flags(asmjit::x86::Assembler &a, uint32_t instsize, asmjit::Operand const &dst, u8 flags);
void calculate_status_flags_mul(asmjit::x86::Assembler &a, uint32_t instsize, asmjit::x86::Gp const &lo, asmjit::x86::Gp const &hi);
void calculate_status_flags_mul_low(asmjit::x86::Assembler &a, uint32_t instsize, asmjit::x86::Gp const &lo);

size_t emit(asmjit::CodeHolder &ch);

// internal state
Expand Down
Loading

0 comments on commit 2a0ae18

Please sign in to comment.