Merge pull request #4953 from lioncash/fwd

CachedInterpreter: Forward declare instruction struct
This commit is contained in:
Markus Wick 2017-02-24 23:36:11 +01:00 committed by GitHub
commit 51136681df
2 changed files with 46 additions and 27 deletions

View File

@ -14,6 +14,42 @@
#include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCAnalyst.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
struct CachedInterpreter::Instruction
{
typedef void (*CommonCallback)(UGeckoInstruction);
typedef bool (*ConditionalCallback)(u32 data);
Instruction() : type(INSTRUCTION_ABORT) {}
Instruction(const CommonCallback c, UGeckoInstruction i)
: common_callback(c), data(i.hex), type(INSTRUCTION_TYPE_COMMON)
{
}
Instruction(const ConditionalCallback c, u32 d)
: conditional_callback(c), data(d), type(INSTRUCTION_TYPE_CONDITIONAL)
{
}
union
{
const CommonCallback common_callback;
const ConditionalCallback conditional_callback;
};
u32 data;
enum
{
INSTRUCTION_ABORT,
INSTRUCTION_TYPE_COMMON,
INSTRUCTION_TYPE_CONDITIONAL,
} type;
};
CachedInterpreter::CachedInterpreter() : code_buffer(32000)
{
}
CachedInterpreter::~CachedInterpreter() = default;
void CachedInterpreter::Init() void CachedInterpreter::Init()
{ {
m_code.reserve(CODE_SIZE / sizeof(Instruction)); m_code.reserve(CODE_SIZE / sizeof(Instruction));
@ -33,6 +69,11 @@ void CachedInterpreter::Shutdown()
m_block_cache.Shutdown(); m_block_cache.Shutdown();
} }
const u8* CachedInterpreter::GetCodePtr() const
{
return reinterpret_cast<const u8*>(m_code.data() + m_code.size());
}
void CachedInterpreter::ExecuteOneBlock() void CachedInterpreter::ExecuteOneBlock()
{ {
const u8* normal_entry = m_block_cache.Dispatch(); const u8* normal_entry = m_block_cache.Dispatch();

View File

@ -14,8 +14,9 @@
class CachedInterpreter : public JitBase class CachedInterpreter : public JitBase
{ {
public: public:
CachedInterpreter() : code_buffer(32000) {} CachedInterpreter();
~CachedInterpreter() {} ~CachedInterpreter();
void Init() override; void Init() override;
void Shutdown() override; void Shutdown() override;
@ -31,32 +32,9 @@ public:
const char* GetName() override { return "Cached Interpreter"; } const char* GetName() override { return "Cached Interpreter"; }
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; } const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }
private: private:
struct Instruction struct Instruction;
{
typedef void (*CommonCallback)(UGeckoInstruction);
typedef bool (*ConditionalCallback)(u32 data);
Instruction() : type(INSTRUCTION_ABORT){}; const u8* GetCodePtr() const;
Instruction(const CommonCallback c, UGeckoInstruction i)
: common_callback(c), data(i.hex), type(INSTRUCTION_TYPE_COMMON){};
Instruction(const ConditionalCallback c, u32 d)
: conditional_callback(c), data(d), type(INSTRUCTION_TYPE_CONDITIONAL){};
union
{
const CommonCallback common_callback;
const ConditionalCallback conditional_callback;
};
u32 data;
enum
{
INSTRUCTION_ABORT,
INSTRUCTION_TYPE_COMMON,
INSTRUCTION_TYPE_CONDITIONAL,
} type;
};
const u8* GetCodePtr() { return (u8*)(m_code.data() + m_code.size()); }
void ExecuteOneBlock(); void ExecuteOneBlock();
BlockCache m_block_cache{*this}; BlockCache m_block_cache{*this};