summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorMerryMage <MerryMage@users.noreply.github.com>2017-04-11 17:00:34 +0100
committerMerryMage <MerryMage@users.noreply.github.com>2017-04-11 20:25:18 +0100
commit433999d60ff2af2aa74fe7cd3b4f5ca699637c36 (patch)
tree5d27817af01424d1ef68da83449ecaa212df7271 /Source/Core
parent4e90c5da8b3c4de34aea8a2521e7612d64f6c7c6 (diff)
ConstantPool: Return a pointer instead of an OpArg
This allows for greater flexibility.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/Jit64Common/ConstantPool.cpp7
-rw-r--r--Source/Core/Core/PowerPC/Jit64Common/ConstantPool.h10
-rw-r--r--Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.h10
3 files changed, 13 insertions, 14 deletions
diff --git a/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.cpp b/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.cpp
index cd8da238a0..24db1f12c4 100644
--- a/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.cpp
+++ b/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.cpp
@@ -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;
}
diff --git a/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.h b/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.h
index 732a41af9d..51e6e84d7d 100644
--- a/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.h
+++ b/Source/Core/Core/PowerPC/Jit64Common/ConstantPool.h
@@ -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
diff --git a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.h b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.h
index 244494a31e..20e44d0bc0 100644
--- a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.h
+++ b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.h
@@ -30,15 +30,21 @@ public:
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,