backend/arm64: Adjust how relocations are stored

This commit is contained in:
Merry 2022-07-15 09:59:01 +01:00 committed by merry
parent e0f091b6a6
commit 3bf2b0aba9
2 changed files with 8 additions and 3 deletions

View file

@ -26,7 +26,7 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block) {
code.STR(W0, X1, offsetof(A32JitState, regs) + 1 * sizeof(u32)); code.STR(W0, X1, offsetof(A32JitState, regs) + 1 * sizeof(u32));
code.STR(W0, X1, offsetof(A32JitState, regs) + 15 * sizeof(u32)); code.STR(W0, X1, offsetof(A32JitState, regs) + 15 * sizeof(u32));
ebi.relocations[code.ptr<CodePtr>() - ebi.entry_point] = LinkTarget::ReturnFromRunCode; ebi.relocations.emplace_back(Relocation{code.ptr<CodePtr>() - ebi.entry_point, LinkTarget::ReturnFromRunCode});
code.NOP(); code.NOP();
ebi.size = code.ptr<CodePtr>() - ebi.entry_point; ebi.size = code.ptr<CodePtr>() - ebi.entry_point;

View file

@ -6,9 +6,9 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <vector>
#include <mcl/stdint.hpp> #include <mcl/stdint.hpp>
#include <tsl/robin_map.h>
namespace oaknut { namespace oaknut {
struct PointerCodeGeneratorPolicy; struct PointerCodeGeneratorPolicy;
@ -29,10 +29,15 @@ enum class LinkTarget {
ReturnFromRunCode, ReturnFromRunCode,
}; };
struct Relocation {
std::ptrdiff_t code_offset;
LinkTarget target;
};
struct EmittedBlockInfo { struct EmittedBlockInfo {
CodePtr entry_point; CodePtr entry_point;
size_t size; size_t size;
tsl::robin_map<std::ptrdiff_t, LinkTarget> relocations; std::vector<Relocation> relocations;
}; };
EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block); EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block);