[a64] Implement HIR Branch labeling

Adds support for HIR labels to create actual oaknut labels
This commit is contained in:
Wunkolo 2024-05-04 15:46:18 -07:00
parent e5fd3d340c
commit 8257740d21
2 changed files with 10 additions and 2 deletions

View File

@ -265,8 +265,7 @@ bool A64Emitter::Emit(HIRBuilder* builder, EmitFunctionInfo& func_info) {
// Mark block labels.
auto label = block->label_head;
while (label) {
// TODO(wunkolo): string-labels?
// L(label->name);
l(label_lookup_[label->name]);
label = label->next;
}

View File

@ -10,6 +10,7 @@
#ifndef XENIA_CPU_BACKEND_A64_A64_EMITTER_H_
#define XENIA_CPU_BACKEND_A64_A64_EMITTER_H_
#include <unordered_map>
#include <vector>
#include "xenia/base/arena.h"
@ -165,6 +166,11 @@ class A64Emitter : public oaknut::CodeBlock, public oaknut::CodeGenerator {
r = oaknut::QReg(idx);
}
// Gets(and possibly create) an HIR label with the specified name
oaknut::Label* lookup_label(const char* label_name) {
return &label_lookup_[label_name];
}
oaknut::Label& epilog_label() { return *epilog_label_; }
void MarkSourceOffset(const hir::Instr* i);
@ -229,6 +235,9 @@ class A64Emitter : public oaknut::CodeBlock, public oaknut::CodeGenerator {
oaknut::Label* epilog_label_ = nullptr;
// Convert from plain-text label-names into oaknut-labels
std::unordered_map<std::string, oaknut::Label> label_lookup_;
hir::Instr* current_instr_ = nullptr;
FunctionDebugInfo* debug_info_ = nullptr;