Skip to content

Commit

Permalink
Merge pull request #6462 from lioncash/ppc
Browse files Browse the repository at this point in the history
PPCTables: Make the op type enum an enum class
  • Loading branch information
degasus committed Mar 19, 2018
2 parents 8002bfb + 6428cee commit 3d49bdb
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 313 deletions.
530 changes: 265 additions & 265 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitArm64/Jit.cpp
Expand Up @@ -772,7 +772,7 @@ void JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock*
}

CompileInstruction(ops[i]);
if (!CanMergeNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER)
if (!CanMergeNextInstructions(1) || js.op[1].opinfo->type != ::OpType::Integer)
FlushCarry();

// If we have a register that will never be used again, flush it.
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp
Expand Up @@ -56,7 +56,7 @@ void JitArm64::ComputeCarry()
return;

js.carryFlagSet = true;
if (CanMergeNextInstructions(1) && js.op[1].opinfo->type == OPTYPE_INTEGER)
if (CanMergeNextInstructions(1) && js.op[1].opinfo->type == ::OpType::Integer)
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/JitInterface.cpp
Expand Up @@ -241,8 +241,8 @@ void CompileExceptionCheck(ExceptionType type)
if (type == ExceptionType::FIFOWrite)
{
// Check in case the code has been replaced since: do we need to do this?
int optype = GetOpInfo(PowerPC::HostRead_U32(PC))->type;
if (optype != OPTYPE_STORE && optype != OPTYPE_STOREFP && (optype != OPTYPE_STOREPS))
const ::OpType optype = GetOpInfo(PowerPC::HostRead_U32(PC))->type;
if (optype != ::OpType::Store && optype != ::OpType::StoreFP && optype != ::OpType::StorePS)
return;
}
exception_addresses->insert(PC);
Expand Down
34 changes: 17 additions & 17 deletions Source/Core/Core/PowerPC/PPCAnalyst.cpp
Expand Up @@ -252,11 +252,11 @@ static bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b)
// a crash caused by this error.
//
// [1] https://bugs.dolphin-emu.org/issues/5864#note-7
if (b_info->type != OPTYPE_INTEGER)
if (b_info->type != OpType::Integer)
return false;

// And it's possible a might raise an interrupt too (fcmpo/fcmpu)
if (a_info->type != OPTYPE_INTEGER)
if (a_info->type != OpType::Integer)
return false;

// Check that we have no register collisions.
Expand Down Expand Up @@ -464,7 +464,7 @@ static bool isCmp(const CodeOp& a)
static bool isCarryOp(const CodeOp& a)
{
return (a.opinfo->flags & FL_SET_CA) && !(a.opinfo->flags & FL_SET_OE) &&
a.opinfo->type == OPTYPE_INTEGER;
a.opinfo->type == OpType::Integer;
}

static bool isCror(const CodeOp& a)
Expand Down Expand Up @@ -581,7 +581,7 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk
// If the instruction reads CA but doesn't write it, we still need to store CA in XER; we can't
// leave it in flags.
if (HasOption(OPTION_CARRY_MERGE))
code->wantsCAInFlags = code->wantsCA && code->outputCA && opinfo->type == OPTYPE_INTEGER;
code->wantsCAInFlags = code->wantsCA && code->outputCA && opinfo->type == OpType::Integer;
else
code->wantsCAInFlags = false;

Expand Down Expand Up @@ -659,25 +659,25 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk

switch (opinfo->type)
{
case OPTYPE_INTEGER:
case OPTYPE_LOAD:
case OPTYPE_STORE:
case OPTYPE_LOADFP:
case OPTYPE_STOREFP:
case OpType::Integer:
case OpType::Load:
case OpType::Store:
case OpType::LoadFP:
case OpType::StoreFP:
break;
case OPTYPE_SINGLEFP:
case OPTYPE_DOUBLEFP:
case OpType::SingleFP:
case OpType::DoubleFP:
break;
case OPTYPE_BRANCH:
case OpType::Branch:
if (code->inst.hex == 0x4e800020)
{
// For analysis purposes, we can assume that blr eats opinfo->flags.
code->outputCR0 = true;
code->outputCR1 = true;
}
break;
case OPTYPE_SYSTEM:
case OPTYPE_SYSTEMFP:
case OpType::System:
case OpType::SystemFP:
break;
}
}
Expand Down Expand Up @@ -924,7 +924,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32
fprIsDuplicated[code[i].fregOut] = false;
fprIsStoreSafe[code[i].fregOut] = false;
// Single, duplicated, and doesn't need PPC_FP.
if (code[i].opinfo->type == OPTYPE_SINGLEFP)
if (code[i].opinfo->type == OpType::SingleFP)
{
fprIsSingle[code[i].fregOut] = true;
fprIsDuplicated[code[i].fregOut] = true;
Expand All @@ -940,7 +940,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32
fprIsDuplicated[code[i].fregOut] = true;
}
// Paired are still floats, but the top/bottom halves may differ.
if (code[i].opinfo->type == OPTYPE_PS || code[i].opinfo->type == OPTYPE_LOADPS)
if (code[i].opinfo->type == OpType::PS || code[i].opinfo->type == OpType::LoadPS)
{
fprIsSingle[code[i].fregOut] = true;
fprIsStoreSafe[code[i].fregOut] = true;
Expand All @@ -952,7 +952,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32
fprIsStoreSafe = BitSet32(0);
}

if (code[i].opinfo->type == OPTYPE_STOREPS || code[i].opinfo->type == OPTYPE_LOADPS)
if (code[i].opinfo->type == OpType::StorePS || code[i].opinfo->type == OpType::LoadPS)
{
int gqr = code[i].inst.OPCD == 4 ? code[i].inst.Ix : code[i].inst.I;
gqrUsed[gqr] = true;
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/PowerPC/PPCTables.cpp
Expand Up @@ -41,7 +41,7 @@ const std::array<u64, 16> m_crTable = {{
GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst)
{
GekkoOPInfo* info = m_infoTable[_inst.OPCD];
if (info->type == OPTYPE_SUBTABLE)
if (info->type == OpType::Subtable)
{
switch (_inst.OPCD)
{
Expand All @@ -62,7 +62,7 @@ GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst)
}
else
{
if (info->type == OPTYPE_INVALID)
if (info->type == OpType::Invalid)
{
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op %08x @ %08x", _inst.hex, PC);
return nullptr;
Expand All @@ -74,7 +74,7 @@ GekkoOPInfo* GetOpInfo(UGeckoInstruction _inst)
Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst)
{
const GekkoOPInfo* info = m_infoTable[_inst.OPCD];
if (info->type == OPTYPE_SUBTABLE)
if (info->type == OpType::Subtable)
{
switch (_inst.OPCD)
{
Expand All @@ -95,7 +95,7 @@ Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst)
}
else
{
if (info->type == OPTYPE_INVALID)
if (info->type == OpType::Invalid)
{
ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid op %08x @ %08x", _inst.hex, PC);
return nullptr;
Expand Down Expand Up @@ -131,7 +131,7 @@ const char* GetInstructionName(UGeckoInstruction _inst)
bool IsValidInstruction(UGeckoInstruction _inst)
{
const GekkoOPInfo* info = GetOpInfo(_inst);
return info != nullptr && info->type != OPTYPE_UNKNOWN;
return info != nullptr && info->type != OpType::Unknown;
}

void CountInstruction(UGeckoInstruction _inst)
Expand Down
44 changes: 22 additions & 22 deletions Source/Core/Core/PowerPC/PPCTables.h
Expand Up @@ -61,34 +61,34 @@ enum
FL_INOUT_FLOAT_D = FL_IN_FLOAT_D | FL_OUT_FLOAT_D,
};

enum
enum class OpType
{
OPTYPE_INVALID,
OPTYPE_SUBTABLE,
OPTYPE_INTEGER,
OPTYPE_CR,
OPTYPE_SPR,
OPTYPE_SYSTEM,
OPTYPE_SYSTEMFP,
OPTYPE_LOAD,
OPTYPE_STORE,
OPTYPE_LOADFP,
OPTYPE_STOREFP,
OPTYPE_DOUBLEFP,
OPTYPE_SINGLEFP,
OPTYPE_LOADPS,
OPTYPE_STOREPS,
OPTYPE_PS,
OPTYPE_DCACHE,
OPTYPE_ICACHE,
OPTYPE_BRANCH,
OPTYPE_UNKNOWN,
Invalid,
Subtable,
Integer,
CR,
SPR,
System,
SystemFP,
Load,
Store,
LoadFP,
StoreFP,
DoubleFP,
SingleFP,
LoadPS,
StorePS,
PS,
DataCache,
InstructionCache,
Branch,
Unknown,
};

struct GekkoOPInfo
{
const char* opname;
int type;
OpType type;
int flags;
int numCycles;
u64 runCount;
Expand Down

0 comments on commit 3d49bdb

Please sign in to comment.