mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2026-04-29 13:31:59 +00:00
Removed unnecessary config input to recompilation functions
This commit is contained in:
parent
ddb8a08482
commit
bb2fc8c67b
3 changed files with 14 additions and 15 deletions
|
|
@ -7,7 +7,6 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <span>
|
||||
#include <unordered_set>
|
||||
#include <filesystem>
|
||||
#include "rabbitizer.hpp"
|
||||
|
|
@ -219,7 +218,7 @@ namespace RecompPort {
|
|||
};
|
||||
|
||||
bool analyze_function(const Context& context, const Function& function, const std::vector<rabbitizer::InstructionCpu>& instructions, FunctionStats& stats);
|
||||
bool recompile_function(const Context& context, const Config& config, const Function& func, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs, bool write_header);
|
||||
bool recompile_function(const Context& context, const Function& func, const std::string& recomp_include, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs, bool write_header);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
12
src/main.cpp
12
src/main.cpp
|
|
@ -1330,7 +1330,7 @@ bool compare_files(const std::filesystem::path& file1_path, const std::filesyste
|
|||
return std::equal(begin1, std::istreambuf_iterator<char>(), begin2); //Second argument is end-of-range iterator
|
||||
}
|
||||
|
||||
bool recompile_single_function(const RecompPort::Context& context, const RecompPort::Config& config, const RecompPort::Function& func, const std::filesystem::path& output_path, std::span<std::vector<uint32_t>> static_funcs_out) {
|
||||
bool recompile_single_function(const RecompPort::Context& context, const RecompPort::Function& func, const std::string& recomp_include, const std::filesystem::path& output_path, std::span<std::vector<uint32_t>> static_funcs_out) {
|
||||
// Open the temporary output file
|
||||
std::filesystem::path temp_path = output_path;
|
||||
temp_path.replace_extension(".tmp");
|
||||
|
|
@ -1340,7 +1340,7 @@ bool recompile_single_function(const RecompPort::Context& context, const RecompP
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!RecompPort::recompile_function(context, config, func, output_file, static_funcs_out, true)) {
|
||||
if (!RecompPort::recompile_function(context, func, recomp_include, output_file, static_funcs_out, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1828,7 +1828,7 @@ int main(int argc, char** argv) {
|
|||
"void {}(uint8_t* rdram, recomp_context* ctx);\n", func.name);
|
||||
bool result;
|
||||
if (config.single_file_output || config.functions_per_output_file > 1) {
|
||||
result = RecompPort::recompile_function(context, config, func, current_output_file, static_funcs_by_section, false);
|
||||
result = RecompPort::recompile_function(context, func, config.recomp_include, current_output_file, static_funcs_by_section, false);
|
||||
if (!config.single_file_output) {
|
||||
cur_file_function_count++;
|
||||
if (cur_file_function_count >= config.functions_per_output_file) {
|
||||
|
|
@ -1837,7 +1837,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
result = recompile_single_function(context, config, func, config.output_func_path / (func.name + ".c"), static_funcs_by_section);
|
||||
result = recompile_single_function(context, func, config.recomp_include, config.output_func_path / (func.name + ".c"), static_funcs_by_section);
|
||||
}
|
||||
if (result == false) {
|
||||
fmt::print(stderr, "Error recompiling {}\n", func.name);
|
||||
|
|
@ -1907,7 +1907,7 @@ int main(int argc, char** argv) {
|
|||
size_t prev_num_statics = static_funcs_by_section[func.section_index].size();
|
||||
|
||||
if (config.single_file_output || config.functions_per_output_file > 1) {
|
||||
result = RecompPort::recompile_function(context, config, func, current_output_file, static_funcs_by_section, false);
|
||||
result = RecompPort::recompile_function(context, func, config.recomp_include, current_output_file, static_funcs_by_section, false);
|
||||
if (!config.single_file_output) {
|
||||
cur_file_function_count++;
|
||||
if (cur_file_function_count >= config.functions_per_output_file) {
|
||||
|
|
@ -1916,7 +1916,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
result = recompile_single_function(context, config, func, config.output_func_path / (func.name + ".c"), static_funcs_by_section);
|
||||
result = recompile_single_function(context, func, config.recomp_include, config.output_func_path / (func.name + ".c"), static_funcs_by_section);
|
||||
}
|
||||
|
||||
// Add any new static functions that were found while recompiling this one.
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ std::string_view ctx_gpr_prefix(int reg) {
|
|||
}
|
||||
|
||||
// Major TODO, this function grew very organically and needs to be cleaned up. Ideally, it'll get split up into some sort of lookup table grouped by similar instruction types.
|
||||
bool process_instruction(const RecompPort::Context& context, const RecompPort::Config& config, const RecompPort::Function& func, const RecompPort::FunctionStats& stats, const std::unordered_set<uint32_t>& skipped_insns, size_t instr_index, const std::vector<rabbitizer::InstructionCpu>& instructions, std::ofstream& output_file, bool indent, bool emit_link_branch, int link_branch_index, size_t reloc_index, bool& needs_link_branch, bool& is_branch_likely, std::span<std::vector<uint32_t>> static_funcs_out) {
|
||||
bool process_instruction(const RecompPort::Context& context, const RecompPort::Function& func, const RecompPort::FunctionStats& stats, const std::unordered_set<uint32_t>& skipped_insns, size_t instr_index, const std::vector<rabbitizer::InstructionCpu>& instructions, std::ofstream& output_file, bool indent, bool emit_link_branch, int link_branch_index, size_t reloc_index, bool& needs_link_branch, bool& is_branch_likely, std::span<std::vector<uint32_t>> static_funcs_out) {
|
||||
using namespace RecompPort;
|
||||
|
||||
const auto& section = context.sections[func.section_index];
|
||||
|
|
@ -225,7 +225,7 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
|
|||
if (reloc_index + 1 < section.relocs.size() && next_vram > section.relocs[reloc_index].address) {
|
||||
next_reloc_index++;
|
||||
}
|
||||
if (!process_instruction(context, config, func, stats, skipped_insns, instr_index + 1, instructions, output_file, false, false, link_branch_index, next_reloc_index, dummy_needs_link_branch, dummy_is_branch_likely, static_funcs_out)) {
|
||||
if (!process_instruction(context, func, stats, skipped_insns, instr_index + 1, instructions, output_file, false, false, link_branch_index, next_reloc_index, dummy_needs_link_branch, dummy_is_branch_likely, static_funcs_out)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
|
|||
if (reloc_index + 1 < section.relocs.size() && next_vram > section.relocs[reloc_index].address) {
|
||||
next_reloc_index++;
|
||||
}
|
||||
if (!process_instruction(context, config, func, stats, skipped_insns, instr_index + 1, instructions, output_file, true, false, link_branch_index, next_reloc_index, dummy_needs_link_branch, dummy_is_branch_likely, static_funcs_out)) {
|
||||
if (!process_instruction(context, func, stats, skipped_insns, instr_index + 1, instructions, output_file, true, false, link_branch_index, next_reloc_index, dummy_needs_link_branch, dummy_is_branch_likely, static_funcs_out)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
|
|||
if (reloc_index + 1 < section.relocs.size() && next_vram > section.relocs[reloc_index].address) {
|
||||
next_reloc_index++;
|
||||
}
|
||||
if (!process_instruction(context, config, func, stats, skipped_insns, instr_index + 1, instructions, output_file, false, false, link_branch_index, next_reloc_index, dummy_needs_link_branch, dummy_is_branch_likely, static_funcs_out)) {
|
||||
if (!process_instruction(context, func, stats, skipped_insns, instr_index + 1, instructions, output_file, false, false, link_branch_index, next_reloc_index, dummy_needs_link_branch, dummy_is_branch_likely, static_funcs_out)) {
|
||||
return false;
|
||||
}
|
||||
print_indent();
|
||||
|
|
@ -717,7 +717,7 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RecompPort::recompile_function(const RecompPort::Context& context, const RecompPort::Config& config, const RecompPort::Function& func, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs_out, bool write_header) {
|
||||
bool RecompPort::recompile_function(const RecompPort::Context& context, const RecompPort::Function& func, const std::string& recomp_include, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs_out, bool write_header) {
|
||||
//fmt::print("Recompiling {}\n", func.name);
|
||||
std::vector<rabbitizer::InstructionCpu> instructions;
|
||||
|
||||
|
|
@ -726,7 +726,7 @@ bool RecompPort::recompile_function(const RecompPort::Context& context, const Re
|
|||
fmt::print(output_file,
|
||||
"{}\n"
|
||||
"\n",
|
||||
config.recomp_include);
|
||||
recomp_include);
|
||||
}
|
||||
|
||||
fmt::print(output_file,
|
||||
|
|
@ -808,7 +808,7 @@ bool RecompPort::recompile_function(const RecompPort::Context& context, const Re
|
|||
}
|
||||
|
||||
// Process the current instruction and check for errors
|
||||
if (process_instruction(context, config, func, stats, skipped_insns, instr_index, instructions, output_file, false, needs_link_branch, num_link_branches, reloc_index, needs_link_branch, is_branch_likely, static_funcs_out) == false) {
|
||||
if (process_instruction(context, func, stats, skipped_insns, instr_index, instructions, output_file, false, needs_link_branch, num_link_branches, reloc_index, needs_link_branch, is_branch_likely, static_funcs_out) == false) {
|
||||
fmt::print(stderr, "Error in recompiling {}, clearing output file\n", func.name);
|
||||
output_file.clear();
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue