mirror of
				https://github.com/hedge-dev/XenonRecomp.git
				synced 2025-11-04 06:47:09 +00:00 
			
		
		
		
	Print only actually used labels.
This commit is contained in:
		@@ -1920,6 +1920,29 @@ bool Recompiler::Recompile(const Function& fn)
 | 
			
		||||
    auto end = base + fn.size;
 | 
			
		||||
    auto* data = (uint32_t*)image.Find(base);
 | 
			
		||||
 | 
			
		||||
    static std::unordered_set<size_t> labels;
 | 
			
		||||
    labels.clear();
 | 
			
		||||
 | 
			
		||||
    for (size_t addr = base; addr < end; addr += 4)
 | 
			
		||||
    {
 | 
			
		||||
        const uint32_t instruction = std::byteswap(*(uint32_t*)((char*)data + addr - base));
 | 
			
		||||
        if (!PPC_BL(instruction))
 | 
			
		||||
        {
 | 
			
		||||
            const size_t op = PPC_OP(instruction);
 | 
			
		||||
            if (op == PPC_OP_B)
 | 
			
		||||
                labels.emplace(addr + PPC_BI(instruction));
 | 
			
		||||
            else if (op == PPC_OP_BC)
 | 
			
		||||
                labels.emplace(addr + PPC_BD(instruction));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        auto switchTable = switchTables.find(addr);
 | 
			
		||||
        if (switchTable != switchTables.end())
 | 
			
		||||
        {
 | 
			
		||||
            for (auto label : switchTable->second.labels)
 | 
			
		||||
                labels.emplace(label);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    auto symbol = image.symbols.find(fn.base);
 | 
			
		||||
    if (symbol != image.symbols.end())
 | 
			
		||||
    {
 | 
			
		||||
@@ -1937,13 +1960,15 @@ bool Recompiler::Recompile(const Function& fn)
 | 
			
		||||
 | 
			
		||||
    // TODO: the printing scheme here is scuffed
 | 
			
		||||
    RecompilerLocalVariables localVariables;
 | 
			
		||||
    static std::string tempString;
 | 
			
		||||
    tempString.clear();
 | 
			
		||||
    std::swap(out, tempString);
 | 
			
		||||
 | 
			
		||||
    ppc_insn insn;
 | 
			
		||||
    while (base < end)
 | 
			
		||||
    {
 | 
			
		||||
        println("loc_{:X}:", base);
 | 
			
		||||
        if (labels.contains(base))
 | 
			
		||||
            println("loc_{:X}:", base);
 | 
			
		||||
 | 
			
		||||
        if (switchTable == switchTables.end())
 | 
			
		||||
            switchTable = switchTables.find(base);
 | 
			
		||||
@@ -2122,6 +2147,8 @@ void Recompiler::SaveCurrentOutData(const char* directoryPath, const std::string
 | 
			
		||||
        FILE* f = fopen(filePath.c_str(), "rb");
 | 
			
		||||
        if (f)
 | 
			
		||||
        {
 | 
			
		||||
            static std::vector<uint8_t> temp;
 | 
			
		||||
 | 
			
		||||
            fseek(f, 0, SEEK_END);
 | 
			
		||||
            long fileSize = ftell(f);
 | 
			
		||||
            if (fileSize == out.size())
 | 
			
		||||
 
 | 
			
		||||
@@ -41,8 +41,6 @@ struct Recompiler
 | 
			
		||||
    std::unordered_map<size_t, SwitchTable> switchTables;
 | 
			
		||||
    std::string out;
 | 
			
		||||
    size_t cppFileIndex = 0;
 | 
			
		||||
    std::vector<uint8_t> temp;
 | 
			
		||||
    std::string tempString;
 | 
			
		||||
    uint32_t setJmpAddress = 0;
 | 
			
		||||
    uint32_t longJmpAddress = 0;
 | 
			
		||||
    RecompilerConfig config;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,9 +3,7 @@ project("PowerSample")
 | 
			
		||||
add_compile_options(
 | 
			
		||||
    "/fp:strict"
 | 
			
		||||
    "-march=x86-64-v3"
 | 
			
		||||
    "-fno-strict-aliasing"
 | 
			
		||||
    "-Wno-unused-label"
 | 
			
		||||
    "-Wno-unused-variable")
 | 
			
		||||
    "-fno-strict-aliasing")
 | 
			
		||||
 | 
			
		||||
file(GLOB RecompiledFiles *.cpp)
 | 
			
		||||
add_library(PowerSample ${RecompiledFiles})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								PowerTests/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								PowerTests/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
*.cpp
 | 
			
		||||
		Reference in New Issue
	
	Block a user