From 9b0a349a5e8414452b10364c98b0916849d33073 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Mon, 8 Jul 2024 16:51:17 -0400 Subject: [PATCH] Moved parts of recomp_port.h into new internal headers in src folder --- CMakeLists.txt | 104 +++++++++++++++++++++--------------------- include/recomp_port.h | 96 -------------------------------------- src/analysis.cpp | 1 + src/analysis.h | 38 +++++++++++++++ src/config.cpp | 68 +-------------------------- src/config.h | 69 ++++++++++++++++++++++++++++ src/main.cpp | 1 + src/recompilation.cpp | 1 + 8 files changed, 164 insertions(+), 214 deletions(-) create mode 100644 src/analysis.h create mode 100644 src/config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1916015..d2e9753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,50 +10,50 @@ project(rabbitizer) add_library(rabbitizer STATIC) target_sources(rabbitizer PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrId.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrIdType.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR3000GTE.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerRegistersTracker.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerConfig.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerVersion.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/Utils.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrCategory.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrIdType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrSuffix.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegister.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegisterDescriptor.c") + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrId.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrIdType.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR3000GTE.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerRegistersTracker.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerConfig.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerVersion.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/common/Utils.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrCategory.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrId.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrIdType.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrSuffix.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_OperandType.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_ProcessUniqueId.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegister.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegisterDescriptor.c") target_include_directories(rabbitizer PUBLIC - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include") + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/include" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/cplusplus/include") target_include_directories(rabbitizer PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/tables") + "${CMAKE_CURRENT_SOURCE_DIR}/lib/rabbitizer/tables") # fmtlib add_subdirectory(lib/fmt) @@ -67,14 +67,14 @@ project(N64Recomp) add_library(N64Recomp) target_sources(N64Recomp PRIVATE - ${CMAKE_SOURCE_DIR}/src/analysis.cpp - ${CMAKE_SOURCE_DIR}/src/operations.cpp - ${CMAKE_SOURCE_DIR}/src/cgenerator.cpp - ${CMAKE_SOURCE_DIR}/src/recompilation.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/analysis.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/operations.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/cgenerator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/recompilation.cpp ) -target_include_directories(N64Recomp PRIVATE - "${CMAKE_SOURCE_DIR}/include") +target_include_directories(N64Recomp PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(N64Recomp fmt rabbitizer tomlplusplus::tomlplusplus) @@ -83,13 +83,13 @@ project(N64RecompCLI) add_executable(N64RecompCLI) target_sources(N64RecompCLI PRIVATE - ${CMAKE_SOURCE_DIR}/src/config.cpp - ${CMAKE_SOURCE_DIR}/src/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/config.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ) target_include_directories(N64RecompCLI PRIVATE - "${CMAKE_SOURCE_DIR}/lib/ELFIO" - "${CMAKE_SOURCE_DIR}/include") + "${CMAKE_CURRENT_SOURCE_DIR}/lib/ELFIO" + "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(N64RecompCLI fmt rabbitizer tomlplusplus::tomlplusplus N64Recomp) set_target_properties(N64RecompCLI PROPERTIES OUTPUT_NAME N64Recomp) @@ -98,9 +98,9 @@ set_target_properties(N64RecompCLI PROPERTIES OUTPUT_NAME N64Recomp) project(RSPRecomp) add_executable(RSPRecomp) -target_include_directories(RSPRecomp PRIVATE "${CMAKE_SOURCE_DIR}/include") +target_include_directories(RSPRecomp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(RSPRecomp fmt rabbitizer tomlplusplus::tomlplusplus) target_sources(RSPRecomp PRIVATE - ${CMAKE_SOURCE_DIR}/RSPRecomp/src/rsp_recomp.cpp) + ${CMAKE_CURRENT_SOURCE_DIR}/RSPRecomp/src/rsp_recomp.cpp) diff --git a/include/recomp_port.h b/include/recomp_port.h index ee0e4a7..ff5407b 100644 --- a/include/recomp_port.h +++ b/include/recomp_port.h @@ -22,96 +22,6 @@ constexpr uint32_t byteswap(uint32_t val) { #endif namespace RecompPort { - - // Potential argument types for function declarations - enum class FunctionArgType { - u32, - s32, - }; - - // Mapping of function name to argument types - using DeclaredFunctionMap = std::unordered_map>; - - struct InstructionPatch { - std::string func_name; - int32_t vram; - uint32_t value; - }; - - struct FunctionHook { - std::string func_name; - int32_t before_vram; - std::string text; - }; - - struct FunctionSize { - std::string func_name; - uint32_t size_bytes; - - FunctionSize(const std::string& func_name, uint32_t size_bytes) : func_name(std::move(func_name)), size_bytes(size_bytes) {} - }; - - struct ManualFunction { - std::string func_name; - std::string section_name; - uint32_t vram; - uint32_t size; - - ManualFunction(const std::string& func_name, std::string section_name, uint32_t vram, uint32_t size) : func_name(std::move(func_name)), section_name(std::move(section_name)), vram(vram), size(size) {} - }; - - struct Config { - int32_t entrypoint; - int32_t functions_per_output_file; - bool has_entrypoint; - bool uses_mips3_float_mode; - bool single_file_output; - bool use_absolute_symbols; - bool unpaired_lo16_warnings; - std::filesystem::path elf_path; - std::filesystem::path symbols_file_path; - std::filesystem::path func_reference_syms_file_path; - std::vector data_reference_syms_file_paths; - std::filesystem::path rom_file_path; - std::filesystem::path output_func_path; - std::filesystem::path relocatable_sections_path; - std::filesystem::path output_binary_path; - std::vector stubbed_funcs; - std::vector ignored_funcs; - DeclaredFunctionMap declared_funcs; - std::vector instruction_patches; - std::vector function_hooks; - std::vector manual_func_sizes; - std::vector manual_functions; - std::string bss_section_suffix; - std::string recomp_include; - - Config(const char* path); - bool good() { return !bad; } - private: - bool bad; - }; - - struct JumpTable { - uint32_t vram; - uint32_t addend_reg; - uint32_t rom; - uint32_t lw_vram; - uint32_t addu_vram; - uint32_t jr_vram; - std::vector entries; - - JumpTable(uint32_t vram, uint32_t addend_reg, uint32_t rom, uint32_t lw_vram, uint32_t addu_vram, uint32_t jr_vram, std::vector&& entries) - : vram(vram), addend_reg(addend_reg), rom(rom), lw_vram(lw_vram), addu_vram(addu_vram), jr_vram(jr_vram), entries(std::move(entries)) {} - }; - - struct AbsoluteJump { - uint32_t jump_target; - uint32_t instruction_vram; - - AbsoluteJump(uint32_t jump_target, uint32_t instruction_vram) : jump_target(jump_target), instruction_vram(instruction_vram) {} - }; - struct Function { uint32_t vram; uint32_t rom; @@ -163,11 +73,6 @@ namespace RecompPort { bool has_mips32_relocs = false; }; - struct FunctionStats { - std::vector jump_tables; - std::vector absolute_jumps; - }; - struct ReferenceSection { uint32_t rom_addr; uint32_t ram_addr; @@ -217,7 +122,6 @@ namespace RecompPort { Context() = default; }; - bool analyze_function(const Context& context, const Function& function, const std::vector& instructions, FunctionStats& stats); bool recompile_function(const Context& context, const Function& func, const std::string& recomp_include, std::ofstream& output_file, std::span> static_funcs, bool write_header); } diff --git a/src/analysis.cpp b/src/analysis.cpp index 5a689a0..36cff76 100644 --- a/src/analysis.cpp +++ b/src/analysis.cpp @@ -5,6 +5,7 @@ #include "fmt/format.h" #include "recomp_port.h" +#include "analysis.h" extern "C" const char* RabbitizerRegister_getNameGpr(uint8_t regValue); diff --git a/src/analysis.h b/src/analysis.h new file mode 100644 index 0000000..b450660 --- /dev/null +++ b/src/analysis.h @@ -0,0 +1,38 @@ +#ifndef __RECOMP_ANALYSIS_H__ +#define __RECOMP_ANALYSIS_H__ + +#include +#include + +#include "recomp_port.h" + +namespace RecompPort { + struct JumpTable { + uint32_t vram; + uint32_t addend_reg; + uint32_t rom; + uint32_t lw_vram; + uint32_t addu_vram; + uint32_t jr_vram; + std::vector entries; + + JumpTable(uint32_t vram, uint32_t addend_reg, uint32_t rom, uint32_t lw_vram, uint32_t addu_vram, uint32_t jr_vram, std::vector&& entries) + : vram(vram), addend_reg(addend_reg), rom(rom), lw_vram(lw_vram), addu_vram(addu_vram), jr_vram(jr_vram), entries(std::move(entries)) {} + }; + + struct AbsoluteJump { + uint32_t jump_target; + uint32_t instruction_vram; + + AbsoluteJump(uint32_t jump_target, uint32_t instruction_vram) : jump_target(jump_target), instruction_vram(instruction_vram) {} + }; + + struct FunctionStats { + std::vector jump_tables; + std::vector absolute_jumps; + }; + + bool analyze_function(const Context& context, const Function& function, const std::vector& instructions, FunctionStats& stats); +} + +#endif \ No newline at end of file diff --git a/src/config.cpp b/src/config.cpp index 98d6294..fb2b6b3 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -2,6 +2,7 @@ #include #include "fmt/format.h" +#include "config.h" #include "recomp_port.h" std::filesystem::path concat_if_not_empty(const std::filesystem::path& parent, const std::filesystem::path& child) { @@ -103,68 +104,6 @@ std::vector get_ignored_funcs(const toml::table* patches_data) { return ignored_funcs; } -std::unordered_map arg_type_map{ - {"u32", RecompPort::FunctionArgType::u32}, - {"s32", RecompPort::FunctionArgType::s32}, -}; - -std::vector parse_args(const toml::array* args_in) { - std::vector ret(args_in->size()); - - args_in->for_each([&ret](auto&& el) { - if constexpr (toml::is_string) { - const std::string& arg_str = *el; - - // Check if the argument type string is valid. - auto type_find = arg_type_map.find(arg_str); - if (type_find == arg_type_map.end()) { - // It's not, so throw an error (and make it look like a normal toml one). - throw toml::parse_error(("Invalid argument type: " + arg_str).c_str(), el.source()); - } - ret.push_back(type_find->second); - } - else { - throw toml::parse_error("Invalid function argument entry", el.source()); - } - }); - - return ret; -} - -RecompPort::DeclaredFunctionMap get_declared_funcs(const toml::table* patches_data) { - RecompPort::DeclaredFunctionMap declared_funcs{}; - - // Check if the func array exists. - const toml::node_view funcs_data = (*patches_data)["func"]; - - if (funcs_data.is_array()) { - const toml::array* funcs_array = funcs_data.as_array(); - - // Reserve room for all the funcs in the map. - declared_funcs.reserve(funcs_array->size()); - - // Gather the funcs and place them into the map. - funcs_array->for_each([&declared_funcs](auto&& el) { - if constexpr (toml::is_table) { - std::optional func_name = el["name"].template value(); - toml::node_view args_in = el["args"]; - - if (func_name.has_value() && args_in.is_array()) { - const toml::array* args_array = args_in.as_array(); - declared_funcs.emplace(func_name.value(), parse_args(args_array)); - } else { - throw toml::parse_error("Missing required value in func array", el.source()); - } - } - else { - throw toml::parse_error("Invalid declared function entry", el.source()); - } - }); - } - - return declared_funcs; -} - std::vector get_func_sizes(const toml::table* patches_data) { std::vector func_sizes{}; @@ -438,16 +377,13 @@ RecompPort::Config::Config(const char* path) { // Ignored funcs array (optional) ignored_funcs = get_ignored_funcs(table); - // Functions (optional) - declared_funcs = get_declared_funcs(table); - // Single-instruction patches (optional) instruction_patches = get_instruction_patches(table); // Manual function sizes (optional) manual_func_sizes = get_func_sizes(table); - // Fonction hooks (optional) + // Function hooks (optional) function_hooks = get_function_hooks(table); } diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..2e2e15b --- /dev/null +++ b/src/config.h @@ -0,0 +1,69 @@ +#ifndef __RECOMP_CONFIG_H__ +#define __RECOMP_CONFIG_H__ + +#include +#include +#include + +namespace RecompPort { + struct InstructionPatch { + std::string func_name; + int32_t vram; + uint32_t value; + }; + + struct FunctionHook { + std::string func_name; + int32_t before_vram; + std::string text; + }; + + struct FunctionSize { + std::string func_name; + uint32_t size_bytes; + + FunctionSize(const std::string& func_name, uint32_t size_bytes) : func_name(std::move(func_name)), size_bytes(size_bytes) {} + }; + + struct ManualFunction { + std::string func_name; + std::string section_name; + uint32_t vram; + uint32_t size; + + ManualFunction(const std::string& func_name, std::string section_name, uint32_t vram, uint32_t size) : func_name(std::move(func_name)), section_name(std::move(section_name)), vram(vram), size(size) {} + }; + + struct Config { + int32_t entrypoint; + int32_t functions_per_output_file; + bool has_entrypoint; + bool uses_mips3_float_mode; + bool single_file_output; + bool use_absolute_symbols; + bool unpaired_lo16_warnings; + std::filesystem::path elf_path; + std::filesystem::path symbols_file_path; + std::filesystem::path func_reference_syms_file_path; + std::vector data_reference_syms_file_paths; + std::filesystem::path rom_file_path; + std::filesystem::path output_func_path; + std::filesystem::path relocatable_sections_path; + std::filesystem::path output_binary_path; + std::vector stubbed_funcs; + std::vector ignored_funcs; + std::vector instruction_patches; + std::vector function_hooks; + std::vector manual_func_sizes; + std::vector manual_functions; + std::string bss_section_suffix; + std::string recomp_include; + + Config(const char* path); + bool good() { return !bad; } + private: + bool bad; + }; +} + +#endif diff --git a/src/main.cpp b/src/main.cpp index 4f66711..84248d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,7 @@ #include "fmt/ostream.h" #include "recomp_port.h" +#include "config.h" #include std::unordered_set reimplemented_funcs{ diff --git a/src/recompilation.cpp b/src/recompilation.cpp index 2b3691c..38b8ea3 100644 --- a/src/recompilation.cpp +++ b/src/recompilation.cpp @@ -9,6 +9,7 @@ #include "fmt/ostream.h" #include "recomp_port.h" +#include "analysis.h" #include "operations.h" #include "generator.h"