From f1d020ce9533356b6faa703324c75705e1c2aa0c Mon Sep 17 00:00:00 2001 From: Lioncache Date: Mon, 21 Aug 2023 14:34:47 -0400 Subject: [PATCH] Interpreter: Tie SSA data elements to supported vector width Now, if we ever increase our vector sizes, the allocated data elements will follow suit without needing to remember to handle this as well. --- .../Interface/Core/Interpreter/InterpreterOps.cpp | 6 ++++-- .../Interface/Core/Interpreter/InterpreterOps.h | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.cpp b/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.cpp index 1363d4087..449b7f605 100644 --- a/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.cpp +++ b/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.cpp @@ -346,8 +346,10 @@ void InterpreterOps::InterpretIR(FEXCore::Core::CpuStateFrame *Frame, FEXCore::I auto BlockEnd = CurrentIR->GetBlocks().end(); - constexpr size_t ListEntrySizeInBytes = sizeof(InterpVector256); - const size_t SSADataSize = ListSize * ListEntrySizeInBytes; + // SSA data elements must be able to accommodate data that would + // fit inside the largest vector size (otherwise vector operations + // go kaboom, and we don't want that). + const size_t SSADataSize = ListSize * MaxInterpeterVectorSize; InterpreterOps::IROpData OpData{ .State = Frame->Thread, diff --git a/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.h b/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.h index 4a8943f78..00dc6f73e 100644 --- a/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.h +++ b/FEXCore/Source/Interface/Core/Interpreter/InterpreterOps.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -433,13 +434,14 @@ namespace FEXCore::CPU { return IROp->Size; } + // The maximum size a vector can be within FEX's interpreter. + // NOTE: If we ever support AVX-512, this should be changed + // to 64 bytes in size. + static constexpr size_t MaxInterpeterVectorSize = Core::CPUState::XMM_AVX_REG_SIZE; + // Alias for specifying temporary data that is operated on // before storing into a destination. - // - // NOTE: This should be the maximum size a vector can be within - // FEX. e.g. If we ever support AVX-512, this should be changed - // to be 64 bytes in size. - using TempVectorDataArray = std::array; + using TempVectorDataArray = std::array; }; } // namespace FEXCore::CPU