backend/arm64: Implement Eor
This commit is contained in:
parent
4e3fd70f6e
commit
4cff0d9977
1 changed files with 32 additions and 28 deletions
|
@ -3,6 +3,8 @@
|
|||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <fmt/ostream.h>
|
||||
#include <oaknut/oaknut.hpp>
|
||||
|
||||
|
@ -655,8 +657,8 @@ static void MaybeBitImm(oaknut::CodeGenerator& code, u64 imm, EmitFn emit_fn) {
|
|||
}
|
||||
}
|
||||
|
||||
template<size_t bitsize, typename EmitFn1, typename EmitFn2>
|
||||
static void EmitBitOp(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst, EmitFn1 emit_without_flags, EmitFn2 emit_with_flags) {
|
||||
template<size_t bitsize, typename EmitFn1, typename EmitFn2 = std::nullptr_t>
|
||||
static void EmitBitOp(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst, EmitFn1 emit_without_flags, EmitFn2 emit_with_flags = nullptr) {
|
||||
const auto nz_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetNZFromOp);
|
||||
const auto nzcv_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetNZCVFromOp);
|
||||
ASSERT(!(nz_inst && nzcv_inst));
|
||||
|
@ -666,6 +668,7 @@ static void EmitBitOp(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* i
|
|||
auto Rresult = ctx.reg_alloc.WriteReg<bitsize>(inst);
|
||||
auto Ra = ctx.reg_alloc.ReadReg<bitsize>(args[0]);
|
||||
|
||||
if constexpr (!std::is_same_v<EmitFn2, std::nullptr_t>) {
|
||||
if (flag_inst) {
|
||||
auto Wflags = ctx.reg_alloc.WriteFlags(flag_inst);
|
||||
|
||||
|
@ -679,7 +682,11 @@ static void EmitBitOp(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* i
|
|||
|
||||
emit_with_flags(Rresult, Ra, Rb);
|
||||
}
|
||||
} else {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[1].IsImmediate()) {
|
||||
RegAlloc::Realize(Rresult, Ra);
|
||||
|
||||
|
@ -691,7 +698,6 @@ static void EmitBitOp(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* i
|
|||
emit_without_flags(Rresult, Rb, Rb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void EmitIR<IR::Opcode::And32>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
||||
|
@ -727,18 +733,16 @@ void EmitIR<IR::Opcode::AndNot64>(oaknut::CodeGenerator& code, EmitContext& ctx,
|
|||
|
||||
template<>
|
||||
void EmitIR<IR::Opcode::Eor32>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
||||
(void)code;
|
||||
(void)ctx;
|
||||
(void)inst;
|
||||
ASSERT_FALSE("Unimplemented");
|
||||
EmitBitOp<32>(
|
||||
code, ctx, inst,
|
||||
[&](auto& result, auto& a, auto& b) { code.EOR(result, a, b); });
|
||||
}
|
||||
|
||||
template<>
|
||||
void EmitIR<IR::Opcode::Eor64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
||||
(void)code;
|
||||
(void)ctx;
|
||||
(void)inst;
|
||||
ASSERT_FALSE("Unimplemented");
|
||||
EmitBitOp<64>(
|
||||
code, ctx, inst,
|
||||
[&](auto& result, auto& a, auto& b) { code.EOR(result, a, b); });
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Reference in a new issue