mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-04 21:55:06 +01:00
IR: Add VectorDeinterleave{Even,Odd}Lower
This commit is contained in:
parent
df477c46c2
commit
f35aaa017c
4 changed files with 150 additions and 22 deletions
|
|
@ -895,28 +895,74 @@ void EmitX64::EmitVectorDeinterleaveEven16(EmitContext& ctx, IR::Inst* inst) {
|
|||
void EmitX64::EmitVectorDeinterleaveEven32(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
|
||||
code.pshufd(lhs, lhs, 0b10001000);
|
||||
code.pshufd(rhs, rhs, 0b10001000);
|
||||
|
||||
if (code.HasSSE41()) {
|
||||
code.pblendw(lhs, rhs, 0b11110000);
|
||||
} else {
|
||||
code.punpcklqdq(lhs, rhs);
|
||||
}
|
||||
code.shufps(lhs, rhs, 0b10001000);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveEven64(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
|
||||
code.shufpd(lhs, rhs, 0b00);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveEvenLower8(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
const Xbyak::Xmm tmp = ctx.reg_alloc.ScratchXmm();
|
||||
|
||||
code.movdqa(tmp, code.MConst(xword, 0x00FF00FF00FF00FF, 0x00FF00FF00FF00FF));
|
||||
code.pand(lhs, tmp);
|
||||
code.pand(rhs, tmp);
|
||||
code.packuswb(lhs, rhs);
|
||||
code.pshufd(lhs, lhs, 0b11011000);
|
||||
code.movq(lhs, lhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveEvenLower16(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
|
||||
code.pslld(lhs, 16);
|
||||
code.psrad(lhs, 16);
|
||||
|
||||
code.pslld(rhs, 16);
|
||||
code.psrad(rhs, 16);
|
||||
|
||||
code.packssdw(lhs, rhs);
|
||||
code.pshufd(lhs, lhs, 0b11011000);
|
||||
code.movq(lhs, lhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveEvenLower32(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
|
||||
code.unpcklps(lhs, rhs);
|
||||
code.movq(lhs, lhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveEvenLower64(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
[[maybe_unused]] const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
|
||||
code.movq(lhs, lhs);
|
||||
code.pslldq(rhs, 8);
|
||||
code.por(lhs, rhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
|
@ -948,16 +994,9 @@ void EmitX64::EmitVectorDeinterleaveOdd16(EmitContext& ctx, IR::Inst* inst) {
|
|||
void EmitX64::EmitVectorDeinterleaveOdd32(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
|
||||
code.pshufd(lhs, lhs, 0b11011101);
|
||||
code.pshufd(rhs, rhs, 0b11011101);
|
||||
|
||||
if (code.HasSSE41()) {
|
||||
code.pblendw(lhs, rhs, 0b11110000);
|
||||
} else {
|
||||
code.punpcklqdq(lhs, rhs);
|
||||
}
|
||||
code.shufps(lhs, rhs, 0b11011101);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
|
@ -965,13 +1004,64 @@ void EmitX64::EmitVectorDeinterleaveOdd32(EmitContext& ctx, IR::Inst* inst) {
|
|||
void EmitX64::EmitVectorDeinterleaveOdd64(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
|
||||
code.punpckhqdq(lhs, rhs);
|
||||
code.shufpd(lhs, rhs, 0b11);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveOddLower8(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
|
||||
code.psraw(lhs, 8);
|
||||
code.psraw(rhs, 8);
|
||||
code.packsswb(lhs, rhs);
|
||||
code.pshufd(lhs, lhs, 0b11011000);
|
||||
code.movq(lhs, lhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveOddLower16(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
|
||||
code.psrad(lhs, 16);
|
||||
code.psrad(rhs, 16);
|
||||
code.packssdw(lhs, rhs);
|
||||
code.pshufd(lhs, lhs, 0b11011000);
|
||||
code.movq(lhs, lhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveOddLower32(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
const Xbyak::Xmm lhs = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseXmm(args[1]);
|
||||
const Xbyak::Xmm zero = ctx.reg_alloc.ScratchXmm();
|
||||
|
||||
code.xorps(zero, zero);
|
||||
code.unpcklps(lhs, rhs);
|
||||
code.unpckhpd(lhs, zero);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, lhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorDeinterleaveOddLower64(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
[[maybe_unused]] const Xbyak::Xmm lhs = ctx.reg_alloc.UseXmm(args[0]);
|
||||
const Xbyak::Xmm rhs = ctx.reg_alloc.UseScratchXmm(args[1]);
|
||||
|
||||
code.movq(rhs, rhs);
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, rhs);
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorEor(EmitContext& ctx, IR::Inst* inst) {
|
||||
EmitVectorOperation(code, ctx, inst, &Xbyak::CodeGenerator::pxor);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue