Remove global state from PPCAnalyst.cpp. Little bit of cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1580 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-12-18 10:44:03 +00:00
parent feb8dc7e6b
commit 50d72c1e59
9 changed files with 170 additions and 329 deletions
-2
View File
@@ -45,7 +45,6 @@ namespace HW
void Init()
{
CoreTiming::Init();
PPCAnalyst::Init();
Thunk_Init(); // not really hw, but this way we know it's inited early :P
State_Init();
@@ -91,7 +90,6 @@ namespace HW
State_Shutdown();
Thunk_Shutdown();
CoreTiming::Shutdown();
PPCAnalyst::Shutdown();
}
void DoState(PointerWrap &p)
+5 -1
View File
@@ -172,6 +172,7 @@ namespace Jit64
{
JitState js;
JitOptions jo;
PPCAnalyst::CodeBuffer code_buffer(32000);
void Init()
{
@@ -319,7 +320,10 @@ namespace Jit64
//Analyze the block, collect all instructions it is made of (including inlining,
//if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
PPCAnalyst::CodeOp *ops = PPCAnalyst::Flatten(emaddress, size, js.st, js.gpa, js.fpa);
PPCAnalyst::Flatten(emaddress, &size, &js.st, &js.gpa, &js.fpa, &code_buffer);
PPCAnalyst::CodeOp *ops = code_buffer.codebuffer;
const u8 *start = AlignCode4(); //TODO: Test if this or AlignCode16 make a difference from GetCodePtr
b.checkedEntry = start;
b.runCount = 0;
@@ -21,6 +21,7 @@
// dependency is a little inconvenient and this is possibly a slight
// performance hit, it's not enabled by default, but it's useful for
// locating performance issues.
//#define OPROFILE_REPORT
#include <map>
@@ -71,10 +72,10 @@ namespace Jit64
TRAMPOLINE_SIZE = 1024*1024,
//MAX_NUM_BLOCKS = 65536,
};
int CODE_SIZE = 1024*1024*16; // nonconstant to be able to have an option for it
int CODE_SIZE = 1024*1024*16;
int MAX_NUM_BLOCKS = 65536*2;
static u8 **blockCodePointers; // cut these in half and force below 2GB?
static u8 **blockCodePointers;
static std::multimap<u32, int> links_to;
@@ -133,8 +134,8 @@ namespace Jit64
#endif
}
/* This clears the JIT cache. It's called from JitCache.cpp when the JIT cache
is full and when saving and loading states */
// This clears the JIT cache. It's called from JitCache.cpp when the JIT cache
// is full and when saving and loading states.
void ClearCache()
{
Core::DisplayMessage("Cleared code cache.", 3000);
@@ -348,13 +349,6 @@ namespace Jit64
}
}
/*
if ((b.exitAddress[0] == INVALID_EXIT || b.linkStatus[0]) &&
(b.exitAddress[1] == INVALID_EXIT || b.linkStatus[1])) {
unlinked.erase(iter);
if (unlinked.size() > 4000) PanicAlert("Removed from unlinked. Size = %i", unlinked.size());
}
*/
using namespace std;
void LinkBlock(int i)
{
@@ -408,7 +402,6 @@ namespace Jit64
SetCodePtr(prev_code); // reset code pointer
}
#define BLR_OP 0x4e800020
void InvalidateCodeRange(u32 address, u32 length)
{
@@ -418,7 +411,7 @@ namespace Jit64
//This is slow but should be safe (zelda needs it for block linking)
for (int i = 0; i < numBlocks; i++)
{
if (RangeIntersect(blocks[i].originalAddress, blocks[i].originalAddress+blocks[i].originalSize,
if (RangeIntersect(blocks[i].originalAddress, blocks[i].originalAddress + blocks[i].originalSize,
address, address + length))
{
DestroyBlock(i, true);
@@ -278,6 +278,10 @@ void stfs(UGeckoInstruction inst)
void stfsx(UGeckoInstruction inst)
{
#ifdef JIT_OFF_OPTIONS
if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreFloatingOff)
{Default(inst); return;} // turn off from debugger
#endif
// We can take a shortcut here - it's not likely that a hardware access would use this instruction.
INSTRUCTION_START;
#ifdef _M_X64
@@ -182,7 +182,7 @@ void psq_st(UGeckoInstruction inst)
{
if (gpr.R(a).IsImm() && !update && cpu_info.bSSSE3)
{
u32 addr = gpr.R(a).offset + offset;
u32 addr = (u32)(gpr.R(a).offset + offset);
if (addr == 0xCC008000) {
// Writing to FIFO. Let's do fast method.
CVTPD2PS(XMM0, fpr.R(s));
File diff suppressed because it is too large Load Diff
+11 -4
View File
@@ -76,13 +76,20 @@ struct BlockRegStats
min(firstRead[reg], firstWrite[reg]);}
};
void Init();
void Shutdown();
CodeOp *Flatten(u32 address, int &realsize, BlockStats &st, BlockRegStats &gpa, BlockRegStats &fpa);
class CodeBuffer
{
public:
CodeBuffer(int size);
~CodeBuffer();
PPCAnalyst::CodeOp *codebuffer;
int size_;
};
void Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa, BlockRegStats *fpa, CodeBuffer *buffer);
void LogFunctionCall(u32 addr);
void FindFunctions(u32 startAddr, u32 endAddr, SymbolDB *func_db);
bool AnalyzeFunction(u32 startAddr, Symbol &func, int max_size = 0);
+29 -26
View File
@@ -122,8 +122,7 @@ Interpreter::_interpreterInstruction GetInterpreterOp(UGeckoInstruction _inst)
}
}
GekkoOPTemplate primarytable[] =
static GekkoOPTemplate primarytable[] =
{
{4, Interpreter::RunTable4, DynaRunTable4, {"RunTable4", OPTYPE_SUBTABLE | (4<<24), 0}},
{19, Interpreter::RunTable19, DynaRunTable19, {"RunTable19", OPTYPE_SUBTABLE | (19<<24), 0}},
@@ -204,7 +203,7 @@ GekkoOPTemplate primarytable[] =
{58, Interpreter::unknown_instruction, Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}},
};
GekkoOPTemplate table4[] =
static GekkoOPTemplate table4[] =
{ //SUBOP10
{0, Interpreter::ps_cmpu0, Jit64::Default, {"ps_cmpu0", OPTYPE_PS, FL_SET_CRn}},
{32, Interpreter::ps_cmpo0, Jit64::Default, {"ps_cmpo0", OPTYPE_PS, FL_SET_CRn}},
@@ -222,7 +221,7 @@ GekkoOPTemplate table4[] =
{1014, Interpreter::dcbz_l, Jit64::Default, {"dcbz_l", OPTYPE_SYSTEM, 0}},
};
GekkoOPTemplate table4_2[] =
static GekkoOPTemplate table4_2[] =
{
{10, Interpreter::ps_sum0, Jit64::ps_sum, {"ps_sum0", OPTYPE_PS, 0}},
{11, Interpreter::ps_sum1, Jit64::ps_sum, {"ps_sum1", OPTYPE_PS, 0}},
@@ -244,7 +243,7 @@ GekkoOPTemplate table4_2[] =
};
GekkoOPTemplate table4_3[] =
static GekkoOPTemplate table4_3[] =
{
{6, Interpreter::psq_lx, Jit64::Default, {"psq_lx", OPTYPE_PS, 0}},
{7, Interpreter::psq_stx, Jit64::Default, {"psq_stx", OPTYPE_PS, 0}},
@@ -252,7 +251,7 @@ GekkoOPTemplate table4_3[] =
{39, Interpreter::psq_stux, Jit64::Default, {"psq_stux", OPTYPE_PS, 0}},
};
GekkoOPTemplate table19[] =
static GekkoOPTemplate table19[] =
{
{528, Interpreter::bcctrx, Jit64::bcctrx, {"bcctrx", OPTYPE_BRANCH, FL_ENDBLOCK}},
{16, Interpreter::bclrx, Jit64::bclrx, {"bclrx", OPTYPE_BRANCH, FL_ENDBLOCK}},
@@ -273,7 +272,7 @@ GekkoOPTemplate table19[] =
};
GekkoOPTemplate table31[] =
static GekkoOPTemplate table31[] =
{
{28, Interpreter::andx, Jit64::andx, {"andx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}},
{60, Interpreter::andcx, Jit64::Default, {"andcx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}},
@@ -386,7 +385,7 @@ GekkoOPTemplate table31[] =
{566, Interpreter::tlbsync, Jit64::Default, {"tlbsync", OPTYPE_SYSTEM, 0}},
};
GekkoOPTemplate table31_2[] =
static GekkoOPTemplate table31_2[] =
{
{266, Interpreter::addx, Jit64::addx, {"addx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}},
{10, Interpreter::addcx, Jit64::Default, {"addcx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_SET_CA | FL_RC_BIT}},
@@ -406,7 +405,7 @@ GekkoOPTemplate table31_2[] =
{200, Interpreter::subfzex, Jit64::Default, {"subfzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}},
};
GekkoOPTemplate table59[] =
static GekkoOPTemplate table59[] =
{
{18, Interpreter::fdivsx, Jit64::fp_arith_s, {"fdivsx", OPTYPE_FPU, FL_RC_BIT_F, 16}},
{20, Interpreter::fsubsx, Jit64::fp_arith_s, {"fsubsx", OPTYPE_FPU, FL_RC_BIT_F}},
@@ -420,7 +419,7 @@ GekkoOPTemplate table59[] =
{31, Interpreter::fnmaddsx, Jit64::fmaddXX, {"fnmaddsx", OPTYPE_FPU, FL_RC_BIT_F}},
};
GekkoOPTemplate table63[] =
static GekkoOPTemplate table63[] =
{
{264, Interpreter::fabsx, Jit64::Default, {"fabsx", OPTYPE_FPU, FL_RC_BIT_F}},
{32, Interpreter::fcmpo, Jit64::fcmpx, {"fcmpo", OPTYPE_FPU, FL_RC_BIT_F}},
@@ -440,7 +439,7 @@ GekkoOPTemplate table63[] =
{711, Interpreter::mtfsfx, Jit64::Default, {"mtfsfx", OPTYPE_SYSTEMFP, 0, 2}},
};
GekkoOPTemplate table63_2[] =
static GekkoOPTemplate table63_2[] =
{
{18, Interpreter::fdivx, Jit64::Default, {"fdivx", OPTYPE_FPU, FL_RC_BIT_F, 30}},
{20, Interpreter::fsubx, Jit64::Default, {"fsubx", OPTYPE_FPU, FL_RC_BIT_F}},
@@ -455,7 +454,10 @@ GekkoOPTemplate table63_2[] =
{31, Interpreter::fnmaddx, Jit64::fmaddXX, {"fnmaddx", OPTYPE_FPU, FL_RC_BIT_F}},
};
bool PPCTables::UsesFPU(UGeckoInstruction _inst)
namespace PPCTables
{
bool UsesFPU(UGeckoInstruction _inst)
{
switch (_inst.OPCD)
{
@@ -500,7 +502,7 @@ bool PPCTables::UsesFPU(UGeckoInstruction _inst)
}
}
void PPCTables::InitTables()
void InitTables()
{
//clear
for (int i = 0; i < 32; i++)
@@ -671,31 +673,30 @@ void PPCTables::CompileInstruction(UGeckoInstruction _inst)
}
}
bool PPCTables::IsValidInstruction(UGeckoInstruction _instCode)
bool IsValidInstruction(UGeckoInstruction _instCode)
{
const GekkoOPInfo *info = GetOpInfo(_instCode);
return info != 0;
}
void PPCTables::CountInstruction(UGeckoInstruction _inst)
void CountInstruction(UGeckoInstruction _inst)
{
GekkoOPInfo *info = GetOpInfo(_inst);
if (info)
info->runCount++;
}
struct inf
void PrintInstructionRunCounts()
{
const char *name;
int count;
bool operator < (const inf &o) const
struct inf
{
return count > o.count;
}
};
void PPCTables::PrintInstructionRunCounts()
{
const char *name;
int count;
bool operator < (const inf &o) const
{
return count > o.count;
}
};
std::vector<inf> temp;
for (int i = 0; i < m_numInstructions; i++)
{
@@ -712,7 +713,7 @@ void PPCTables::PrintInstructionRunCounts()
}
//TODO move to LogManager
void PPCTables::LogCompiledInstructions()
void LogCompiledInstructions()
{
static int time = 0;
FILE *f = fopen(StringFromFormat(FULL_LOGS_DIR "inst_log%i.txt", time).c_str(), "w");
@@ -740,3 +741,5 @@ void PPCTables::LogCompiledInstructions()
#endif
time++;
}
} // namespace
+24 -12
View File
@@ -71,6 +71,18 @@ enum
OPTYPE_UNKNOWN ,
};
enum {
OPCD_HLEFUNCTION = 1,
OPCD_COMPILEDBLOCK = 2,
OPCD_BCx = 16,
OPCD_SC = 17,
OPCD_Bx = 18,
};
enum {
OP_BLR = 0x4e800020,
};
struct GekkoOPInfo
{
const char *opname;
@@ -85,21 +97,21 @@ struct GekkoOPInfo
GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst);
Interpreter::_interpreterInstruction GetInterpreterOp(UGeckoInstruction _inst);
class PPCTables
namespace PPCTables
{
public:
typedef void (*_recompilerInstruction) (UGeckoInstruction instCode);
typedef void (*_interpreterInstruction)(UGeckoInstruction instCode);
static void InitTables();
static bool IsValidInstruction(UGeckoInstruction _instCode);
static bool UsesFPU(UGeckoInstruction _inst);
typedef void (*_recompilerInstruction) (UGeckoInstruction instCode);
typedef void (*_interpreterInstruction)(UGeckoInstruction instCode);
static void CountInstruction(UGeckoInstruction _inst);
static void PrintInstructionRunCounts();
static void LogCompiledInstructions();
void InitTables();
bool IsValidInstruction(UGeckoInstruction _instCode);
bool UsesFPU(UGeckoInstruction _inst);
static void CompileInstruction(UGeckoInstruction _inst);
};
void CountInstruction(UGeckoInstruction _inst);
void PrintInstructionRunCounts();
void LogCompiledInstructions();
void CompileInstruction(UGeckoInstruction _inst);
} // namespace
#endif