mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-25 15:23:35 +01:00
Pass in some analysis results, don't use yet.
This commit is contained in:
1 parent
109ad17ac6
commit
52d6080fb4
4 files changed
+30
-28
No files matched your search
+17
-17
@@ -28,12 +28,8 @@
|
||||
using namespace MIPSCodeUtils;
|
||||
using namespace std;
|
||||
|
||||
#define NUM_MIPS_GPRS 32
|
||||
|
||||
namespace MIPSAnalyst
|
||||
{
|
||||
RegisterAnalysisResults gprAnal[NUM_MIPS_GPRS];
|
||||
|
||||
// Only can ever output a single reg.
|
||||
int GetOutGPReg(MIPSOpcode op) {
|
||||
MIPSInfo opinfo = MIPSGetInfo(op);
|
||||
@@ -90,16 +86,18 @@ namespace MIPSAnalyst
|
||||
return (op >> 26) == 0 && (op & 0x3f) == 12;
|
||||
}
|
||||
|
||||
void Analyze(u32 address) {
|
||||
AnalysisResults Analyze(u32 address) {
|
||||
const int MAX_ANALYZE = 10000;
|
||||
|
||||
AnalysisResults results;
|
||||
|
||||
//set everything to -1 (FF)
|
||||
memset(gprAnal, 255, sizeof(AnalysisResults) * NUM_MIPS_GPRS);
|
||||
for (int i = 0; i < NUM_MIPS_GPRS; i++) {
|
||||
gprAnal[i].used = false;
|
||||
gprAnal[i].readCount = 0;
|
||||
gprAnal[i].writeCount = 0;
|
||||
gprAnal[i].readAsAddrCount = 0;
|
||||
memset(&results, 255, sizeof(AnalysisResults));
|
||||
for (int i = 0; i < MIPS_NUM_GPRS; i++) {
|
||||
results.r[i].used = false;
|
||||
results.r[i].readCount = 0;
|
||||
results.r[i].writeCount = 0;
|
||||
results.r[i].readAsAddrCount = 0;
|
||||
}
|
||||
|
||||
for (u32 addr = address, endAddr = address + MAX_ANALYZE; addr <= endAddr; addr += 4) {
|
||||
@@ -111,19 +109,19 @@ namespace MIPSAnalyst
|
||||
|
||||
if (info & IN_RS) {
|
||||
if ((info & IN_RS_ADDR) == IN_RS_ADDR) {
|
||||
gprAnal[rs].MarkReadAsAddr(addr);
|
||||
results.r[rs].MarkReadAsAddr(addr);
|
||||
} else {
|
||||
gprAnal[rs].MarkRead(addr);
|
||||
results.r[rs].MarkRead(addr);
|
||||
}
|
||||
}
|
||||
|
||||
if (info & IN_RT) {
|
||||
gprAnal[rt].MarkRead(addr);
|
||||
results.r[rt].MarkRead(addr);
|
||||
}
|
||||
|
||||
int outReg = GetOutGPReg(op);
|
||||
if (outReg != -1) {
|
||||
gprAnal[outReg].MarkWrite(addr);
|
||||
results.r[outReg].MarkWrite(addr);
|
||||
}
|
||||
|
||||
if (info & DELAYSLOT)
|
||||
@@ -136,14 +134,16 @@ namespace MIPSAnalyst
|
||||
int numUsedRegs=0;
|
||||
static int totalUsedRegs=0;
|
||||
static int numAnalyzings=0;
|
||||
for (int i = 0; i < NUM_MIPS_GPRS; i++) {
|
||||
if (gprAnal[i].used) {
|
||||
for (int i = 0; i < MIPS_NUM_GPRS; i++) {
|
||||
if (results.r[i].used) {
|
||||
numUsedRegs++;
|
||||
}
|
||||
}
|
||||
totalUsedRegs+=numUsedRegs;
|
||||
numAnalyzings++;
|
||||
DEBUG_LOG(CPU,"[ %08x ] Used regs: %i Average: %f",address,numUsedRegs,(float)totalUsedRegs/(float)numAnalyzings);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10
-7
@@ -24,7 +24,8 @@ class DebugInterface;
|
||||
|
||||
namespace MIPSAnalyst
|
||||
{
|
||||
void Analyze(u32 address);
|
||||
const int MIPS_NUM_GPRS = 32;
|
||||
|
||||
struct RegisterAnalysisResults {
|
||||
bool used;
|
||||
int firstRead;
|
||||
@@ -38,9 +39,9 @@ namespace MIPSAnalyst
|
||||
int writeCount;
|
||||
int readAsAddrCount;
|
||||
|
||||
int TotalReadCount() {return readCount + readAsAddrCount;}
|
||||
int FirstRead() {return firstReadAsAddr < firstRead ? firstReadAsAddr : firstRead;}
|
||||
int LastRead() {return lastReadAsAddr > lastRead ? lastReadAsAddr : lastRead;}
|
||||
int TotalReadCount() const { return readCount + readAsAddrCount; }
|
||||
int FirstRead() const { return firstReadAsAddr < firstRead ? firstReadAsAddr : firstRead; }
|
||||
int LastRead() const { return lastReadAsAddr > lastRead ? lastReadAsAddr : lastRead; }
|
||||
|
||||
void MarkRead(u32 addr) {
|
||||
if (firstRead == -1)
|
||||
@@ -67,11 +68,13 @@ namespace MIPSAnalyst
|
||||
}
|
||||
};
|
||||
|
||||
struct AnalysisResults
|
||||
{
|
||||
int x;
|
||||
struct AnalysisResults {
|
||||
RegisterAnalysisResults r[MIPS_NUM_GPRS];
|
||||
};
|
||||
|
||||
AnalysisResults Analyze(u32 address);
|
||||
|
||||
|
||||
bool IsRegisterUsed(u32 reg, u32 addr);
|
||||
void ScanForFunctions(u32 startAddr, u32 endAddr);
|
||||
void CompileLeafs();
|
||||
|
||||
@@ -292,8 +292,7 @@ const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
|
||||
|
||||
b->normalEntry = GetCodePtr();
|
||||
|
||||
// TODO: this needs work
|
||||
MIPSAnalyst::AnalysisResults analysis; // = MIPSAnalyst::Analyze(em_address);
|
||||
MIPSAnalyst::AnalysisResults analysis = MIPSAnalyst::Analyze(em_address);
|
||||
|
||||
gpr.Start(mips_, analysis);
|
||||
fpr.Start(mips_, analysis);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "x64Emitter.h"
|
||||
#include "../MIPSAnalyst.h"
|
||||
#include "Common/x64Emitter.h"
|
||||
#include "Core/MIPS/MIPSAnalyst.h"
|
||||
|
||||
using namespace Gen;
|
||||
|
||||
|
||||
Reference in new issue
Block a user