RSP: More work getting the RSP x64 recompiler to compile tasks
This commit is contained in:
parent
38bb0b50fb
commit
f8a76f348d
|
@ -1,4 +1,5 @@
|
|||
#include <Project64-rsp-core/Hle/HleTask.h>
|
||||
#include <Project64-rsp-core/Recompiler/RspCodeBlock.h>
|
||||
#include <Project64-rsp-core/Recompiler/RspProfiling.h>
|
||||
#include <Project64-rsp-core/cpu/RSPRegisterHandlerPlugin.h>
|
||||
#include <Project64-rsp-core/cpu/RspMemory.h>
|
||||
|
@ -74,12 +75,13 @@ void CHleTask::SetupCommandList(const TASK_INFO & TaskInfo)
|
|||
m_TaskFunctions = nullptr;
|
||||
|
||||
TaskFunctions JumpFunctions;
|
||||
RspCodeBlocks Functions;
|
||||
for (uint32_t i = 0, n = JumpTableLength; i < n; i++)
|
||||
{
|
||||
uint16_t FuncAddress = *((uint16_t *)(m_DMEM + (((i << 1) + JumpTablePos) ^ 2)));
|
||||
if (FuncAddress != 0x1118)
|
||||
{
|
||||
void * FuncPtr = m_Recompiler.CompileHLETask(FuncAddress);
|
||||
void * FuncPtr = m_Recompiler.CompileHLETask(FuncAddress, Functions, 0x1118);
|
||||
JumpFunctions.emplace_back(TaskFunctionAddress(FuncAddress, FuncPtr));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -69,32 +69,31 @@ asmjit::Error RspAssembler::_log(const char * data, size_t size) noexcept
|
|||
if (m_LabelSymbols.size() > 0 && Pos != std::string::npos)
|
||||
{
|
||||
size_t len = AsmjitLog.length();
|
||||
uint32_t Value = 0;
|
||||
uint32_t Value = 0, valueLen = 0;
|
||||
for (int i = 0; i < 8 && (Pos + 1 + i) < len; i++)
|
||||
{
|
||||
char c = AsmjitLog[Pos + 1 + i];
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
Value = (Value * 10) + (c - '0');
|
||||
valueLen += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
NumberSymbolMap::iterator itr = m_LabelSymbols.find(Value);
|
||||
if (itr != m_LabelSymbols.end())
|
||||
if (valueLen > 0)
|
||||
{
|
||||
std::string::size_type endPos = Pos + 1;
|
||||
for (std::string::size_type LenSize = AsmjitLog.length(); (endPos < LenSize && isdigit((unsigned char)AsmjitLog[endPos])); endPos++)
|
||||
LabelSymbolMap::iterator itr = m_LabelSymbols.find(Value);
|
||||
if (itr != m_LabelSymbols.end())
|
||||
{
|
||||
}
|
||||
std::string LabelStr = AsmjitLog.substr(Pos, endPos - Pos);
|
||||
AsmjitLog.replace(Pos, LabelStr.length(), itr->second.Symbol);
|
||||
itr->second.Count -= 1;
|
||||
if (itr->second.Count == 0)
|
||||
{
|
||||
m_LabelSymbols.erase(itr);
|
||||
std::string::size_type endPos = Pos + 1;
|
||||
for (std::string::size_type LenSize = AsmjitLog.length(); (endPos < LenSize && isdigit((unsigned char)AsmjitLog[endPos])); endPos++)
|
||||
{
|
||||
}
|
||||
std::string LabelStr = AsmjitLog.substr(Pos, endPos - Pos);
|
||||
AsmjitLog.replace(Pos, LabelStr.length(), itr->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +139,15 @@ void RspAssembler::CompConstToVariable(void * Variable, const char * VariableNam
|
|||
cmp(asmjit::x86::dword_ptr((uint64_t)Variable), Const);
|
||||
}
|
||||
|
||||
void RspAssembler::CompX86regToVariable(void * Variable, const char * VariableName, const asmjit::x86::Gp & Reg)
|
||||
{
|
||||
if (LogAsmCode)
|
||||
{
|
||||
AddNumberSymbol((uint64_t)Variable, VariableName);
|
||||
}
|
||||
cmp(Reg, asmjit::x86::dword_ptr((uint64_t)Variable));
|
||||
}
|
||||
|
||||
void RspAssembler::JeLabel(const char * LabelName, asmjit::Label & JumpLabel)
|
||||
{
|
||||
if (LogAsmCode)
|
||||
|
@ -221,23 +229,30 @@ void RspAssembler::MoveX86regToVariable(void * Variable, const char * VariableNa
|
|||
mov(asmjit::x86::dword_ptr((uint64_t)(Variable)), Reg);
|
||||
}
|
||||
|
||||
void RspAssembler::SetgVariable(void * Variable, const char * VariableName)
|
||||
{
|
||||
if (LogAsmCode)
|
||||
{
|
||||
AddNumberSymbol((uint64_t)Variable, VariableName);
|
||||
}
|
||||
setg(asmjit::x86::byte_ptr((uint64_t)Variable));
|
||||
}
|
||||
|
||||
void RspAssembler::SetzVariable(void * Variable, const char * VariableName)
|
||||
{
|
||||
if (LogAsmCode)
|
||||
{
|
||||
AddNumberSymbol((uint64_t)Variable, VariableName);
|
||||
}
|
||||
setz(asmjit::x86::byte_ptr((uint64_t)Variable));
|
||||
}
|
||||
|
||||
void RspAssembler::AddLabelSymbol(const asmjit::Label & Label, const char * Symbol)
|
||||
{
|
||||
NumberSymbolMap::iterator itr = m_LabelSymbols.find(Label.id());
|
||||
if (itr != m_LabelSymbols.end())
|
||||
LabelSymbolMap::iterator itr = m_LabelSymbols.find(Label.id());
|
||||
if (itr == m_LabelSymbols.end())
|
||||
{
|
||||
if (strcmp(itr->second.Symbol.c_str(), Symbol) == 0)
|
||||
{
|
||||
itr->second.Count += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
__debugbreak();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LabelSymbols.emplace(std::make_pair(Label.id(), NumberSymbol{Symbol, 2}));
|
||||
m_LabelSymbols.emplace(std::make_pair(Label.id(), Symbol));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
void CallFunc(void * FunctPtr, const char * FunctName);
|
||||
void CallThis(void * ThisPtr, void * FunctPtr, const char * FunctName);
|
||||
void CompConstToVariable(void * Variable, const char * VariableName, uint32_t Const);
|
||||
void CompX86regToVariable(void * Variable, const char * VariableName, const asmjit::x86::Gp & Reg);
|
||||
void JeLabel(const char * LabelName, asmjit::Label & JumpLabel);
|
||||
void JgLabel(const char * LabelName, asmjit::Label & JumpLabel);
|
||||
void JleLabel(const char * LabelName, asmjit::Label & JumpLabel);
|
||||
|
@ -25,13 +26,16 @@ public:
|
|||
void MoveConstToVariable(void * Variable, const char * VariableName, uint32_t Const);
|
||||
void MoveVariableToX86reg(const asmjit::x86::Gp & Reg, void * Variable, const char * VariableName);
|
||||
void MoveX86regToVariable(void * Variable, const char * VariableName, const asmjit::x86::Gp & Reg);
|
||||
void SetgVariable(void * Variable, const char * VariableName);
|
||||
void SetzVariable(void * Variable, const char * VariableName);
|
||||
|
||||
void AddLabelSymbol(const asmjit::Label & Label, const char * Symbol);
|
||||
|
||||
private:
|
||||
RspAssembler();
|
||||
RspAssembler(const RspAssembler &);
|
||||
RspAssembler & operator=(const RspAssembler &);
|
||||
|
||||
void AddLabelSymbol(const asmjit::Label & Label, const char * Symbol);
|
||||
void AddNumberSymbol(uint64_t Value, const char * Symbol);
|
||||
|
||||
typedef struct
|
||||
|
@ -40,12 +44,13 @@ private:
|
|||
uint32_t Count;
|
||||
} NumberSymbol;
|
||||
|
||||
typedef std::map<uint64_t, std::string> LabelSymbolMap;
|
||||
typedef std::map<uint64_t, NumberSymbol> NumberSymbolMap;
|
||||
|
||||
void handleError(asmjit::Error err, const char * message, asmjit::BaseEmitter * origin);
|
||||
asmjit::Error _log(const char * data, size_t size) noexcept;
|
||||
std::string & m_CodeLog;
|
||||
NumberSymbolMap m_LabelSymbols;
|
||||
LabelSymbolMap m_LabelSymbols;
|
||||
NumberSymbolMap m_NumberSymbols;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include <Common/StdString.h>
|
||||
#include <Project64-rsp-core/cpu/RspSystem.h>
|
||||
|
||||
RspCodeBlock::RspCodeBlock(CRSPSystem & System, uint32_t StartAddress, RspCodeType type, RspCodeBlocks & Functions) :
|
||||
RspCodeBlock::RspCodeBlock(CRSPSystem & System, uint32_t StartAddress, RspCodeType type, uint32_t EndBlockAddress, RspCodeBlocks & Functions) :
|
||||
m_Functions(Functions),
|
||||
m_EndBlockAddress(EndBlockAddress),
|
||||
m_System(System),
|
||||
m_StartAddress(StartAddress),
|
||||
m_CodeType(type),
|
||||
|
@ -23,6 +24,11 @@ void * RspCodeBlock::GetCompiledLocation() const
|
|||
return m_CompiledLoction;
|
||||
}
|
||||
|
||||
uint32_t RspCodeBlock::GetEndBlockAddress() const
|
||||
{
|
||||
return m_EndBlockAddress;
|
||||
}
|
||||
|
||||
const RspCodeBlock::Addresses & RspCodeBlock::GetFunctionCalls() const
|
||||
{
|
||||
return m_FunctionCalls;
|
||||
|
@ -73,36 +79,37 @@ void RspCodeBlock::Analyze(void)
|
|||
uint32_t Address = m_StartAddress;
|
||||
uint8_t * IMEM = m_System.m_IMEM;
|
||||
|
||||
enum EndHleTaskOp
|
||||
{
|
||||
J_0x1118 = 0x09000446
|
||||
};
|
||||
|
||||
bool FoundEnd = false;
|
||||
for (;;)
|
||||
{
|
||||
RSPInstruction Instruction(Address, *(uint32_t *)(IMEM + (Address & 0xFFF)));
|
||||
if (Instruction.IsJump() && Instruction.Value() == J_0x1118)
|
||||
{
|
||||
if (std::find(m_End.begin(), m_End.end(), Address) == m_End.end())
|
||||
{
|
||||
m_End.insert(Address);
|
||||
}
|
||||
}
|
||||
else if (Instruction.IsJump())
|
||||
if (Instruction.IsJump())
|
||||
{
|
||||
uint32_t target = Instruction.JumpTarget();
|
||||
if (std::find(m_BranchTargets.begin(), m_BranchTargets.end(), target) == m_BranchTargets.end())
|
||||
if (target == m_EndBlockAddress)
|
||||
{
|
||||
m_BranchTargets.insert(target);
|
||||
if (std::find(m_End.begin(), m_End.end(), Address) == m_End.end())
|
||||
{
|
||||
m_End.insert(Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::find(m_BranchTargets.begin(), m_BranchTargets.end(), target) == m_BranchTargets.end())
|
||||
{
|
||||
m_BranchTargets.insert(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Instruction.IsConditionalBranch())
|
||||
{
|
||||
uint32_t target = Instruction.ConditionalBranchTarget();
|
||||
if (std::find(m_BranchTargets.begin(), m_BranchTargets.end(), target) == m_BranchTargets.end())
|
||||
if (target != m_EndBlockAddress)
|
||||
{
|
||||
m_BranchTargets.insert(target);
|
||||
if (std::find(m_BranchTargets.begin(), m_BranchTargets.end(), target) == m_BranchTargets.end())
|
||||
{
|
||||
m_BranchTargets.insert(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Instruction.IsStaticCall())
|
||||
|
@ -120,7 +127,7 @@ void RspCodeBlock::Analyze(void)
|
|||
break;
|
||||
}
|
||||
if ((m_CodeType == RspCodeType_SUBROUTINE && Instruction.IsJumpReturn()) ||
|
||||
(m_CodeType == RspCodeType_TASK && Instruction.Value() == J_0x1118))
|
||||
(m_CodeType == RspCodeType_TASK && Instruction.IsJump() && Instruction.JumpTarget() == m_EndBlockAddress))
|
||||
{
|
||||
bool JumpBeyond = false;
|
||||
for (Addresses::iterator itr = m_BranchTargets.begin(); itr != m_BranchTargets.end(); itr++)
|
||||
|
@ -144,7 +151,7 @@ void RspCodeBlock::Analyze(void)
|
|||
{
|
||||
if (m_Functions.find(*itr) == m_Functions.end())
|
||||
{
|
||||
RspCodeBlockPtr FunctionCall = std::make_unique<RspCodeBlock>(m_System, *itr, RspCodeType_SUBROUTINE, m_Functions);
|
||||
RspCodeBlockPtr FunctionCall = std::make_unique<RspCodeBlock>(m_System, *itr, RspCodeType_SUBROUTINE, m_EndBlockAddress, m_Functions);
|
||||
if (!FunctionCall->IsValid())
|
||||
{
|
||||
m_Valid = false;
|
||||
|
|
|
@ -24,10 +24,11 @@ class RspCodeBlock
|
|||
public:
|
||||
typedef std::set<uint32_t> Addresses;
|
||||
|
||||
RspCodeBlock(CRSPSystem & System, uint32_t StartAddress, RspCodeType type, RspCodeBlocks & Functions);
|
||||
RspCodeBlock(CRSPSystem & System, uint32_t StartAddress, RspCodeType type, uint32_t EndBlockAddress, RspCodeBlocks & Functions);
|
||||
|
||||
const Addresses & GetBranchTargets() const;
|
||||
void * GetCompiledLocation() const;
|
||||
uint32_t GetEndBlockAddress() const;
|
||||
const Addresses & GetFunctionCalls() const;
|
||||
const RSPInstructions & GetInstructions() const;
|
||||
const RspCodeBlock * GetFunctionBlock(uint32_t Address) const;
|
||||
|
@ -45,6 +46,7 @@ private:
|
|||
void Analyze();
|
||||
|
||||
RspCodeBlocks & m_Functions;
|
||||
const uint32_t m_EndBlockAddress;
|
||||
RSPInstructions m_Instructions;
|
||||
uint32_t m_StartAddress;
|
||||
RspCodeType m_CodeType;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "RspRecompilerCPU-x64.h"
|
||||
#include "RspCodeBlock.h"
|
||||
#include <Common/Log.h>
|
||||
#include <Common/StdString.h>
|
||||
#include <Project64-rsp-core/Recompiler/RspAssembler.h>
|
||||
#include <Project64-rsp-core/Recompiler/RspCodeBlock.h>
|
||||
#include <Project64-rsp-core/Recompiler/RspProfiling.h>
|
||||
|
@ -44,16 +45,14 @@ CRSPRecompiler::~CRSPRecompiler()
|
|||
}
|
||||
}
|
||||
|
||||
void CRSPRecompiler::AddBranchJump(uint32_t Target, asmjit::Label Jump)
|
||||
void CRSPRecompiler::AddBranchJump(uint32_t Target)
|
||||
{
|
||||
BranchTargets::iterator it = m_BranchTargets.find(Target);
|
||||
if (it == m_BranchTargets.end())
|
||||
{
|
||||
m_BranchTargets[Target] = Jump;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
asmjit::Label Label = m_Assembler->newLabel();
|
||||
m_BranchTargets[Target] = Label;
|
||||
m_Assembler->AddLabelSymbol(Label, stdstr_f("0x%X", Target).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +454,7 @@ void CRSPRecompiler::CompileCodeBlock(RspCodeBlock & block)
|
|||
const RspCodeBlock::Addresses & branchTargets = block.GetBranchTargets();
|
||||
for (uint32_t Target : branchTargets)
|
||||
{
|
||||
AddBranchJump(Target, m_Assembler->newLabel());
|
||||
AddBranchJump(Target);
|
||||
}
|
||||
|
||||
/*if (Compiler.bReOrdering)
|
||||
|
@ -536,15 +535,14 @@ void CRSPRecompiler::CompileCodeBlock(RspCodeBlock & block)
|
|||
m_CurrentBlock = nullptr;
|
||||
}
|
||||
|
||||
void * CRSPRecompiler::CompileHLETask(uint32_t Address)
|
||||
void * CRSPRecompiler::CompileHLETask(uint32_t Address, RspCodeBlocks & Functions, const uint32_t EndBlockAddress)
|
||||
{
|
||||
void * funcPtr = nullptr;
|
||||
bool compile = Address == 0x0000187C;
|
||||
bool compile = true;
|
||||
if (compile)
|
||||
{
|
||||
// have code block in CRSPRecompiler and pass to RspCodeBlock, so it is the owner and sub functions are analysised once
|
||||
RspCodeBlocks Functions;
|
||||
RspCodeBlock CodeInfo(m_System, Address, RspCodeType_TASK, Functions);
|
||||
RspCodeBlock CodeInfo(m_System, Address, RspCodeType_TASK, EndBlockAddress, Functions);
|
||||
|
||||
RspCodeBlock::Addresses FunctionCalls = CodeInfo.GetFunctionCalls();
|
||||
for (RspCodeBlock::Addresses::iterator itr = FunctionCalls.begin(); itr != FunctionCalls.end(); itr++)
|
||||
|
@ -555,7 +553,10 @@ void * CRSPRecompiler::CompileHLETask(uint32_t Address)
|
|||
return nullptr;
|
||||
}
|
||||
RspCodeBlockPtr & FuncCodeBlock = funcitr->second;
|
||||
CompileCodeBlock(*FuncCodeBlock);
|
||||
if (FuncCodeBlock->GetCompiledLocation() == nullptr)
|
||||
{
|
||||
CompileCodeBlock(*FuncCodeBlock);
|
||||
}
|
||||
}
|
||||
CompileCodeBlock(CodeInfo);
|
||||
funcPtr = CodeInfo.GetCompiledLocation();
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#if defined(__amd64__) || defined(_M_X64)
|
||||
|
||||
#include "asmjit.h"
|
||||
#include <Project64-rsp-core/Recompiler/RspCodeBlock.h>
|
||||
#include <Project64-rsp-core/Recompiler/RspRecompilerOps-x64.h>
|
||||
#include <Project64-rsp-core/cpu/RSPOpcode.h>
|
||||
#include <Project64-rsp-core/cpu/RspPipelineStage.h>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class CRSPSystem;
|
||||
|
@ -23,7 +25,7 @@ public:
|
|||
~CRSPRecompiler();
|
||||
|
||||
void Reset();
|
||||
void * CompileHLETask(uint32_t Address);
|
||||
void * CompileHLETask(uint32_t Address, RspCodeBlocks & Functions, const uint32_t EndBlockAddress);
|
||||
void Log(_Printf_format_string_ const char * Text, ...);
|
||||
|
||||
static void * GetAddressOf(int32_t value, ...);
|
||||
|
@ -33,7 +35,7 @@ private:
|
|||
CRSPRecompiler(const CRSPRecompiler &);
|
||||
CRSPRecompiler & operator=(const CRSPRecompiler &);
|
||||
|
||||
void AddBranchJump(uint32_t Target, asmjit::Label Jump);
|
||||
void AddBranchJump(uint32_t Target);
|
||||
bool FindBranchJump(uint32_t Target, asmjit::Label & Jump);
|
||||
void BuildRecompilerCPU(void);
|
||||
void CompileCodeBlock(RspCodeBlock & block);
|
||||
|
|
|
@ -17,6 +17,8 @@ extern p_Recompfunc RSP_Recomp_Vector[64];
|
|||
extern p_Recompfunc RSP_Recomp_Lc2[32];
|
||||
extern p_Recompfunc RSP_Recomp_Sc2[32];
|
||||
|
||||
uint32_t BranchCompare = 0;
|
||||
|
||||
CRSPRecompilerOps::CRSPRecompilerOps(CRSPSystem & System, CRSPRecompiler & Recompiler) :
|
||||
m_System(System),
|
||||
m_Recompiler(Recompiler),
|
||||
|
@ -61,15 +63,15 @@ void CRSPRecompilerOps::J(void)
|
|||
{
|
||||
uint32_t Target = (m_OpCode.target << 2) & 0x1FFC;
|
||||
asmjit::Label Jump;
|
||||
if (m_Recompiler.FindBranchJump(Target, Jump))
|
||||
{
|
||||
m_Assembler->JmpLabel(stdstr_f("0x%X", Target).c_str(), Jump);
|
||||
}
|
||||
else if (m_CurrentBlock->IsEnd(m_CompilePC))
|
||||
if (m_CurrentBlock->IsEnd(m_CompilePC) && m_CurrentBlock->CodeType() == RspCodeType_TASK)
|
||||
{
|
||||
m_Assembler->MoveConstToVariable(m_System.m_SP_PC_REG, "RSP PC", Target);
|
||||
ExitCodeBlock();
|
||||
}
|
||||
else if (m_Recompiler.FindBranchJump(Target, Jump))
|
||||
{
|
||||
m_Assembler->JmpLabel(stdstr_f("0x%X", Target).c_str(), Jump);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
|
@ -146,24 +148,21 @@ void CRSPRecompilerOps::BEQ(void)
|
|||
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
||||
return;
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
#ifdef tofix
|
||||
if (m_OpCode.rt == 0)
|
||||
{
|
||||
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
||||
m_Assembler->CompConstToVariable(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), 0);
|
||||
}
|
||||
else if (m_OpCode.rs == 0)
|
||||
{
|
||||
CompConstToVariable(0, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
||||
m_Assembler->CompConstToVariable(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
||||
CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
||||
m_Assembler->MoveVariableToX86reg(asmjit::x86::r11, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
||||
m_Assembler->CompX86regToVariable(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), asmjit::x86::r11);
|
||||
}
|
||||
SetzVariable(&BranchCompare, "BranchCompare");
|
||||
m_Assembler->SetzVariable(&BranchCompare, "BranchCompare");
|
||||
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
||||
#endif
|
||||
}
|
||||
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
||||
{
|
||||
|
@ -182,7 +181,6 @@ void CRSPRecompilerOps::BEQ(void)
|
|||
|
||||
if (m_OpCode.rs == 0 && m_OpCode.rt == 0)
|
||||
{
|
||||
m_NextInstruction = RSPPIPELINE_NORMAL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -204,22 +202,34 @@ void CRSPRecompilerOps::BEQ(void)
|
|||
m_Assembler->CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
||||
#endif
|
||||
}
|
||||
if (Target == m_CurrentBlock->GetEndBlockAddress())
|
||||
{
|
||||
asmjit::Label ContinueLabel = m_Assembler->newLabel();
|
||||
m_Assembler->JneLabel(stdstr_f("Continue-%X", m_CompilePC).c_str(), ContinueLabel);
|
||||
m_Assembler->MoveConstToVariable(m_System.m_SP_PC_REG, "RSP PC", Target);
|
||||
ExitCodeBlock();
|
||||
m_Assembler->bind(ContinueLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
asmjit::Label Jump;
|
||||
if (!m_Recompiler.FindBranchJump(Target, Jump))
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
m_Assembler->JeLabel(stdstr_f("0x%X", Target).c_str(), Jump);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asmjit::Label Jump;
|
||||
if (!m_Recompiler.FindBranchJump(Target, Jump))
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
m_Assembler->CompConstToVariable(&BranchCompare, "BranchCompare", true);
|
||||
m_Assembler->JeLabel(stdstr_f("0x%X", Target).c_str(), Jump);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
#ifdef tofix
|
||||
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
||||
JeLabel32("BranchEqual", 0);
|
||||
#endif
|
||||
}
|
||||
m_NextInstruction = RSPPIPELINE_NORMAL;
|
||||
}
|
||||
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
||||
{
|
||||
|
@ -283,7 +293,6 @@ void CRSPRecompilerOps::BNE(void)
|
|||
|
||||
if (m_OpCode.rs == 0 && m_OpCode.rt == 0)
|
||||
{
|
||||
m_NextInstruction = RSPPIPELINE_NORMAL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -321,7 +330,6 @@ void CRSPRecompilerOps::BNE(void)
|
|||
JeLabel32("BranchNotEqual", 0);
|
||||
#endif
|
||||
}
|
||||
m_NextInstruction = RSPPIPELINE_NORMAL;
|
||||
}
|
||||
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
||||
{
|
||||
|
@ -436,12 +444,9 @@ void CRSPRecompilerOps::BGTZ(void)
|
|||
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
||||
return;
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
#ifdef tofix
|
||||
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
||||
SetgVariable(&BranchCompare, "BranchCompare");
|
||||
m_Assembler->CompConstToVariable(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), 0);
|
||||
m_Assembler->SetgVariable(&BranchCompare, "BranchCompare");
|
||||
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
||||
#endif
|
||||
}
|
||||
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
||||
{
|
||||
|
@ -455,24 +460,20 @@ void CRSPRecompilerOps::BGTZ(void)
|
|||
#endif
|
||||
return;
|
||||
}
|
||||
asmjit::Label Jump;
|
||||
if (!m_Recompiler.FindBranchJump(Target, Jump))
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
if (!m_DelayAffectBranch)
|
||||
{
|
||||
m_Assembler->CompConstToVariable(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), 0);
|
||||
asmjit::Label Jump;
|
||||
if (!m_Recompiler.FindBranchJump(Target, Jump))
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
m_Assembler->JgLabel(stdstr_f("0x%X", Target).c_str(), Jump);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Take a look at the branch compare variable
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
#ifdef tofix
|
||||
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
||||
JeLabel32("BranchGreater", 0);
|
||||
#endif
|
||||
m_Assembler->CompConstToVariable(&BranchCompare, "BranchCompare", true);
|
||||
m_Assembler->JeLabel(stdstr_f("0x%X", Target).c_str(), Jump);
|
||||
}
|
||||
}
|
||||
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
||||
|
@ -560,12 +561,12 @@ void CRSPRecompilerOps::LW(void)
|
|||
|
||||
void CRSPRecompilerOps::LBU(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::LBU, "RSPOp::LBU");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::LHU(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::LHU, "RSPOp::LHU");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::LWU(void)
|
||||
|
@ -627,7 +628,7 @@ void CRSPRecompilerOps::Special_SLLV(void)
|
|||
|
||||
void CRSPRecompilerOps::Special_SRLV(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Special_SRLV, "RSPOp::Special_SRLV");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Special_SRAV(void)
|
||||
|
@ -793,7 +794,7 @@ void CRSPRecompilerOps::Cop0_MT(void)
|
|||
|
||||
void CRSPRecompilerOps::Cop2_MF(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Cop2_MF, "RSPOp::Cop2_MF");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Cop2_CF(void)
|
||||
|
@ -860,12 +861,12 @@ void CRSPRecompilerOps::Vector_VMUDN(void)
|
|||
|
||||
void CRSPRecompilerOps::Vector_VMUDH(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VMUDH, "RSPOp::Vector_VMUDH");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VMACF(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VMACF, "RSPOp::Vector_VMACF");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VMACU(void)
|
||||
|
@ -920,12 +921,12 @@ void CRSPRecompilerOps::Vector_VADDC(void)
|
|||
|
||||
void CRSPRecompilerOps::Vector_VSUBC(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VSUBC, "RSPOp::Vector_VSUBC");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VSAW(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VSAW, "RSPOp::Vector_VSAW");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VLT(void)
|
||||
|
@ -945,12 +946,12 @@ void CRSPRecompilerOps::Vector_VNE(void)
|
|||
|
||||
void CRSPRecompilerOps::Vector_VGE(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VGE, "RSPOp::Vector_VGE");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VCL(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VCL, "RSPOp::Vector_VCL");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VCH(void)
|
||||
|
@ -970,7 +971,7 @@ void CRSPRecompilerOps::Vector_VMRG(void)
|
|||
|
||||
void CRSPRecompilerOps::Vector_VAND(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::Vector_VAND, "RSPOp::Vector_VAND");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Vector_VNAND(void)
|
||||
|
@ -1071,7 +1072,7 @@ void CRSPRecompilerOps::Opcode_LQV(void)
|
|||
|
||||
void CRSPRecompilerOps::Opcode_LRV(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::LRV, "RSPOp::LRV");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Opcode_LPV(void)
|
||||
|
@ -1118,7 +1119,7 @@ void CRSPRecompilerOps::Opcode_SSV(void)
|
|||
|
||||
void CRSPRecompilerOps::Opcode_SLV(void)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
Cheat_r4300iOpcode(&RSPOp::SLV, "RSPOp::SLV");
|
||||
}
|
||||
|
||||
void CRSPRecompilerOps::Opcode_SDV(void)
|
||||
|
@ -1176,7 +1177,7 @@ void CRSPRecompilerOps::UnknownOpcode(void)
|
|||
void CRSPRecompilerOps::EnterCodeBlock(void)
|
||||
{
|
||||
m_Assembler->sub(asmjit::x86::rsp, 40);
|
||||
if (Profiling)
|
||||
if (Profiling && m_CurrentBlock->CodeType() == RspCodeType_TASK)
|
||||
{
|
||||
m_Assembler->mov(asmjit::x86::rcx, asmjit::imm((uintptr_t)m_CompilePC));
|
||||
m_Assembler->CallFunc(AddressOf(&StartTimer), "StartTimer");
|
||||
|
@ -1185,7 +1186,7 @@ void CRSPRecompilerOps::EnterCodeBlock(void)
|
|||
|
||||
void CRSPRecompilerOps::ExitCodeBlock(void)
|
||||
{
|
||||
if (Profiling)
|
||||
if (Profiling && m_CurrentBlock->CodeType() == RspCodeType_TASK)
|
||||
{
|
||||
m_Assembler->CallFunc(AddressOf(&StopTimer), "StopTimer");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue