From 38fa984b538870da7fb138ae1afc17e4ed93df2a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Apr 2018 15:12:00 -0400 Subject: [PATCH] IR: Add opcode for packed word->f32 conversions --- src/backend_x64/emit_x64_vector_floating_point.cpp | 9 +++++++++ src/frontend/ir/ir_emitter.cpp | 4 ++++ src/frontend/ir/ir_emitter.h | 1 + src/frontend/ir/opcodes.inc | 1 + 4 files changed, 15 insertions(+) diff --git a/src/backend_x64/emit_x64_vector_floating_point.cpp b/src/backend_x64/emit_x64_vector_floating_point.cpp index d92e1134..de5f6fcb 100644 --- a/src/backend_x64/emit_x64_vector_floating_point.cpp +++ b/src/backend_x64/emit_x64_vector_floating_point.cpp @@ -203,6 +203,15 @@ void EmitX64::EmitFPVectorMul64(EmitContext& ctx, IR::Inst* inst) { EmitVectorOperation64(code, ctx, inst, &Xbyak::CodeGenerator::mulpd); } +void EmitX64::EmitFPVectorS32ToSingle(EmitContext& ctx, IR::Inst* inst) { + auto args = ctx.reg_alloc.GetArgumentInfo(inst); + const Xbyak::Xmm xmm = ctx.reg_alloc.UseScratchXmm(args[0]); + + code.cvtdq2ps(xmm, xmm); + + ctx.reg_alloc.DefineValue(inst, xmm); +} + void EmitX64::EmitFPVectorSub32(EmitContext& ctx, IR::Inst* inst) { EmitVectorOperation32(code, ctx, inst, &Xbyak::CodeGenerator::subps); } diff --git a/src/frontend/ir/ir_emitter.cpp b/src/frontend/ir/ir_emitter.cpp index 78c13a39..fd86d9c5 100644 --- a/src/frontend/ir/ir_emitter.cpp +++ b/src/frontend/ir/ir_emitter.cpp @@ -1383,6 +1383,10 @@ U128 IREmitter::FPVectorSub(size_t esize, const U128& a, const U128& b) { return {}; } +U128 IREmitter::FPVectorS32ToSingle(const U128& a) { + return Inst(Opcode::FPVectorS32ToSingle, a); +} + void IREmitter::Breakpoint() { Inst(Opcode::Breakpoint); } diff --git a/src/frontend/ir/ir_emitter.h b/src/frontend/ir/ir_emitter.h index 1819c52c..880a165f 100644 --- a/src/frontend/ir/ir_emitter.h +++ b/src/frontend/ir/ir_emitter.h @@ -264,6 +264,7 @@ public: U128 FPVectorDiv(size_t esize, const U128& a, const U128& b); U128 FPVectorMul(size_t esize, const U128& a, const U128& b); U128 FPVectorSub(size_t esize, const U128& a, const U128& b); + U128 FPVectorS32ToSingle(const U128& a); void Breakpoint(); diff --git a/src/frontend/ir/opcodes.inc b/src/frontend/ir/opcodes.inc index ece3c33d..4c9aca9d 100644 --- a/src/frontend/ir/opcodes.inc +++ b/src/frontend/ir/opcodes.inc @@ -363,6 +363,7 @@ OPCODE(FPVectorDiv32, T::U128, T::U128, T::U OPCODE(FPVectorDiv64, T::U128, T::U128, T::U128 ) OPCODE(FPVectorMul32, T::U128, T::U128, T::U128 ) OPCODE(FPVectorMul64, T::U128, T::U128, T::U128 ) +OPCODE(FPVectorS32ToSingle, T::U128, T::U128 ) OPCODE(FPVectorSub32, T::U128, T::U128, T::U128 ) OPCODE(FPVectorSub64, T::U128, T::U128, T::U128 )