diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index 2d56b952c..ec2a8b085 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -5147,8 +5147,8 @@ void OpDispatchBuilder::InstallHostSpecificOpcodeHandlers() { {OPD(1, 0b01, 0x7F), 1, &OpDispatchBuilder::VMOVAPS_VMOVAPDOp}, {OPD(1, 0b10, 0x7F), 1, &OpDispatchBuilder::VMOVUPS_VMOVUPDOp}, - {OPD(1, 0b00, 0xC2), 1, &OpDispatchBuilder::AVXVFCMPOp<4>}, - {OPD(1, 0b01, 0xC2), 1, &OpDispatchBuilder::AVXVFCMPOp<8>}, + {OPD(1, 0b00, 0xC2), 1, &OpDispatchBuilder::AVXVFCMPOp}, + {OPD(1, 0b01, 0xC2), 1, &OpDispatchBuilder::AVXVFCMPOp}, {OPD(1, 0b10, 0xC2), 1, &OpDispatchBuilder::AVXInsertScalarFCMPOp}, {OPD(1, 0b11, 0xC2), 1, &OpDispatchBuilder::AVXInsertScalarFCMPOp}, diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.h b/FEXCore/Source/Interface/Core/OpcodeDispatcher.h index c2ad5a122..6ddc507c3 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.h +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.h @@ -476,7 +476,7 @@ public: void MOVBetweenGPR_FPR(OpcodeArgs, VectorOpType VectorType); void TZCNT(OpcodeArgs); void LZCNT(OpcodeArgs); - template + template void VFCMPOp(OpcodeArgs); void SHUFOp(OpcodeArgs, size_t ElementSize); template @@ -558,7 +558,7 @@ public: template void AVXCVTGPR_To_FPR(OpcodeArgs); - template + template void AVXVFCMPOp(OpcodeArgs); template @@ -938,7 +938,8 @@ public: void AVX128_VectorALU(OpcodeArgs, IROps IROp, size_t ElementSize); void AVX128_VectorUnary(OpcodeArgs, IROps IROp, size_t ElementSize); void AVX128_VectorUnaryImpl(OpcodeArgs, size_t SrcSize, size_t ElementSize, std::function Helper); - void AVX128_VectorBinaryImpl(OpcodeArgs, size_t SrcSize, size_t ElementSize, std::function Helper); + void AVX128_VectorBinaryImpl(OpcodeArgs, size_t SrcSize, IR::OpSize ElementSize, + std::function Helper); void AVX128_VectorShiftWideImpl(OpcodeArgs, size_t ElementSize, IROps IROp); void AVX128_VectorShiftImmImpl(OpcodeArgs, size_t ElementSize, IROps IROp); void AVX128_VectorTrinaryImpl(OpcodeArgs, size_t SrcSize, size_t ElementSize, Ref Src3, @@ -963,9 +964,9 @@ public: void AVX128_VMOVSHDUP(OpcodeArgs); template void AVX128_VBROADCAST(OpcodeArgs); - template + template void AVX128_VPUNPCKL(OpcodeArgs); - template + template void AVX128_VPUNPCKH(OpcodeArgs); void AVX128_MOVVectorUnaligned(OpcodeArgs); template @@ -973,18 +974,18 @@ public: template void AVX128_CVTFPR_To_GPR(OpcodeArgs); void AVX128_VANDN(OpcodeArgs); - template + template void AVX128_VPACKSS(OpcodeArgs); - template + template void AVX128_VPACKUS(OpcodeArgs); Ref AVX128_PSIGNImpl(size_t ElementSize, Ref Src1, Ref Src2); - template + template void AVX128_VPSIGN(OpcodeArgs); template void AVX128_UCOMISx(OpcodeArgs); void AVX128_VectorScalarInsertALU(OpcodeArgs, FEXCore::IR::IROps IROp, IR::OpSize ElementSize); - Ref AVX128_VFCMPImpl(size_t ElementSize, Ref Src1, Ref Src2, uint8_t CompType); - template + Ref AVX128_VFCMPImpl(IR::OpSize ElementSize, Ref Src1, Ref Src2, uint8_t CompType); + template void AVX128_VFCMP(OpcodeArgs); template void AVX128_InsertScalarFCMP(OpcodeArgs); @@ -1007,15 +1008,15 @@ public: void AVX128_VINSERTPS(OpcodeArgs); Ref AVX128_PHSUBImpl(Ref Src1, Ref Src2, size_t ElementSize); - template + template void AVX128_VPHSUB(OpcodeArgs); void AVX128_VPHSUBSW(OpcodeArgs); - template + template void AVX128_VADDSUBP(OpcodeArgs); - template + template void AVX128_VPMULL(OpcodeArgs); void AVX128_VPMULHRSW(OpcodeArgs); @@ -1055,7 +1056,7 @@ public: template void AVX128_InsertScalarRound(OpcodeArgs); - template + template void AVX128_VDPP(OpcodeArgs); void AVX128_VPERMQ(OpcodeArgs); @@ -1067,7 +1068,7 @@ public: template void AVX128_VPERMILImm(OpcodeArgs); - template + template void AVX128_VHADDP(OpcodeArgs); void AVX128_VPHADDSW(OpcodeArgs); @@ -1078,7 +1079,7 @@ public: template void AVX128_VBLEND(OpcodeArgs); - template + template void AVX128_VHSUBP(OpcodeArgs); void AVX128_VPSHUFB(OpcodeArgs); @@ -1430,7 +1431,7 @@ private: void MOVScalarOpImpl(OpcodeArgs, IR::OpSize ElementSize); void VMOVScalarOpImpl(OpcodeArgs, IR::OpSize ElementSize); - Ref VFCMPOpImpl(OpSize Size, size_t ElementSize, Ref Src1, Ref Src2, uint8_t CompType); + Ref VFCMPOpImpl(OpSize Size, IR::OpSize ElementSize, Ref Src1, Ref Src2, uint8_t CompType); void VTESTOpImpl(OpSize SrcSize, size_t ElementSize, Ref Src1, Ref Src2); diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/AVX_128.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/AVX_128.cpp index 16f66cab2..e0cdea098 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/AVX_128.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/AVX_128.cpp @@ -40,11 +40,11 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b00, 0x13), 1, &OpDispatchBuilder::AVX128_VMOVLP}, {OPD(1, 0b01, 0x13), 1, &OpDispatchBuilder::AVX128_VMOVLP}, - {OPD(1, 0b00, 0x14), 1, &OpDispatchBuilder::AVX128_VPUNPCKL<4>}, - {OPD(1, 0b01, 0x14), 1, &OpDispatchBuilder::AVX128_VPUNPCKL<8>}, + {OPD(1, 0b00, 0x14), 1, &OpDispatchBuilder::AVX128_VPUNPCKL}, + {OPD(1, 0b01, 0x14), 1, &OpDispatchBuilder::AVX128_VPUNPCKL}, - {OPD(1, 0b00, 0x15), 1, &OpDispatchBuilder::AVX128_VPUNPCKH<4>}, - {OPD(1, 0b01, 0x15), 1, &OpDispatchBuilder::AVX128_VPUNPCKH<8>}, + {OPD(1, 0b00, 0x15), 1, &OpDispatchBuilder::AVX128_VPUNPCKH}, + {OPD(1, 0b01, 0x15), 1, &OpDispatchBuilder::AVX128_VPUNPCKH}, {OPD(1, 0b00, 0x16), 1, &OpDispatchBuilder::AVX128_VMOVHP}, {OPD(1, 0b01, 0x16), 1, &OpDispatchBuilder::AVX128_VMOVHP}, @@ -139,20 +139,20 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b10, 0x5F), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorScalarInsertALU, IR::OP_VFMAXSCALARINSERT, OpSize::i32Bit>}, {OPD(1, 0b11, 0x5F), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorScalarInsertALU, IR::OP_VFMAXSCALARINSERT, OpSize::i64Bit>}, - {OPD(1, 0b01, 0x60), 1, &OpDispatchBuilder::AVX128_VPUNPCKL<1>}, - {OPD(1, 0b01, 0x61), 1, &OpDispatchBuilder::AVX128_VPUNPCKL<2>}, - {OPD(1, 0b01, 0x62), 1, &OpDispatchBuilder::AVX128_VPUNPCKL<4>}, - {OPD(1, 0b01, 0x63), 1, &OpDispatchBuilder::AVX128_VPACKSS<2>}, + {OPD(1, 0b01, 0x60), 1, &OpDispatchBuilder::AVX128_VPUNPCKL}, + {OPD(1, 0b01, 0x61), 1, &OpDispatchBuilder::AVX128_VPUNPCKL}, + {OPD(1, 0b01, 0x62), 1, &OpDispatchBuilder::AVX128_VPUNPCKL}, + {OPD(1, 0b01, 0x63), 1, &OpDispatchBuilder::AVX128_VPACKSS}, {OPD(1, 0b01, 0x64), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorALU, IR::OP_VCMPGT, 1>}, {OPD(1, 0b01, 0x65), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorALU, IR::OP_VCMPGT, 2>}, {OPD(1, 0b01, 0x66), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorALU, IR::OP_VCMPGT, 4>}, - {OPD(1, 0b01, 0x67), 1, &OpDispatchBuilder::AVX128_VPACKUS<2>}, - {OPD(1, 0b01, 0x68), 1, &OpDispatchBuilder::AVX128_VPUNPCKH<1>}, - {OPD(1, 0b01, 0x69), 1, &OpDispatchBuilder::AVX128_VPUNPCKH<2>}, - {OPD(1, 0b01, 0x6A), 1, &OpDispatchBuilder::AVX128_VPUNPCKH<4>}, - {OPD(1, 0b01, 0x6B), 1, &OpDispatchBuilder::AVX128_VPACKSS<4>}, - {OPD(1, 0b01, 0x6C), 1, &OpDispatchBuilder::AVX128_VPUNPCKL<8>}, - {OPD(1, 0b01, 0x6D), 1, &OpDispatchBuilder::AVX128_VPUNPCKH<8>}, + {OPD(1, 0b01, 0x67), 1, &OpDispatchBuilder::AVX128_VPACKUS}, + {OPD(1, 0b01, 0x68), 1, &OpDispatchBuilder::AVX128_VPUNPCKH}, + {OPD(1, 0b01, 0x69), 1, &OpDispatchBuilder::AVX128_VPUNPCKH}, + {OPD(1, 0b01, 0x6A), 1, &OpDispatchBuilder::AVX128_VPUNPCKH}, + {OPD(1, 0b01, 0x6B), 1, &OpDispatchBuilder::AVX128_VPACKSS}, + {OPD(1, 0b01, 0x6C), 1, &OpDispatchBuilder::AVX128_VPUNPCKL}, + {OPD(1, 0b01, 0x6D), 1, &OpDispatchBuilder::AVX128_VPUNPCKH}, {OPD(1, 0b01, 0x6E), 1, &OpDispatchBuilder::AVX128_MOVBetweenGPR_FPR}, {OPD(1, 0b01, 0x6F), 1, &OpDispatchBuilder::AVX128_VMOVAPS}, @@ -168,8 +168,8 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b00, 0x77), 1, &OpDispatchBuilder::AVX128_VZERO}, - {OPD(1, 0b01, 0x7C), 1, &OpDispatchBuilder::AVX128_VHADDP}, - {OPD(1, 0b11, 0x7C), 1, &OpDispatchBuilder::AVX128_VHADDP}, + {OPD(1, 0b01, 0x7C), 1, &OpDispatchBuilder::AVX128_VHADDP}, + {OPD(1, 0b11, 0x7C), 1, &OpDispatchBuilder::AVX128_VHADDP}, {OPD(1, 0b01, 0x7D), 1, &OpDispatchBuilder::AVX128_VHSUBP}, {OPD(1, 0b11, 0x7D), 1, &OpDispatchBuilder::AVX128_VHSUBP}, @@ -179,8 +179,8 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b01, 0x7F), 1, &OpDispatchBuilder::AVX128_VMOVAPS}, {OPD(1, 0b10, 0x7F), 1, &OpDispatchBuilder::AVX128_VMOVAPS}, - {OPD(1, 0b00, 0xC2), 1, &OpDispatchBuilder::AVX128_VFCMP<4>}, - {OPD(1, 0b01, 0xC2), 1, &OpDispatchBuilder::AVX128_VFCMP<8>}, + {OPD(1, 0b00, 0xC2), 1, &OpDispatchBuilder::AVX128_VFCMP}, + {OPD(1, 0b01, 0xC2), 1, &OpDispatchBuilder::AVX128_VFCMP}, {OPD(1, 0b10, 0xC2), 1, &OpDispatchBuilder::AVX128_InsertScalarFCMP}, {OPD(1, 0b11, 0xC2), 1, &OpDispatchBuilder::AVX128_InsertScalarFCMP}, @@ -190,8 +190,8 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b00, 0xC6), 1, &OpDispatchBuilder::AVX128_VSHUF<4>}, {OPD(1, 0b01, 0xC6), 1, &OpDispatchBuilder::AVX128_VSHUF<8>}, - {OPD(1, 0b01, 0xD0), 1, &OpDispatchBuilder::AVX128_VADDSUBP<8>}, - {OPD(1, 0b11, 0xD0), 1, &OpDispatchBuilder::AVX128_VADDSUBP<4>}, + {OPD(1, 0b01, 0xD0), 1, &OpDispatchBuilder::AVX128_VADDSUBP}, + {OPD(1, 0b11, 0xD0), 1, &OpDispatchBuilder::AVX128_VADDSUBP}, {OPD(1, 0b01, 0xD1), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorShiftWideImpl, 2, IROps::OP_VUSHRSWIDE>}, // VPSRL {OPD(1, 0b01, 0xD2), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorShiftWideImpl, 4, IROps::OP_VUSHRSWIDE>}, // VPSRL @@ -236,7 +236,7 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b01, 0xF1), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorShiftWideImpl, 2, IROps::OP_VUSHLSWIDE>}, // VPSLL {OPD(1, 0b01, 0xF2), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorShiftWideImpl, 4, IROps::OP_VUSHLSWIDE>}, // VPSLL {OPD(1, 0b01, 0xF3), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorShiftWideImpl, 8, IROps::OP_VUSHLSWIDE>}, // VPSLL - {OPD(1, 0b01, 0xF4), 1, &OpDispatchBuilder::AVX128_VPMULL<4, false>}, + {OPD(1, 0b01, 0xF4), 1, &OpDispatchBuilder::AVX128_VPMULL}, {OPD(1, 0b01, 0xF5), 1, &OpDispatchBuilder::AVX128_VPMADDWD}, {OPD(1, 0b01, 0xF6), 1, &OpDispatchBuilder::AVX128_VPSADBW}, {OPD(1, 0b01, 0xF7), 1, &OpDispatchBuilder::AVX128_MASKMOV}, @@ -250,18 +250,18 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(1, 0b01, 0xFE), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorALU, IR::OP_VADD, 4>}, {OPD(2, 0b01, 0x00), 1, &OpDispatchBuilder::AVX128_VPSHUFB}, - {OPD(2, 0b01, 0x01), 1, &OpDispatchBuilder::AVX128_VHADDP}, - {OPD(2, 0b01, 0x02), 1, &OpDispatchBuilder::AVX128_VHADDP}, + {OPD(2, 0b01, 0x01), 1, &OpDispatchBuilder::AVX128_VHADDP}, + {OPD(2, 0b01, 0x02), 1, &OpDispatchBuilder::AVX128_VHADDP}, {OPD(2, 0b01, 0x03), 1, &OpDispatchBuilder::AVX128_VPHADDSW}, {OPD(2, 0b01, 0x04), 1, &OpDispatchBuilder::AVX128_VPMADDUBSW}, - {OPD(2, 0b01, 0x05), 1, &OpDispatchBuilder::AVX128_VPHSUB<2>}, - {OPD(2, 0b01, 0x06), 1, &OpDispatchBuilder::AVX128_VPHSUB<4>}, + {OPD(2, 0b01, 0x05), 1, &OpDispatchBuilder::AVX128_VPHSUB}, + {OPD(2, 0b01, 0x06), 1, &OpDispatchBuilder::AVX128_VPHSUB}, {OPD(2, 0b01, 0x07), 1, &OpDispatchBuilder::AVX128_VPHSUBSW}, - {OPD(2, 0b01, 0x08), 1, &OpDispatchBuilder::AVX128_VPSIGN<1>}, - {OPD(2, 0b01, 0x09), 1, &OpDispatchBuilder::AVX128_VPSIGN<2>}, - {OPD(2, 0b01, 0x0A), 1, &OpDispatchBuilder::AVX128_VPSIGN<4>}, + {OPD(2, 0b01, 0x08), 1, &OpDispatchBuilder::AVX128_VPSIGN}, + {OPD(2, 0b01, 0x09), 1, &OpDispatchBuilder::AVX128_VPSIGN}, + {OPD(2, 0b01, 0x0A), 1, &OpDispatchBuilder::AVX128_VPSIGN}, {OPD(2, 0b01, 0x0B), 1, &OpDispatchBuilder::AVX128_VPMULHRSW}, {OPD(2, 0b01, 0x0C), 1, &OpDispatchBuilder::AVX128_VPERMILReg}, {OPD(2, 0b01, 0x0D), 1, &OpDispatchBuilder::AVX128_VPERMILReg}, @@ -286,10 +286,10 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(2, 0b01, 0x24), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_ExtendVectorElements, 2, 8, true>}, {OPD(2, 0b01, 0x25), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_ExtendVectorElements, 4, 8, true>}, - {OPD(2, 0b01, 0x28), 1, &OpDispatchBuilder::AVX128_VPMULL<4, true>}, + {OPD(2, 0b01, 0x28), 1, &OpDispatchBuilder::AVX128_VPMULL}, {OPD(2, 0b01, 0x29), 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::AVX128_VectorALU, IR::OP_VCMPEQ, 8>}, {OPD(2, 0b01, 0x2A), 1, &OpDispatchBuilder::AVX128_MOVVectorNT}, - {OPD(2, 0b01, 0x2B), 1, &OpDispatchBuilder::AVX128_VPACKUS<4>}, + {OPD(2, 0b01, 0x2B), 1, &OpDispatchBuilder::AVX128_VPACKUS}, {OPD(2, 0b01, 0x2C), 1, &OpDispatchBuilder::AVX128_VMASKMOV}, {OPD(2, 0b01, 0x2D), 1, &OpDispatchBuilder::AVX128_VMASKMOV}, {OPD(2, 0b01, 0x2E), 1, &OpDispatchBuilder::AVX128_VMASKMOV}, @@ -406,8 +406,8 @@ void OpDispatchBuilder::InstallAVX128Handlers() { {OPD(3, 0b01, 0x38), 1, &OpDispatchBuilder::AVX128_VINSERT}, {OPD(3, 0b01, 0x39), 1, &OpDispatchBuilder::AVX128_VEXTRACT128}, - {OPD(3, 0b01, 0x40), 1, &OpDispatchBuilder::AVX128_VDPP<4>}, - {OPD(3, 0b01, 0x41), 1, &OpDispatchBuilder::AVX128_VDPP<8>}, + {OPD(3, 0b01, 0x40), 1, &OpDispatchBuilder::AVX128_VDPP}, + {OPD(3, 0b01, 0x41), 1, &OpDispatchBuilder::AVX128_VDPP}, {OPD(3, 0b01, 0x42), 1, &OpDispatchBuilder::AVX128_VMPSADBW}, {OPD(3, 0b01, 0x46), 1, &OpDispatchBuilder::AVX128_VPERM2}, @@ -672,8 +672,8 @@ void OpDispatchBuilder::AVX128_VectorUnaryImpl(OpcodeArgs, size_t SrcSize, size_ AVX128_StoreResult_WithOpSize(Op, Op->Dest, Result); } -void OpDispatchBuilder::AVX128_VectorBinaryImpl(OpcodeArgs, size_t SrcSize, size_t ElementSize, - std::function Helper) { +void OpDispatchBuilder::AVX128_VectorBinaryImpl(OpcodeArgs, size_t SrcSize, IR::OpSize ElementSize, + std::function Helper) { const auto Is128Bit = SrcSize == Core::CPUState::XMM_SSE_REG_SIZE; auto Src1 = AVX128_LoadSource_WithOpSize(Op, Op->Src[0], Op->Flags, !Is128Bit); @@ -974,16 +974,16 @@ void OpDispatchBuilder::AVX128_VBROADCAST(OpcodeArgs) { AVX128_StoreResult_WithOpSize(Op, Op->Dest, Src); } -template +template void OpDispatchBuilder::AVX128_VPUNPCKL(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return _VZip(OpSize::i128Bit, _ElementSize, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return _VZip(OpSize::i128Bit, _ElementSize, Src1, Src2); }); } -template +template void OpDispatchBuilder::AVX128_VPUNPCKH(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return _VZip2(OpSize::i128Bit, _ElementSize, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return _VZip2(OpSize::i128Bit, _ElementSize, Src1, Src2); }); } void OpDispatchBuilder::AVX128_MOVVectorUnaligned(OpcodeArgs) { @@ -1066,19 +1066,21 @@ void OpDispatchBuilder::AVX128_CVTFPR_To_GPR(OpcodeArgs) { void OpDispatchBuilder::AVX128_VANDN(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), OpSize::i128Bit, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return _VAndn(OpSize::i128Bit, _ElementSize, Src2, Src1); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return _VAndn(OpSize::i128Bit, _ElementSize, Src2, Src1); }); } -template +template void OpDispatchBuilder::AVX128_VPACKSS(OpcodeArgs) { - AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return _VSQXTNPair(OpSize::i128Bit, _ElementSize, Src1, Src2); }); + AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { + return _VSQXTNPair(OpSize::i128Bit, _ElementSize, Src1, Src2); + }); } -template +template void OpDispatchBuilder::AVX128_VPACKUS(OpcodeArgs) { - AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return _VSQXTUNPair(OpSize::i128Bit, _ElementSize, Src1, Src2); }); + AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { + return _VSQXTUNPair(OpSize::i128Bit, _ElementSize, Src1, Src2); + }); } Ref OpDispatchBuilder::AVX128_PSIGNImpl(size_t ElementSize, Ref Src1, Ref Src2) { @@ -1087,10 +1089,10 @@ Ref OpDispatchBuilder::AVX128_PSIGNImpl(size_t ElementSize, Ref Src1, Ref Src2) return _VMul(OpSize::i128Bit, ElementSize, Src1, Control); } -template +template void OpDispatchBuilder::AVX128_VPSIGN(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return AVX128_PSIGNImpl(_ElementSize, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return AVX128_PSIGNImpl(_ElementSize, Src1, Src2); }); } template @@ -1132,7 +1134,7 @@ void OpDispatchBuilder::AVX128_VectorScalarInsertALU(OpcodeArgs, FEXCore::IR::IR AVX128_StoreResult_WithOpSize(Op, Op->Dest, RefPair {.Low = Result_Low, .High = High}); } -template +template void OpDispatchBuilder::AVX128_VFCMP(OpcodeArgs) { const uint8_t CompType = Op->Src[2].Literal(); @@ -1144,7 +1146,7 @@ void OpDispatchBuilder::AVX128_VFCMP(OpcodeArgs) { .CompType = CompType, }; - AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this, &Capture](size_t _ElementSize, Ref Src1, Ref Src2) { + AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this, &Capture](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return VFCMPOpImpl(OpSize::i128Bit, _ElementSize, Src1, Src2, Capture.CompType); }); } @@ -1408,7 +1410,7 @@ void OpDispatchBuilder::AVX128_VPINSRDQ(OpcodeArgs) { } void OpDispatchBuilder::AVX128_VariableShiftImpl(OpcodeArgs, IROps IROp) { - AVX128_VectorBinaryImpl(Op, GetDstSize(Op), GetSrcSize(Op), [this, IROp](size_t ElementSize, Ref Src1, Ref Src2) { + AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSizeFromSrc(Op), [this, IROp](IR::OpSize ElementSize, Ref Src1, Ref Src2) { DeriveOp(Shift, IROp, _VUShr(OpSize::i128Bit, ElementSize, Src1, Src2, true)); return Shift; }); @@ -1473,41 +1475,42 @@ void OpDispatchBuilder::AVX128_VINSERTPS(OpcodeArgs) { AVX128_StoreResult_WithOpSize(Op, Op->Dest, AVX128_Zext(Result)); } -template +template void OpDispatchBuilder::AVX128_VPHSUB(OpcodeArgs) { - AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return PHSUBOpImpl(OpSize::i128Bit, Src1, Src2, _ElementSize); }); + AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { + return PHSUBOpImpl(OpSize::i128Bit, Src1, Src2, _ElementSize); + }); } void OpDispatchBuilder::AVX128_VPHSUBSW(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i16Bit, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return PHSUBSOpImpl(OpSize::i128Bit, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return PHSUBSOpImpl(OpSize::i128Bit, Src1, Src2); }); } -template +template void OpDispatchBuilder::AVX128_VADDSUBP(OpcodeArgs) { - AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, [this](size_t _ElementSize, Ref Src1, Ref Src2) { + AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return ADDSUBPOpImpl(OpSize::i128Bit, _ElementSize, Src1, Src2); }); } -template +template void OpDispatchBuilder::AVX128_VPMULL(OpcodeArgs) { static_assert(ElementSize == sizeof(uint32_t), "Currently only handles 32-bit -> 64-bit"); - AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, [this](size_t _ElementSize, Ref Src1, Ref Src2) -> Ref { + AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) -> Ref { return PMULLOpImpl(OpSize::i128Bit, ElementSize, Signed, Src1, Src2); }); } void OpDispatchBuilder::AVX128_VPMULHRSW(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i16Bit, - [this](size_t _ElementSize, Ref Src1, Ref Src2) -> Ref { return PMULHRSWOpImpl(OpSize::i128Bit, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) -> Ref { return PMULHRSWOpImpl(OpSize::i128Bit, Src1, Src2); }); } template void OpDispatchBuilder::AVX128_VPMULHW(OpcodeArgs) { - AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i16Bit, [this](size_t _ElementSize, Ref Src1, Ref Src2) -> Ref { + AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i16Bit, [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) -> Ref { if (Signed) { return _VSMulH(OpSize::i128Bit, _ElementSize, Src1, Src2); } else { @@ -1822,11 +1825,11 @@ void OpDispatchBuilder::AVX128_InsertScalarRound(OpcodeArgs) { AVX128_StoreResult_WithOpSize(Op, Op->Dest, AVX128_Zext(Result)); } -template +template void OpDispatchBuilder::AVX128_VDPP(OpcodeArgs) { const uint64_t Literal = Op->Src[2].Literal(); - AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this, Literal](size_t, Ref Src1, Ref Src2) { + AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this, Literal](IR::OpSize, Ref Src1, Ref Src2) { return DPPOpImpl(OpSize::i128Bit, Src1, Src2, Literal, ElementSize); }); } @@ -1953,9 +1956,9 @@ void OpDispatchBuilder::AVX128_VPERMILImm(OpcodeArgs) { AVX128_StoreResult_WithOpSize(Op, Op->Dest, Result); } -template +template void OpDispatchBuilder::AVX128_VHADDP(OpcodeArgs) { - AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this](size_t, Ref Src1, Ref Src2) { + AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), ElementSize, [this](IR::OpSize, Ref Src1, Ref Src2) { DeriveOp(Res, IROp, _VFAddP(OpSize::i128Bit, ElementSize, Src1, Src2)); return Res; }); @@ -1963,17 +1966,17 @@ void OpDispatchBuilder::AVX128_VHADDP(OpcodeArgs) { void OpDispatchBuilder::AVX128_VPHADDSW(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i16Bit, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return PHADDSOpImpl(OpSize::i128Bit, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return PHADDSOpImpl(OpSize::i128Bit, Src1, Src2); }); } void OpDispatchBuilder::AVX128_VPMADDUBSW(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), OpSize::i128Bit, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return PMADDUBSWOpImpl(OpSize::i128Bit, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return PMADDUBSWOpImpl(OpSize::i128Bit, Src1, Src2); }); } void OpDispatchBuilder::AVX128_VPMADDWD(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), OpSize::i128Bit, - [this](size_t _ElementSize, Ref Src1, Ref Src2) { return PMADDWDOpImpl(OpSize::i128Bit, Src1, Src2); }); + [this](IR::OpSize _ElementSize, Ref Src1, Ref Src2) { return PMADDWDOpImpl(OpSize::i128Bit, Src1, Src2); }); } template @@ -2003,21 +2006,22 @@ void OpDispatchBuilder::AVX128_VBLEND(OpcodeArgs) { AVX128_StoreResult_WithOpSize(Op, Op->Dest, Result); } -template +template void OpDispatchBuilder::AVX128_VHSUBP(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, - [this](size_t, Ref Src1, Ref Src2) { return HSUBPOpImpl(OpSize::i128Bit, ElementSize, Src1, Src2); }); + [this](IR::OpSize, Ref Src1, Ref Src2) { return HSUBPOpImpl(OpSize::i128Bit, ElementSize, Src1, Src2); }); } void OpDispatchBuilder::AVX128_VPSHUFB(OpcodeArgs) { auto MaskVector = GeneratePSHUFBMask(OpSize::i128Bit); - AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i8Bit, - [this, MaskVector](size_t, Ref Src1, Ref Src2) { return PSHUFBOpImpl(OpSize::i128Bit, Src1, Src2, MaskVector); }); + AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i8Bit, [this, MaskVector](IR::OpSize, Ref Src1, Ref Src2) { + return PSHUFBOpImpl(OpSize::i128Bit, Src1, Src2, MaskVector); + }); } void OpDispatchBuilder::AVX128_VPSADBW(OpcodeArgs) { AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i8Bit, - [this](size_t, Ref Src1, Ref Src2) { return PSADBWOpImpl(OpSize::i128Bit, Src1, Src2); }); + [this](IR::OpSize, Ref Src1, Ref Src2) { return PSADBWOpImpl(OpSize::i128Bit, Src1, Src2); }); } void OpDispatchBuilder::AVX128_VMPSADBW(OpcodeArgs) { @@ -2044,10 +2048,10 @@ void OpDispatchBuilder::AVX128_VMPSADBW(OpcodeArgs) { void OpDispatchBuilder::AVX128_VPALIGNR(OpcodeArgs) { const auto Index = Op->Src[2].Literal(); - const auto Size = GetDstSize(Op); - const auto SanitizedDstSize = std::min(Size, uint8_t {16}); + const auto Size = OpSizeFromDst(Op); + const auto SanitizedDstSize = std::min(Size, OpSize::i128Bit); - AVX128_VectorBinaryImpl(Op, Size, SanitizedDstSize, [this, Index](size_t SanitizedDstSize, Ref Src1, Ref Src2) -> Ref { + AVX128_VectorBinaryImpl(Op, Size, SanitizedDstSize, [this, Index](IR::OpSize SanitizedDstSize, Ref Src1, Ref Src2) -> Ref { if (Index >= (SanitizedDstSize * 2)) { // If the immediate is greater than both vectors combined then it zeroes the vector return LoadZeroVector(OpSize::i128Bit); @@ -2363,7 +2367,7 @@ void OpDispatchBuilder::AVX128_VPERMD(OpcodeArgs) { void OpDispatchBuilder::AVX128_VPCLMULQDQ(OpcodeArgs) { const auto Selector = static_cast(Op->Src[2].Literal()); - AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), 0, [this, Selector](size_t _, Ref Src1, Ref Src2) { + AVX128_VectorBinaryImpl(Op, GetSrcSize(Op), OpSize::iInvalid, [this, Selector](size_t _, Ref Src1, Ref Src2) { return _PCLMUL(OpSize::i128Bit, Src1, Src2, Selector & 0b1'0001); }); } diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/SecondaryTables.h b/FEXCore/Source/Interface/Core/OpcodeDispatcher/SecondaryTables.h index b8c8b00cf..342f4ecda 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/SecondaryTables.h +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/SecondaryTables.h @@ -95,7 +95,7 @@ constexpr std::tuple OpDisp {0x76, 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::VectorALUOp, IR::OP_VCMPEQ, 4>}, {0x77, 1, &OpDispatchBuilder::X87EMMS}, - {0xC2, 1, &OpDispatchBuilder::VFCMPOp<4>}, + {0xC2, 1, &OpDispatchBuilder::VFCMPOp}, {0xC6, 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::SHUFOp, 4>}, {0xD1, 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::PSRLDOp, 2>}, @@ -257,7 +257,7 @@ constexpr std::tuple OpDisp {0x7D, 1, &OpDispatchBuilder::HSUBP<8>}, {0x7E, 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::MOVBetweenGPR_FPR, OpDispatchBuilder::VectorOpType::SSE>}, {0x7F, 1, &OpDispatchBuilder::MOVVectorAlignedOp}, - {0xC2, 1, &OpDispatchBuilder::VFCMPOp<8>}, + {0xC2, 1, &OpDispatchBuilder::VFCMPOp}, {0xC4, 1, &OpDispatchBuilder::PINSROp}, {0xC5, 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::PExtrOp, OpSize::i16Bit>}, {0xC6, 1, &OpDispatchBuilder::Bind<&OpDispatchBuilder::SHUFOp, 8>}, diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp index 0970e5d80..d4d988f68 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp @@ -2404,7 +2404,7 @@ void OpDispatchBuilder::MOVBetweenGPR_FPR(OpcodeArgs, VectorOpType VectorType) { } } -Ref OpDispatchBuilder::VFCMPOpImpl(OpSize Size, size_t ElementSize, Ref Src1, Ref Src2, uint8_t CompType) { +Ref OpDispatchBuilder::VFCMPOpImpl(OpSize Size, IR::OpSize ElementSize, Ref Src1, Ref Src2, uint8_t CompType) { Ref Result {}; switch (CompType & 0x7) { case 0x0: // EQ @@ -2429,7 +2429,7 @@ Ref OpDispatchBuilder::VFCMPOpImpl(OpSize Size, size_t ElementSize, Ref Src1, Re FEX_UNREACHABLE; } -template +template void OpDispatchBuilder::VFCMPOp(OpcodeArgs) { // No need for zero-extending in the scalar case, since // all we need is an insert at the end of the operation. @@ -2448,7 +2448,7 @@ void OpDispatchBuilder::VFCMPOp(OpcodeArgs) { template void OpDispatchBuilder::VFCMPOp(OpcodeArgs); template void OpDispatchBuilder::VFCMPOp(OpcodeArgs); -template +template void OpDispatchBuilder::AVXVFCMPOp(OpcodeArgs) { // No need for zero-extending in the scalar case, since // all we need is an insert at the end of the operation. diff --git a/FEXCore/Source/Interface/IR/IR.json b/FEXCore/Source/Interface/IR/IR.json index bcfc9ac5c..de99c4dfb 100644 --- a/FEXCore/Source/Interface/IR/IR.json +++ b/FEXCore/Source/Interface/IR/IR.json @@ -1903,7 +1903,7 @@ "DestSize": "RegisterSize", "NumElements": "RegisterSize / ElementSize" }, - "FPR = VNot u8:#RegisterSize, u8:#ElementSize, FPR:$Vector": { + "FPR = VNot OpSize:#RegisterSize, OpSize:#ElementSize, FPR:$Vector": { "DestSize": "RegisterSize", "NumElements": "RegisterSize / ElementSize" },