Merge pull request #14273 from JosJuice/x64-oparg-padding

Jit64: Make OpArg and TrampolineInfo smaller
This commit is contained in:
Jordan Woyak authored and GitHub committed 2026-01-11 16:14:50 -06:00
commit dc8f2995ef
3 files changed
+21 -21

No files matched your search

+4 -4
View File
@@ -113,8 +113,8 @@ struct OpArg
// dummy op arg, used for storage // dummy op arg, used for storage
constexpr OpArg() = default; constexpr OpArg() = default;
constexpr OpArg(u64 offset_, int scale_, X64Reg rm_reg = RAX, X64Reg scaled_reg = RAX) constexpr OpArg(u64 offset_, int scale_, X64Reg rm_reg = RAX, X64Reg scaled_reg = RAX)
: scale{static_cast<u8>(scale_)}, offsetOrBaseReg{static_cast<u16>(rm_reg)}, : offset{offset_}, offsetOrBaseReg{static_cast<u16>(rm_reg)},
indexReg{static_cast<u16>(scaled_reg)}, offset{offset_} indexReg{static_cast<u16>(scaled_reg)}, scale{static_cast<u8>(scale_)}
{ {
} }
constexpr bool operator==(const OpArg& b) const constexpr bool operator==(const OpArg& b) const
@@ -234,11 +234,11 @@ private:
void WriteSingleByteOp(XEmitter* emit, u8 op, X64Reg operandReg, int bits); void WriteSingleByteOp(XEmitter* emit, u8 op, X64Reg operandReg, int bits);
void WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& operand, int bits) const; void WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& operand, int bits) const;
u8 scale = 0; u64 offset = 0; // Also used to store immediates.
u16 offsetOrBaseReg = 0; u16 offsetOrBaseReg = 0;
u16 indexReg = 0; u16 indexReg = 0;
u64 offset = 0; // Also used to store immediates.
u16 operandReg = 0; u16 operandReg = 0;
u8 scale = 0;
}; };
template <typename T> template <typename T>
@@ -355,7 +355,7 @@ void EmuCodeBlock::SafeLoadToReg(X64Reg reg_value, const Gen::OpArg& opAddress,
{ {
NOP(padding); NOP(padding);
} }
info.len = static_cast<u32>(GetCodePtr() - info.start); info.len = static_cast<u16>(GetCodePtr() - info.start);
js.fastmemLoadStore = mov.address; js.fastmemLoadStore = mov.address;
return; return;
@@ -527,7 +527,7 @@ void EmuCodeBlock::SafeWriteRegToReg(OpArg reg_value, X64Reg reg_addr, int acces
{ {
NOP(padding); NOP(padding);
} }
info.len = static_cast<u32>(GetCodePtr() - info.start); info.len = static_cast<u16>(GetCodePtr() - info.start);
js.fastmemLoadStore = mov.address; js.fastmemLoadStore = mov.address;
@@ -16,21 +16,7 @@ struct TrampolineInfo final
u8* start = nullptr; u8* start = nullptr;
// The start + len = end of the store operation (points to the next instruction) // The start + len = end of the store operation (points to the next instruction)
u32 len = 0; u16 len = 0;
// The PPC PC for the current load/store block
u32 pc = 0;
// Saved because we need these to make the ABI call in the trampoline
BitSet32 registersInUse{};
// The MOV operation
Gen::X64Reg nonAtomicSwapStoreSrc{};
// src/dest for load/store
s32 offset = 0;
Gen::X64Reg op_reg{};
Gen::OpArg op_arg{};
// Original SafeLoadXXX/SafeStoreXXX flags // Original SafeLoadXXX/SafeStoreXXX flags
u8 flags = 0; u8 flags = 0;
@@ -46,4 +32,18 @@ struct TrampolineInfo final
// Set to true if we added the offset to the address and need to undo it // Set to true if we added the offset to the address and need to undo it
bool offsetAddedToAddress : 1 = false; bool offsetAddedToAddress : 1 = false;
// The PPC PC for the current load/store block
u32 pc = 0;
// Saved because we need these to make the ABI call in the trampoline
BitSet32 registersInUse{};
// The MOV operation
Gen::X64Reg nonAtomicSwapStoreSrc{};
// src/dest for load/store
s32 offset = 0;
Gen::X64Reg op_reg{};
Gen::OpArg op_arg{};
}; };