From f81192373fd3e8744d298f3e4358094e0b0bceca Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Mon, 17 Aug 2015 21:51:57 +0200 Subject: [PATCH] PPU/LLVM: Replace magic number with opcode enum in GetBranchTypeFromInstruction. --- rpcs3/Emu/Cell/PPULLVMRecompiler.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp b/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp index 84e8d912a0..a28e2c5872 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp +++ b/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp @@ -701,23 +701,25 @@ u32 ppu_recompiler_llvm::CPUHybridDecoderRecompiler::ExecuteFunction(PPUThread * } /// Get the branch type from a branch instruction -static BranchType GetBranchTypeFromInstruction(u32 instruction) { - u32 field1 = instruction >> 26; +static BranchType GetBranchTypeFromInstruction(u32 instruction) +{ + u32 instructionOpcode = PPU_instr::fields::OPCD(instruction); u32 lk = instruction & 1; - if (field1 == 16 || field1 == 18) + if (instructionOpcode == PPU_opcodes::PPU_MainOpcodes::B || + instructionOpcode == PPU_opcodes::PPU_MainOpcodes::BC) return lk ? BranchType::FunctionCall : BranchType::LocalBranch; - if (field1 == 19) { - u32 field2 = (instruction >> 1) & 0x3FF; - if (field2 == 16) + if (instructionOpcode == PPU_opcodes::PPU_MainOpcodes::G_13) { + u32 G13Opcode = PPU_instr::fields::GD_13(instruction); + if (G13Opcode == PPU_opcodes::G_13Opcodes::BCLR) return lk ? BranchType::FunctionCall : BranchType::Return; - if (field2 == 528) + if (G13Opcode == PPU_opcodes::G_13Opcodes::BCCTR) return lk ? BranchType::FunctionCall : BranchType::LocalBranch; return BranchType::NonBranch; } - if (field1 == 1 && (instruction & EIF_PERFORM_BLR)) // classify HACK instruction + if (instructionOpcode == PPU_opcodes::PPU_MainOpcodes::HACK && (instruction & EIF_PERFORM_BLR)) // classify HACK instruction return instruction & EIF_USE_BRANCH ? BranchType::FunctionCall : BranchType::Return; - if (field1 == 1 && (instruction & EIF_USE_BRANCH)) + if (instructionOpcode == PPU_opcodes::PPU_MainOpcodes::HACK && (instruction & EIF_USE_BRANCH)) return BranchType::LocalBranch; return BranchType::NonBranch; }