backend/arm64: Implement Identity

This commit is contained in:
Merry 2022-07-22 19:59:23 +01:00 committed by merry
parent 97ba8a0f14
commit fb3b828158
3 changed files with 12 additions and 5 deletions

View file

@ -24,11 +24,10 @@ template<>
void EmitIR<IR::Opcode::Void>(oaknut::CodeGenerator&, EmitContext&, IR::Inst*) {} void EmitIR<IR::Opcode::Void>(oaknut::CodeGenerator&, EmitContext&, IR::Inst*) {}
template<> template<>
void EmitIR<IR::Opcode::Identity>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) { void EmitIR<IR::Opcode::Identity>(oaknut::CodeGenerator&, EmitContext& ctx, IR::Inst* inst) {
(void)code; auto args = ctx.reg_alloc.GetArgumentInfo(inst);
(void)ctx;
(void)inst; ctx.reg_alloc.DefineAsExisting(inst, args[0]);
ASSERT_FALSE("Unimplemented");
} }
template<> template<>

View file

@ -92,6 +92,12 @@ bool RegAlloc::IsValueLive(IR::Inst* inst) const {
return !!ValueLocation(inst); return !!ValueLocation(inst);
} }
void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) {
auto& info = ValueInfo(arg.value.GetInst());
info.values.emplace_back(inst);
info.expected_uses += inst->UseCount();
}
void RegAlloc::AssertNoMoreUses() const { void RegAlloc::AssertNoMoreUses() const {
const auto is_empty = [](const auto& i) { return i.values.empty() && !i.locked && !i.realized && !i.accumulated_uses && !i.expected_uses; }; const auto is_empty = [](const auto& i) { return i.values.empty() && !i.locked && !i.realized && !i.accumulated_uses && !i.expected_uses; };
ASSERT(std::all_of(gprs.begin(), gprs.end(), is_empty)); ASSERT(std::all_of(gprs.begin(), gprs.end(), is_empty));

View file

@ -204,6 +204,8 @@ public:
} }
} }
void DefineAsExisting(IR::Inst* inst, Argument& arg);
void SpillFlags(); void SpillFlags();
void SpillAll(); void SpillAll();