emit_arm64_data_processing: Implement LogicalShift{Left,Right}64
This commit is contained in:
parent
0692f1d40e
commit
adb18fd0a7
1 changed files with 50 additions and 8 deletions
|
@ -321,10 +321,31 @@ void EmitIR<IR::Opcode::LogicalShiftLeft32>(oaknut::CodeGenerator& code, EmitCon
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void EmitIR<IR::Opcode::LogicalShiftLeft64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
void EmitIR<IR::Opcode::LogicalShiftLeft64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
||||||
(void)code;
|
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||||
(void)ctx;
|
|
||||||
(void)inst;
|
if (args[1].IsImmediate()) {
|
||||||
ASSERT_FALSE("Unimplemented");
|
const u8 shift = args[1].GetImmediateU8();
|
||||||
|
auto Xresult = ctx.reg_alloc.WriteX(inst);
|
||||||
|
auto Xoperand = ctx.reg_alloc.ReadX(args[0]);
|
||||||
|
RegAlloc::Realize(Xresult, Xoperand);
|
||||||
|
|
||||||
|
if (shift <= 63) {
|
||||||
|
code.LSL(Xresult, Xoperand, shift);
|
||||||
|
} else {
|
||||||
|
code.MOV(Xresult, XZR);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto Xresult = ctx.reg_alloc.WriteX(inst);
|
||||||
|
auto Xoperand = ctx.reg_alloc.ReadX(args[0]);
|
||||||
|
auto Xshift = ctx.reg_alloc.ReadX(args[1]);
|
||||||
|
RegAlloc::Realize(Xresult, Xoperand, Xshift);
|
||||||
|
ctx.reg_alloc.SpillFlags();
|
||||||
|
|
||||||
|
code.AND(Xscratch0, Xshift, 0xff);
|
||||||
|
code.LSL(Xresult, Xoperand, Xscratch0);
|
||||||
|
code.CMP(Xscratch0, 64);
|
||||||
|
code.CSEL(Xresult, Xresult, XZR, LT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -430,10 +451,31 @@ void EmitIR<IR::Opcode::LogicalShiftRight32>(oaknut::CodeGenerator& code, EmitCo
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void EmitIR<IR::Opcode::LogicalShiftRight64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
void EmitIR<IR::Opcode::LogicalShiftRight64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
||||||
(void)code;
|
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||||
(void)ctx;
|
|
||||||
(void)inst;
|
if (args[1].IsImmediate()) {
|
||||||
ASSERT_FALSE("Unimplemented");
|
const u8 shift = args[1].GetImmediateU8();
|
||||||
|
auto Xresult = ctx.reg_alloc.WriteX(inst);
|
||||||
|
auto Xoperand = ctx.reg_alloc.ReadX(args[0]);
|
||||||
|
RegAlloc::Realize(Xresult, Xoperand);
|
||||||
|
|
||||||
|
if (shift <= 63) {
|
||||||
|
code.LSR(Xresult, Xoperand, shift);
|
||||||
|
} else {
|
||||||
|
code.MOV(Xresult, XZR);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto Xresult = ctx.reg_alloc.WriteX(inst);
|
||||||
|
auto Xoperand = ctx.reg_alloc.ReadX(args[0]);
|
||||||
|
auto Xshift = ctx.reg_alloc.ReadX(args[1]);
|
||||||
|
RegAlloc::Realize(Xresult, Xoperand, Xshift);
|
||||||
|
ctx.reg_alloc.SpillFlags();
|
||||||
|
|
||||||
|
code.AND(Xscratch0, Xshift, 0xff);
|
||||||
|
code.LSR(Xresult, Xoperand, Xscratch0);
|
||||||
|
code.CMP(Xscratch0, 64);
|
||||||
|
code.CSEL(Xresult, Xresult, XZR, LT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
Loading…
Reference in a new issue