ir: Add opcode for performing FP vector absolute differences

This commit is contained in:
Lioncash 2018-06-08 19:49:42 -04:00 committed by MerryMage
parent ba84e7a8de
commit 8a4f8aed06
4 changed files with 36 additions and 0 deletions

View file

@ -173,6 +173,28 @@ static void EmitVectorOperation64(BlockOfCode& code, EmitContext& ctx, IR::Inst*
ctx.reg_alloc.DefineValue(inst, result); ctx.reg_alloc.DefineValue(inst, result);
} }
void EmitX64::EmitFPVectorAbsoluteDifference32(EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
const Xbyak::Xmm a = ctx.reg_alloc.UseScratchXmm(args[0]);
const Xbyak::Xmm b = ctx.reg_alloc.UseXmm(args[1]);
code.subps(a, b);
code.andps(a, code.MConst(xword, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF));
ctx.reg_alloc.DefineValue(inst, a);
}
void EmitX64::EmitFPVectorAbsoluteDifference64(EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
const Xbyak::Xmm a = ctx.reg_alloc.UseScratchXmm(args[0]);
const Xbyak::Xmm b = ctx.reg_alloc.UseXmm(args[1]);
code.subpd(a, b);
code.andpd(a, code.MConst(xword, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF));
ctx.reg_alloc.DefineValue(inst, a);
}
void EmitX64::EmitFPVectorAdd32(EmitContext& ctx, IR::Inst* inst) { void EmitX64::EmitFPVectorAdd32(EmitContext& ctx, IR::Inst* inst) {
EmitVectorOperation32(code, ctx, inst, &Xbyak::CodeGenerator::addps); EmitVectorOperation32(code, ctx, inst, &Xbyak::CodeGenerator::addps);
} }

View file

@ -1491,6 +1491,17 @@ U64 IREmitter::FPU32ToDouble(const U32& a, bool round_to_nearest, bool fpscr_con
return Inst<U64>(Opcode::FPU32ToDouble, a, Imm1(round_to_nearest)); return Inst<U64>(Opcode::FPU32ToDouble, a, Imm1(round_to_nearest));
} }
U128 IREmitter::FPVectorAbsoluteDifference(size_t esize, const U128& a, const U128& b) {
switch (esize) {
case 32:
return Inst<U128>(Opcode::FPVectorAbsoluteDifference32, a, b);
case 64:
return Inst<U128>(Opcode::FPVectorAbsoluteDifference64, a, b);
}
UNREACHABLE();
return {};
}
U128 IREmitter::FPVectorAdd(size_t esize, const U128& a, const U128& b) { U128 IREmitter::FPVectorAdd(size_t esize, const U128& a, const U128& b) {
switch (esize) { switch (esize) {
case 32: case 32:

View file

@ -273,6 +273,7 @@ public:
U64 FPS32ToDouble(const U32& a, bool round_to_nearest, bool fpscr_controlled); U64 FPS32ToDouble(const U32& a, bool round_to_nearest, bool fpscr_controlled);
U64 FPU32ToDouble(const U32& a, bool round_to_nearest, bool fpscr_controlled); U64 FPU32ToDouble(const U32& a, bool round_to_nearest, bool fpscr_controlled);
U128 FPVectorAbsoluteDifference(size_t esize, const U128& a, const U128& b);
U128 FPVectorAdd(size_t esize, const U128& a, const U128& b); U128 FPVectorAdd(size_t esize, const U128& a, const U128& b);
U128 FPVectorDiv(size_t esize, const U128& a, const U128& b); U128 FPVectorDiv(size_t esize, const U128& a, const U128& b);
U128 FPVectorEqual(size_t esize, const U128& a, const U128& b); U128 FPVectorEqual(size_t esize, const U128& a, const U128& b);

View file

@ -396,6 +396,8 @@ OPCODE(FPU32ToDouble, T::U64, T::U32, T::U
OPCODE(FPS32ToDouble, T::U64, T::U32, T::U1 ) OPCODE(FPS32ToDouble, T::U64, T::U32, T::U1 )
// Floating-point vector instructions // Floating-point vector instructions
OPCODE(FPVectorAbsoluteDifference32, T::U128, T::U128, T::U128 )
OPCODE(FPVectorAbsoluteDifference64, T::U128, T::U128, T::U128 )
OPCODE(FPVectorAdd32, T::U128, T::U128, T::U128 ) OPCODE(FPVectorAdd32, T::U128, T::U128, T::U128 )
OPCODE(FPVectorAdd64, T::U128, T::U128, T::U128 ) OPCODE(FPVectorAdd64, T::U128, T::U128, T::U128 )
OPCODE(FPVectorDiv32, T::U128, T::U128, T::U128 ) OPCODE(FPVectorDiv32, T::U128, T::U128, T::U128 )