ConstantPool: Return a pointer instead of an OpArg
This allows for greater flexibility.
This commit is contained in:
parent
4e90c5da8b
commit
433999d60f
|
@ -7,7 +7,6 @@
|
|||
#include <utility>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/x64Emitter.h"
|
||||
#include "Core/PowerPC/Jit64Common/ConstantPool.h"
|
||||
|
||||
ConstantPool::ConstantPool() = default;
|
||||
|
@ -37,8 +36,8 @@ void ConstantPool::Shutdown()
|
|||
m_const_info.clear();
|
||||
}
|
||||
|
||||
Gen::OpArg ConstantPool::GetConstantOpArg(const void* value, size_t element_size,
|
||||
size_t num_elements, size_t index)
|
||||
const void* ConstantPool::GetConstant(const void* value, size_t element_size, size_t num_elements,
|
||||
size_t index)
|
||||
{
|
||||
const size_t value_size = element_size * num_elements;
|
||||
auto iter = m_const_info.find(value);
|
||||
|
@ -59,5 +58,5 @@ Gen::OpArg ConstantPool::GetConstantOpArg(const void* value, size_t element_size
|
|||
_assert_msg_(DYNA_REC, info.m_size == value_size,
|
||||
"Constant has incorrect size in constant pool.");
|
||||
u8* location = static_cast<u8*>(info.m_location);
|
||||
return Gen::M(location + element_size * index);
|
||||
return location + element_size * index;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,6 @@
|
|||
#include <cstddef>
|
||||
#include <map>
|
||||
|
||||
namespace Gen
|
||||
{
|
||||
struct OpArg;
|
||||
class X64CodeBlock;
|
||||
}
|
||||
|
||||
// Constants are copied into this pool so that they live at a memory location
|
||||
// that is close to the code that references it. This ensures that the 32-bit
|
||||
// limitation on RIP addressing is not an issue.
|
||||
|
@ -32,8 +26,8 @@ public:
|
|||
// Copies the value into the pool if it doesn't exist. Returns a pointer
|
||||
// to existing values if they were already copied. Pointer equality is
|
||||
// used to determine if two constants are the same.
|
||||
Gen::OpArg GetConstantOpArg(const void* value, size_t element_size, size_t num_elements,
|
||||
size_t index);
|
||||
const void* GetConstant(const void* value, size_t element_size, size_t num_elements,
|
||||
size_t index);
|
||||
|
||||
private:
|
||||
struct ConstantInfo
|
||||
|
|
|
@ -29,16 +29,22 @@ public:
|
|||
void SwitchToFarCode();
|
||||
void SwitchToNearCode();
|
||||
|
||||
template <typename T>
|
||||
const void* GetConstantFromPool(const T& value)
|
||||
{
|
||||
return m_const_pool.GetConstant(&value, sizeof(T), 1, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Gen::OpArg MConst(const T& value)
|
||||
{
|
||||
return m_const_pool.GetConstantOpArg(&value, sizeof(T), 1, 0);
|
||||
return Gen::M(GetConstantFromPool(value));
|
||||
}
|
||||
|
||||
template <typename T, size_t N>
|
||||
Gen::OpArg MConst(const T (&value)[N], size_t index = 0)
|
||||
{
|
||||
return m_const_pool.GetConstantOpArg(&value, sizeof(T), N, index);
|
||||
return Gen::M(m_const_pool.GetConstant(&value, sizeof(T), N, index));
|
||||
}
|
||||
|
||||
Gen::FixupBranch CheckIfSafeAddress(const Gen::OpArg& reg_value, Gen::X64Reg reg_addr,
|
||||
|
|
Loading…
Reference in New Issue