Address delroth's comments.

This commit is contained in:
Ryan Houdek 2014-04-30 03:49:17 -05:00
parent 40c317d1d4
commit 1cb1260c1d
10 changed files with 56 additions and 57 deletions

View File

@ -185,7 +185,7 @@ void Jit64::Init()
code_block.m_stats = &js.st;
code_block.m_gpa = &js.gpa;
code_block.m_fpa = &js.fpa;
analyser.SetOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE);
analyser.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
}
void Jit64::ClearCache()
@ -449,7 +449,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
// Analyze the block, collect all instructions it is made of (including inlining,
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
if (!memory_exception)
nextPC = analyser.Analyse(em_address, &code_block, code_buf, blockSize);
nextPC = analyser.Analyze(em_address, &code_block, code_buf, blockSize);
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
@ -498,10 +498,10 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
js.downcountAmount += PatchEngine::GetSpeedhackCycles(code_block.m_address);
js.skipnext = false;
js.blockSize = code_block.m_instructions;
js.blockSize = code_block.m_num_instructions;
js.compilerPC = nextPC;
// Translate instructions
for (u32 i = 0; i < code_block.m_instructions; i++)
for (u32 i = 0; i < code_block.m_num_instructions; i++)
{
js.compilerPC = ops[i].address;
js.op = &ops[i];
@ -509,7 +509,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
const GekkoOPInfo *opinfo = ops[i].opinfo;
js.downcountAmount += opinfo->numCycles;
if (i == (code_block.m_instructions - 1))
if (i == (code_block.m_num_instructions - 1))
{
// WARNING - cmp->branch merging will screw this up.
js.isLastInstruction = true;
@ -705,10 +705,10 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
b->flags = js.block_flags;
b->codeSize = (u32)(GetCodePtr() - normalEntry);
b->originalSize = code_block.m_instructions;
b->originalSize = code_block.m_num_instructions;
#ifdef JIT_LOG_X86
LogGeneratedX86(code_block.m_instructions, code_buf, normalEntry, b);
LogGeneratedX86(code_block.m_num_instructions, code_buf, normalEntry, b);
#endif
return normalEntry;

View File

@ -142,7 +142,7 @@ void Jit64::bcx(UGeckoInstruction inst)
if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
SetJumpTarget( pCTRDontBranch );
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}
@ -192,7 +192,7 @@ void Jit64::bcctrx(UGeckoInstruction inst)
// Would really like to continue the block here, but it ends. TODO.
SetJumpTarget(b);
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}
}
@ -242,6 +242,6 @@ void Jit64::bclrx(UGeckoInstruction inst)
if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
SetJumpTarget( pCTRDontBranch );
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}

View File

@ -425,7 +425,7 @@ void Jit64::cmpXX(UGeckoInstruction inst)
}
else
{
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
{
js.skipnext = true;
WriteExit(js.next_compilerPC + 4);
@ -537,7 +537,7 @@ void Jit64::cmpXX(UGeckoInstruction inst)
if (!!(4 & test_bit) == condition) SetJumpTarget(continue2);
if (!!(2 & test_bit) == condition) SetJumpTarget(continue1);
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
{
js.skipnext = true;
WriteExit(js.next_compilerPC + 4);
@ -2234,6 +2234,6 @@ void Jit64::twx(UGeckoInstruction inst)
SetJumpTarget(exit4);
SetJumpTarget(exit5);
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}

View File

@ -44,7 +44,7 @@ void JitArm::Init()
code_block.m_stats = &js.st;
code_block.m_gpa = &js.gpa;
code_block.m_fpa = &js.fpa;
analyser.SetOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE);
analyser.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
}
void JitArm::ClearCache()
@ -336,7 +336,7 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
// Analyze the block, collect all instructions it is made of (including inlining,
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
if (!memory_exception)
nextPC = analyser.Analyse(em_address, &code_block, code_buf, blockSize);
nextPC = analyser.Analyze(em_address, &code_block, code_buf, blockSize);
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
@ -397,7 +397,7 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
js.downcountAmount += PatchEngine::GetSpeedhackCycles(em_address);
js.skipnext = false;
js.blockSize = code_block.m_instructions;
js.blockSize = code_block.m_num_instructions;
js.compilerPC = nextPC;
const int DEBUG_OUTPUT = 0;
@ -406,7 +406,7 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
WARN_LOG(DYNA_REC, "-------0x%08x-------", em_address);
// Translate instructions
for (u32 i = 0; i < code_block.m_instructions; i++)
for (u32 i = 0; i < code_block.m_num_instructions; i++)
{
js.compilerPC = ops[i].address;
js.op = &ops[i];
@ -414,7 +414,7 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
const GekkoOPInfo *opinfo = ops[i].opinfo;
js.downcountAmount += opinfo->numCycles;
if (i == (code_block.m_instructions - 1))
if (i == (code_block.m_num_instructions - 1))
{
// WARNING - cmp->branch merging will screw this up.
js.isLastInstruction = true;
@ -488,7 +488,7 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
b->flags = js.block_flags;
b->codeSize = (u32)(GetCodePtr() - normalEntry);
b->originalSize = code_block.m_instructions;
b->originalSize = code_block.m_num_instructions;
FlushIcache();
return start;
}

View File

@ -202,7 +202,7 @@ void JitArm::bcx(UGeckoInstruction inst)
if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
SetJumpTarget( pCTRDontBranch );
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}
void JitArm::bcctrx(UGeckoInstruction inst)
@ -266,7 +266,7 @@ void JitArm::bcctrx(UGeckoInstruction inst)
SetJumpTarget(b);
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}
}
@ -334,6 +334,6 @@ void JitArm::bclrx(UGeckoInstruction inst)
if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
SetJumpTarget( pCTRDontBranch );
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
}

View File

@ -1015,7 +1015,7 @@ void JitArm::twx(UGeckoInstruction inst)
SetJumpTarget(exit4);
SetJumpTarget(exit5);
if (!analyser.HasOption(PPCAnalyst::PPCAnalyser::OPTION_CONDITIONAL_CONTINUE))
if (!analyser.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
WriteExit(js.compilerPC + 4);
gpr.Unlock(RA, RB);

View File

@ -239,7 +239,7 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
// Analyze the block, collect all instructions it is made of (including inlining,
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
if (!memory_exception)
nextPC = analyser.Analyse(em_address, &code_block, code_buf, blockSize);
nextPC = analyser.Analyze(em_address, &code_block, code_buf, blockSize);
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
@ -265,7 +265,7 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
u64 codeHash = -1;
{
// For profiling and IR Writer
for (u32 i = 0; i < code_block.m_instructions; i++)
for (u32 i = 0; i < code_block.m_num_instructions; i++)
{
const u64 inst = ops[i].inst.hex;
// Ported from boost::hash
@ -286,10 +286,10 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
js.downcountAmount += PatchEngine::GetSpeedhackCycles(em_address);
js.skipnext = false;
js.blockSize = code_block.m_instructions;
js.blockSize = code_block.m_num_instructions;
js.compilerPC = nextPC;
// Translate instructions
for (u32 i = 0; i < code_block.m_instructions; i++)
for (u32 i = 0; i < code_block.m_num_instructions; i++)
{
js.compilerPC = ops[i].address;
js.op = &ops[i];
@ -297,7 +297,7 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
const GekkoOPInfo *opinfo = ops[i].opinfo;
js.downcountAmount += opinfo->numCycles;
if (i == (code_block.m_instructions - 1))
if (i == (code_block.m_num_instructions - 1))
{
// WARNING - cmp->branch merging will screw this up.
js.isLastInstruction = true;
@ -347,7 +347,7 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
WriteCode(nextPC);
b->flags = js.block_flags;
b->codeSize = (u32)(GetCodePtr() - normalEntry);
b->originalSize = code_block.m_instructions;;
b->originalSize = code_block.m_num_instructions;;
FlushIcache();
return start;

View File

@ -84,7 +84,7 @@ protected:
};
PPCAnalyst::CodeBlock code_block;
PPCAnalyst::PPCAnalyser analyser;
PPCAnalyst::PPCAnalyzer analyser;
public:
// This should probably be removed from public:

View File

@ -311,7 +311,7 @@ u32 Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa,
CodeOp *code = buffer->codebuffer;
bool foundExit = false;
u32 returnAddress = 0;
u32 return_address = 0;
// Do analysis of the code, look for dependencies etc
int numSystemInstructions = 0;
@ -446,15 +446,15 @@ u32 Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa,
}
else if (inst.OPCD == 19 && inst.SUBOP10 == 16 &&
(inst.BO & (1 << 4)) && (inst.BO & (1 << 2)) &&
returnAddress != 0)
return_address != 0)
{
// bclrx with unconditional branch = return
follow = true;
destination = returnAddress;
returnAddress = 0;
destination = return_address;
return_address = 0;
if (inst.LK)
returnAddress = address + 4;
return_address = address + 4;
}
else if (inst.OPCD == 31 && inst.SUBOP10 == 467)
{
@ -463,7 +463,7 @@ u32 Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa,
if (index == SPR_LR) {
// We give up to follow the return address
// because we have to check the register usage.
returnAddress = 0;
return_address = 0;
}
}
@ -699,7 +699,7 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db)
leafSize, niceSize, unniceSize);
}
void PPCAnalyser::ReorderInstructions(u32 instructions, CodeOp *code)
void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp *code)
{
// Instruction Reordering Pass
// Bubble down compares towards branches, so that they can be merged.
@ -723,7 +723,7 @@ void PPCAnalyser::ReorderInstructions(u32 instructions, CodeOp *code)
}
}
void PPCAnalyser::SetInstructionStats(CodeBlock *block, CodeOp *code, GekkoOPInfo *opinfo, u32 index)
void PPCAnalyzer::SetInstructionStats(CodeBlock *block, CodeOp *code, GekkoOPInfo *opinfo, u32 index)
{
code->wantsCR0 = false;
code->wantsCR1 = false;
@ -822,7 +822,7 @@ void PPCAnalyser::SetInstructionStats(CodeBlock *block, CodeOp *code, GekkoOPInf
}
}
u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32 blockSize)
u32 PPCAnalyzer::Analyze(u32 address, CodeBlock *block, CodeBuffer *buffer, u32 blockSize)
{
// Clear block stats
memset(block->m_stats, 0, sizeof(BlockStats));
@ -839,12 +839,12 @@ u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
// Reset our block state
block->m_broken = false;
block->m_instructions = 0;
block->m_num_instructions = 0;
CodeOp *code = buffer->codebuffer;
bool found_exit = false;
u32 returnAddress = 0;
u32 return_address = 0;
u32 numFollows = 0;
u32 num_inst = 0;
@ -888,15 +888,15 @@ u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
}
else if (inst.OPCD == 19 && inst.SUBOP10 == 16 &&
(inst.BO & (1 << 4)) && (inst.BO & (1 << 2)) &&
returnAddress != 0)
return_address != 0)
{
// bclrx with unconditional branch = return
follow = true;
destination = returnAddress;
returnAddress = 0;
destination = return_address;
return_address = 0;
if (inst.LK)
returnAddress = address + 4;
return_address = address + 4;
}
else if (inst.OPCD == 31 && inst.SUBOP10 == 467)
{
@ -905,7 +905,7 @@ u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
if (index == SPR_LR) {
// We give up to follow the return address
// because we have to check the register usage.
returnAddress = 0;
return_address = 0;
}
}
@ -978,8 +978,8 @@ u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
}
}
if (block->m_instructions > 1)
ReorderInstructions(block->m_instructions, code);
if (block->m_num_instructions > 1)
ReorderInstructions(block->m_num_instructions, code);
if ((!found_exit && num_inst > 0) || blockSize == 1)
{
@ -992,7 +992,7 @@ u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
bool wantsCR0 = true;
bool wantsCR1 = true;
bool wantsPS1 = true;
for (int i = block->m_instructions - 1; i >= 0; i--)
for (int i = block->m_num_instructions - 1; i >= 0; i--)
{
if (code[i].outputCR0)
wantsCR0 = false;
@ -1007,7 +1007,7 @@ u32 PPCAnalyser::Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
code[i].wantsCR1 = wantsCR1;
code[i].wantsPS1 = wantsPS1;
}
block->m_instructions = num_inst;
block->m_num_instructions = num_inst;
return address;
}

View File

@ -114,7 +114,7 @@ struct CodeBlock
// Number of instructions
// Gives us the size of the block.
u32 m_instructions;
u32 m_num_instructions;
// Some basic statistics about the block.
BlockStats *m_stats;
@ -126,17 +126,16 @@ struct CodeBlock
bool m_broken;
};
class PPCAnalyser
class PPCAnalyzer
{
private:
private:
void ReorderInstructions(u32 instructions, CodeOp *code);
void SetInstructionStats(CodeBlock *block, CodeOp *code, GekkoOPInfo *opinfo, u32 index);
// Options
u32 m_options;
public:
public:
enum AnalystOption
{
@ -166,14 +165,14 @@ class PPCAnalyser
};
PPCAnalyser() : m_options(0) {}
PPCAnalyzer() : m_options(0) {}
// Option setting/getting
void SetOption(AnalystOption option) { m_options |= option; }
void ClearOption(AnalystOption option) { m_options &= ~(option); }
bool HasOption(AnalystOption option) { return !!(m_options & option); }
u32 Analyse(u32 address, CodeBlock *block, CodeBuffer *buffer, u32 blockSize);
u32 Analyze(u32 address, CodeBlock *block, CodeBuffer *buffer, u32 blockSize);
};
u32 Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa,