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*) {}
template<>
void EmitIR<IR::Opcode::Identity>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
(void)code;
(void)ctx;
(void)inst;
ASSERT_FALSE("Unimplemented");
void EmitIR<IR::Opcode::Identity>(oaknut::CodeGenerator&, EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
ctx.reg_alloc.DefineAsExisting(inst, args[0]);
}
template<>

View file

@ -92,6 +92,12 @@ bool RegAlloc::IsValueLive(IR::Inst* inst) const {
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 {
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));

View file

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