From 5fd127b53ad4ba024c40587cdda77cd88c8d03b0 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 27 Oct 2024 15:51:30 -0700 Subject: [PATCH] IR: Change StoreContextIndexed to use IR::OpSize --- FEXCore/Source/Interface/Core/OpcodeDispatcher/X87.cpp | 2 +- FEXCore/Source/Interface/IR/IR.json | 2 +- .../Source/Interface/IR/Passes/x87StackOptimizationPass.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/X87.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/X87.cpp index 0692ae89a..343d7a75a 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/X87.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/X87.cpp @@ -536,7 +536,7 @@ void OpDispatchBuilder::X87FRSTOR(OpcodeArgs) { auto high = _Constant(0xFFFF); Ref Mask = _VCastFromGPR(OpSize::i128Bit, OpSize::i64Bit, low); Mask = _VInsGPR(OpSize::i128Bit, OpSize::i64Bit, 1, Mask, high); - size_t StoreSize = ReducedPrecisionMode ? OpSize::i64Bit : OpSize::i128Bit; + const auto StoreSize = ReducedPrecisionMode ? OpSize::i64Bit : OpSize::i128Bit; for (int i = 0; i < 7; ++i) { Ref Reg = _LoadMem(FPRClass, OpSize::i128Bit, Mem, _Constant((Size * 7) + (10 * i)), OpSize::i8Bit, MEM_OFFSET_SXTX, 1); // Mask off the top bits diff --git a/FEXCore/Source/Interface/IR/IR.json b/FEXCore/Source/Interface/IR/IR.json index 6b345bf98..bd0d928c2 100644 --- a/FEXCore/Source/Interface/IR/IR.json +++ b/FEXCore/Source/Interface/IR/IR.json @@ -473,7 +473,7 @@ "!($BaseOffset >= offsetof(Core::CPUState, xmm.avx.data[0]) && $BaseOffset < offsetof(Core::CPUState, xmm.avx.data[16])) && \"Can't LoadContextIndexed to XMM\"" ] }, - "StoreContextIndexed SSA:$Value, GPR:$Index, u8:#ByteSize, u32:$BaseOffset, u32:$Stride, RegisterClass:$Class": { + "StoreContextIndexed SSA:$Value, GPR:$Index, OpSize:#ByteSize, u32:$BaseOffset, u32:$Stride, RegisterClass:$Class": { "HasSideEffects": true, "Desc": ["Stores a value to the context with offset and indexed by SSA value", "Ctx[BaseOffset + Index * Stride] = Value" diff --git a/FEXCore/Source/Interface/IR/Passes/x87StackOptimizationPass.cpp b/FEXCore/Source/Interface/IR/Passes/x87StackOptimizationPass.cpp index 78d8aab18..e6eaf4e72 100644 --- a/FEXCore/Source/Interface/IR/Passes/x87StackOptimizationPass.cpp +++ b/FEXCore/Source/Interface/IR/Passes/x87StackOptimizationPass.cpp @@ -331,7 +331,7 @@ inline Ref X87StackOptimization::LoadStackValueAtOffset_Slow(uint8_t Offset) { inline void X87StackOptimization::StoreStackValueAtOffset_Slow(Ref Value, uint8_t Offset, bool SetValid) { OrderedNode* TopOffset = GetOffsetTopWithCache_Slow(Offset); // store - IREmit->_StoreContextIndexed(Value, TopOffset, ReducedPrecisionMode ? 8 : 16, MMBaseOffset(), 16, FPRClass); + IREmit->_StoreContextIndexed(Value, TopOffset, ReducedPrecisionMode ? OpSize::i64Bit : OpSize::i128Bit, MMBaseOffset(), 16, FPRClass); // mark it valid // In some cases we might already know it has been previously set as valid so we don't need to do it again if (SetValid) { @@ -477,7 +477,8 @@ Ref X87StackOptimization::SynchronizeStackValues() { } Ref TopIndex = GetOffsetTopWithCache_Slow(i); if (Valid == StackSlot::VALID) { - IREmit->_StoreContextIndexed(StackMember.StackDataNode, TopIndex, ReducedPrecisionMode ? 8 : 16, MMBaseOffset(), 16, FPRClass); + IREmit->_StoreContextIndexed(StackMember.StackDataNode, TopIndex, ReducedPrecisionMode ? OpSize::i64Bit : OpSize::i128Bit, + MMBaseOffset(), 16, FPRClass); } } { // Set valid tags