Skip to content

Commit 2a0ae18

Browse files
authored
Fixed various recompiler issues and added functionality: (#13108)
* 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.
1 parent ea130bc commit 2a0ae18

File tree

9 files changed

+1743
-874
lines changed

9 files changed

+1743
-874
lines changed

src/devices/cpu/drcbec.cpp

Lines changed: 132 additions & 47 deletions
Large diffs are not rendered by default.

src/devices/cpu/drcbex64.cpp

Lines changed: 615 additions & 400 deletions
Large diffs are not rendered by default.

src/devices/cpu/drcbex64.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class drcbe_x64 : public drcbe_interface
135135
void op_mapvar(asmjit::x86::Assembler &a, const uml::instruction &inst);
136136

137137
void op_nop(asmjit::x86::Assembler &a, const uml::instruction &inst);
138+
void op_break(asmjit::x86::Assembler &a, const uml::instruction &inst);
138139
void op_debug(asmjit::x86::Assembler &a, const uml::instruction &inst);
139140
void op_exit(asmjit::x86::Assembler &a, const uml::instruction &inst);
140141
void op_hashjmp(asmjit::x86::Assembler &a, const uml::instruction &inst);
@@ -149,6 +150,7 @@ class drcbe_x64 : public drcbe_interface
149150
void op_getfmod(asmjit::x86::Assembler &a, const uml::instruction &inst);
150151
void op_getexp(asmjit::x86::Assembler &a, const uml::instruction &inst);
151152
void op_getflgs(asmjit::x86::Assembler &a, const uml::instruction &inst);
153+
void op_setflgs(asmjit::x86::Assembler &a, const uml::instruction &inst);
152154
void op_save(asmjit::x86::Assembler &a, const uml::instruction &inst);
153155
void op_restore(asmjit::x86::Assembler &a, const uml::instruction &inst);
154156

@@ -171,7 +173,9 @@ class drcbe_x64 : public drcbe_interface
171173
void op_subc(asmjit::x86::Assembler &a, const uml::instruction &inst);
172174
void op_cmp(asmjit::x86::Assembler &a, const uml::instruction &inst);
173175
void op_mulu(asmjit::x86::Assembler &a, const uml::instruction &inst);
176+
void op_mululw(asmjit::x86::Assembler &a, const uml::instruction &inst);
174177
void op_muls(asmjit::x86::Assembler &a, const uml::instruction &inst);
178+
void op_mulslw(asmjit::x86::Assembler &a, const uml::instruction &inst);
175179
void op_divu(asmjit::x86::Assembler &a, const uml::instruction &inst);
176180
void op_divs(asmjit::x86::Assembler &a, const uml::instruction &inst);
177181
void op_and(asmjit::x86::Assembler &a, const uml::instruction &inst);
@@ -208,7 +212,7 @@ class drcbe_x64 : public drcbe_interface
208212
// alu and shift operation helpers
209213
static bool ones(u64 const value, unsigned const size) noexcept { return (size == 4) ? u32(value) == 0xffffffffU : value == 0xffffffff'ffffffffULL; }
210214
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; });
211-
void shift_op_param(asmjit::x86::Assembler &a, asmjit::x86::Inst::Id const opcode, asmjit::Operand const &dst, be_parameter const &param);
215+
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);
212216

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

232+
void calculate_status_flags(asmjit::x86::Assembler &a, uint32_t instsize, asmjit::Operand const &dst, u8 flags);
233+
void calculate_status_flags_mul(asmjit::x86::Assembler &a, uint32_t instsize, asmjit::x86::Gp const &lo, asmjit::x86::Gp const &hi);
234+
void calculate_status_flags_mul_low(asmjit::x86::Assembler &a, uint32_t instsize, asmjit::x86::Gp const &lo);
235+
228236
size_t emit(asmjit::CodeHolder &ch);
229237

230238
// internal state

0 commit comments

Comments
 (0)