PPU/LLVM: Do not cache block

This commit is contained in:
vlj 2015-07-21 17:15:17 +02:00 committed by Nekotekina
parent abd61538ea
commit 4adb9a2683
2 changed files with 3 additions and 28 deletions

View File

@ -84,7 +84,7 @@ public:
};
Executable Compiler::Compile(const std::string & name, const ControlFlowGraph & cfg, bool inline_all, bool generate_linkable_exits) {
Executable Compiler::Compile(const std::string & name, const ControlFlowGraph & cfg, bool generate_linkable_exits) {
auto compilation_start = std::chrono::high_resolution_clock::now();
m_module = new llvm::Module("Module", *m_llvm_context);
@ -128,7 +128,6 @@ Executable Compiler::Compile(const std::string & name, const ControlFlowGraph &
fpm->doInitialization();
m_state.cfg = &cfg;
m_state.inline_all = inline_all;
m_state.generate_linkable_exits = generate_linkable_exits;
// Create the function
@ -152,27 +151,6 @@ Executable Compiler::Compile(const std::string & name, const ControlFlowGraph &
auto instr_bb = GetBasicBlockFromAddress(m_state.current_instruction_address);
m_ir_builder->SetInsertPoint(instr_bb);
if (!inline_all && *instr_i != cfg.start_address) {
// Use an already compiled implementation of this block if available
auto ordinal = m_recompilation_engine.GetOrdinal(*instr_i);
if (ordinal != 0xFFFFFFFF) {
auto exit_instr_i32 = m_ir_builder->CreatePHI(m_ir_builder->getInt32Ty(), 0);
exit_instr_list.push_back(exit_instr_i32);
auto context_i64 = m_ir_builder->CreateZExt(exit_instr_i32, m_ir_builder->getInt64Ty());
context_i64 = m_ir_builder->CreateOr(context_i64, (u64)cfg.function_address << 32);
auto ret_i32 = IndirectCall(*instr_i, context_i64, false);
auto switch_instr = m_ir_builder->CreateSwitch(ret_i32, GetBasicBlockFromAddress(0xFFFFFFFF));
auto branch_i = cfg.branches.find(*instr_i);
if (branch_i != cfg.branches.end()) {
for (auto next_instr_i = branch_i->second.begin(); next_instr_i != branch_i->second.end(); next_instr_i++) {
switch_instr->addCase(m_ir_builder->getInt32(*next_instr_i), GetBasicBlockFromAddress(*next_instr_i));
}
}
}
}
if (instr_bb->empty()) {
u32 instr = vm::ps3::read32(m_state.current_instruction_address);
Decode(instr);
@ -5870,7 +5848,7 @@ void RecompilationEngine::CompileBlock(BlockEntry & block_entry) {
Log() << "CFG: " << block_entry.cfg.ToString() << "\n";
auto ordinal = AllocateOrdinal(block_entry.cfg.start_address, block_entry.IsFunction());
auto executable = m_compiler.Compile(fmt::Format("fn_0x%08X_%u", block_entry.cfg.start_address, block_entry.revision++), block_entry.cfg, true,
auto executable = m_compiler.Compile(fmt::Format("fn_0x%08X_%u", block_entry.cfg.start_address, block_entry.revision++), block_entry.cfg,
block_entry.IsFunction() ? true : false /*generate_linkable_exits*/);
m_executable_lookup[ordinal] = executable;
block_entry.last_compiled_cfg_size = block_entry.cfg.GetSize();

View File

@ -285,7 +285,7 @@ namespace ppu_recompiler_llvm {
Compiler & operator = (Compiler && other) = delete;
/// Compile a code fragment described by a cfg and return an executable
Executable Compile(const std::string & name, const ControlFlowGraph & cfg, bool inline_all_blocks, bool generate_linkable_exits);
Executable Compile(const std::string & name, const ControlFlowGraph & cfg, bool generate_linkable_exits);
/// Free an executable earilier obtained via a call to Compile
void FreeExecutable(const std::string & name);
@ -727,9 +727,6 @@ namespace ppu_recompiler_llvm {
/// If a branch instruction is encountered, this is set to true by the decode function.
bool hit_branch_instruction;
/// Indicates whether a block should be inlined even if an already compiled version of the block exists
bool inline_all;
/// Create code such that exit points can be linked to other blocks
bool generate_linkable_exits;
};