summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/powerpc
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2018-03-23 11:28:51 +1100
committer Vas Crabb <vas@vastheman.com>2018-03-23 12:17:53 +1100
commit44c7da0cf5609188f67fd146329c44236f344493 (patch)
tree03ee9ea420bf93bf75468e7a76ba7d1339136ede /src/devices/cpu/powerpc
parent3be74a07a89d94b6af8d42a7e3032bccea51ddb0 (diff)
Make UML shorthand a bit easier to use without using namespace everywhere, clean up a bit of macro hell in PowerPC core
Diffstat (limited to 'src/devices/cpu/powerpc')
-rw-r--r--src/devices/cpu/powerpc/ppc.h13
-rw-r--r--src/devices/cpu/powerpc/ppccom.cpp2
-rw-r--r--src/devices/cpu/powerpc/ppcdrc.cpp93
-rw-r--r--src/devices/cpu/powerpc/ppcfe.cpp94
-rw-r--r--src/devices/cpu/powerpc/ppcfe.h68
5 files changed, 131 insertions, 139 deletions
diff --git a/src/devices/cpu/powerpc/ppc.h b/src/devices/cpu/powerpc/ppc.h
index 0a951bd2277..7c75237e834 100644
--- a/src/devices/cpu/powerpc/ppc.h
+++ b/src/devices/cpu/powerpc/ppc.h
@@ -8,17 +8,17 @@
PowerPC emulator.
***************************************************************************/
-
#ifndef MAME_CPU_POWERPC_PPC_H
#define MAME_CPU_POWERPC_PPC_H
#pragma once
-#include "divtlb.h"
#include "cpu/drcfe.h"
#include "cpu/drcuml.h"
#include "cpu/drcumlsh.h"
+#include "divtlb.h"
+
/***************************************************************************
CONSTANTS
@@ -168,14 +168,11 @@ enum
downcast<ppc_device &>(*device).set_bus_frequency(_frequency);
-class ppc_frontend;
-
-
class ppc_device : public cpu_device, public device_vtlb_interface
{
- friend class ppc_frontend;
-
protected:
+ class frontend;
+
/* PowerPC flavors */
enum powerpc_flavor
{
@@ -535,7 +532,7 @@ protected:
/* core state */
drc_cache m_cache; /* pointer to the DRC code cache */
std::unique_ptr<drcuml_state> m_drcuml; /* DRC UML generator state */
- std::unique_ptr<ppc_frontend> m_drcfe; /* pointer to the DRC front-end state */
+ std::unique_ptr<frontend> m_drcfe; /* pointer to the DRC front-end state */
uint32_t m_drcoptions; /* configurable DRC options */
/* parameters for subroutines */
diff --git a/src/devices/cpu/powerpc/ppccom.cpp b/src/devices/cpu/powerpc/ppccom.cpp
index 7f0ee873138..2c271a608bf 100644
--- a/src/devices/cpu/powerpc/ppccom.cpp
+++ b/src/devices/cpu/powerpc/ppccom.cpp
@@ -864,7 +864,7 @@ void ppc_device::device_start()
m_drcuml->symbol_add(&m_fcmp_cr_table, sizeof(m_fcmp_cr_table), "fcmp_cr_table");
/* initialize the front-end helper */
- m_drcfe = std::make_unique<ppc_frontend>(this, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE);
+ m_drcfe = std::make_unique<frontend>(*this, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE);
/* compute the register parameters */
for (int regnum = 0; regnum < 32; regnum++)
diff --git a/src/devices/cpu/powerpc/ppcdrc.cpp b/src/devices/cpu/powerpc/ppcdrc.cpp
index 30ebb6740cb..6b158fd6110 100644
--- a/src/devices/cpu/powerpc/ppcdrc.cpp
+++ b/src/devices/cpu/powerpc/ppcdrc.cpp
@@ -15,16 +15,15 @@
***************************************************************************/
#include "emu.h"
-#include "debugger.h"
#include "ppc.h"
#include "ppccom.h"
#include "ppcfe.h"
#include "ppc_dasm.h"
+
#include "cpu/drcfe.h"
#include "cpu/drcuml.h"
#include "cpu/drcumlsh.h"
-
-using namespace uml;
+#include "debugger.h"
@@ -58,12 +57,12 @@ using namespace uml;
#define R32(reg) m_regmap[reg]
#define R32Z(reg) (((reg) == 0) ? uml::parameter(0) : m_regmap[reg])
#define F64(reg) m_fdregmap[reg]
-#define CR32(reg) mem(&m_core->cr[reg])
-#define FPSCR32 mem(&m_core->fpscr)
-#define MSR32 mem(&m_core->msr)
-#define XERSO32 mem(&m_core->xerso)
-#define SR32(reg) mem(&m_core->sr[reg])
-#define SPR32(reg) mem(&m_core->spr[reg])
+#define CR32(reg) uml::mem(&m_core->cr[reg])
+#define FPSCR32 uml::mem(&m_core->fpscr)
+#define MSR32 uml::mem(&m_core->msr)
+#define XERSO32 uml::mem(&m_core->xerso)
+#define SR32(reg) uml::mem(&m_core->sr[reg])
+#define SPR32(reg) uml::mem(&m_core->spr[reg])
#define CRMASK(reg) (0xf0000000 >> ((reg) * 4))
@@ -103,7 +102,7 @@ using namespace uml;
already allocated
-------------------------------------------------*/
-inline void ppc_device::alloc_handle(drcuml_state *drcuml, code_handle **handleptr, const char *name)
+inline void ppc_device::alloc_handle(drcuml_state *drcuml, uml::code_handle **handleptr, const char *name)
{
if (*handleptr == nullptr)
*handleptr = drcuml->handle_alloc(name);
@@ -660,7 +659,7 @@ static void cfunc_ppccom_get_dsisr(void *param)
void ppc_device::static_generate_entry_point()
{
- code_label skip = 1;
+ uml::code_label skip = 1;
drcuml_block *block;
/* begin generating */
@@ -817,9 +816,9 @@ void ppc_device::static_generate_tlb_mismatch()
void ppc_device::static_generate_exception(uint8_t exception, int recover, const char *name)
{
- code_handle *&exception_handle = recover ? m_exception[exception] : m_exception_norecover[exception];
+ uml::code_handle *&exception_handle = recover ? m_exception[exception] : m_exception_norecover[exception];
uint32_t vector = exception << 8;
- code_label label = 1;
+ uml::code_label label = 1;
drcuml_block *block;
/* begin generating */
@@ -853,7 +852,7 @@ void ppc_device::static_generate_exception(uint8_t exception, int recover, const
UML_MOV(block, I3, vector); // mov i3,vector
if (exception == EXCEPTION_EI)
{
- code_label not_decrementer;
+ uml::code_label not_decrementer;
UML_TEST(block, mem(&m_core->irq_pending), 0x01); // test [irq_pending],0x01
UML_JMPc(block, COND_NZ, not_decrementer = label++); // jmp not_decrementer,nz
@@ -920,7 +919,7 @@ void ppc_device::static_generate_exception(uint8_t exception, int recover, const
UML_MOV(block, I3, vector); // mov i3,vector
if (exception == EXCEPTION_EI)
{
- code_label notwdog, common;
+ uml::code_label notwdog, common;
UML_TEST(block, SPR32(SPR4XX_TSR), PPC4XX_TSR_PIS); // test [tsr],PIS
UML_MOVc(block, COND_NZ, I3, 0x1000); // mov i3,0x1000,NZ
@@ -991,7 +990,7 @@ void ppc_device::static_generate_exception(uint8_t exception, int recover, const
static_generate_memory_accessor
------------------------------------------------------------------*/
-void ppc_device::static_generate_memory_accessor(int mode, int size, int iswrite, int ismasked, const char *name, code_handle *&handleptr, code_handle *masked)
+void ppc_device::static_generate_memory_accessor(int mode, int size, int iswrite, int ismasked, const char *name, uml::code_handle *&handleptr, uml::code_handle *masked)
{
/* on entry, address is in I0; data for writes is in I1; masks are in I2 */
/* on exit, read result is in I0 */
@@ -1599,7 +1598,7 @@ void ppc_device::generate_update_cycles(drcuml_block *block, compiler_state *com
/* check full interrupts if pending */
if (compiler->checkints)
{
- code_label skip;
+ uml::code_label skip;
compiler->checkints = false;
UML_TEST(block, mem(&m_core->irq_pending), ~0); // test [irq_pending],0
@@ -1814,12 +1813,12 @@ void ppc_device::generate_compute_flags(drcuml_block *block, const opcode_desc *
/* modify inputs based on required flags */
if (!DISABLE_FLAG_OPTIMIZATIONS)
{
- if (!(desc->regreq[3] & REGFLAG_XER_CA))
+ if (!(desc->regreq[3] & frontend::REGFLAG_XER_CA))
xermask &= ~XER_CA;
- if (!(desc->regreq[2] & REGFLAG_CR(0)))
+ if (!(desc->regreq[2] & frontend::REGFLAG_CR(0)))
updatecr = 0;
}
- xerflags = ((xermask & XER_OV) ? FLAG_V : 0) | ((xermask & XER_CA) ? FLAG_C : 0);
+ xerflags = ((xermask & XER_OV) ? uml::FLAG_V : 0) | ((xermask & XER_CA) ? uml::FLAG_C : 0);
/* easy case: nothing to do */
if (!updatecr && xermask == 0)
@@ -1943,7 +1942,7 @@ void ppc_device::generate_branch(drcuml_block *block, compiler_state *compiler,
}
else
{
- generate_update_cycles(block, &compiler_temp, mem(srcptr), true); // <subtract cycles>
+ generate_update_cycles(block, &compiler_temp, uml::mem(srcptr), true); // <subtract cycles>
/* clear two LSBs of the target address to prevent branching to an invalid address */
UML_AND(block, I0, mem(srcptr), 0xFFFFFFFC); // and i0, 0xFFFFFFFC
@@ -2857,7 +2856,7 @@ bool ppc_device::generate_instruction_1f(drcuml_block *block, compiler_state *co
UML_CMP(block, I2, 0x00000020); // cmp rb,0x20
UML_JMPc(block, COND_S, compiler->labelnum); // bs 1:
- if (DISABLE_FLAG_OPTIMIZATIONS || (desc->regreq[3] & REGFLAG_XER_CA))
+ if (DISABLE_FLAG_OPTIMIZATIONS || (desc->regreq[3] & frontend::REGFLAG_XER_CA))
{
// for shift amt > 32, carry flag is the sign bit of Rs and the sign bit fills all bit positions
UML_TEST(block, R32(G_RS(op)), 0x80000000);
@@ -2868,7 +2867,7 @@ bool ppc_device::generate_instruction_1f(drcuml_block *block, compiler_state *co
UML_JMP(block, compiler->labelnum+1); // bra 2:
UML_LABEL(block, compiler->labelnum++); // 1:
- if (DISABLE_FLAG_OPTIMIZATIONS || (desc->regreq[3] & REGFLAG_XER_CA))
+ if (DISABLE_FLAG_OPTIMIZATIONS || (desc->regreq[3] & frontend::REGFLAG_XER_CA))
{
UML_SHL(block, I1, 0xffffffff, I2); // shl i1,0xffffffff,i2
UML_XOR(block, I1, I1, ~0); // xor i1,i1,~0
@@ -2889,7 +2888,7 @@ bool ppc_device::generate_instruction_1f(drcuml_block *block, compiler_state *co
return true;
case 0x338: /* SRAWIx */
- if (DISABLE_FLAG_OPTIMIZATIONS || (desc->regreq[3] & REGFLAG_XER_CA))
+ if (DISABLE_FLAG_OPTIMIZATIONS || (desc->regreq[3] & frontend::REGFLAG_XER_CA))
{
UML_AND(block, I0, R32(G_RS(op)), ~(0xffffffff << (G_SH(op) & 31)));// and i0,rs,~(0xffffffff << (sh & 31))
UML_SAR(block, I1, R32(G_RS(op)), 31); // sar i1,rs,31
@@ -3852,84 +3851,84 @@ void ppc_device::log_register_list(drcuml_state *drcuml, const char *string, con
drcuml->log_printf("[%s:", string);
for (regnum = 0; regnum < 32; regnum++)
- if (reglist[0] & REGFLAG_R(regnum))
+ if (reglist[0] & frontend::REGFLAG_R(regnum))
{
drcuml->log_printf("%sr%d", (count++ == 0) ? "" : ",", regnum);
- if (regnostarlist != nullptr && !(regnostarlist[0] & REGFLAG_R(regnum)))
+ if (regnostarlist != nullptr && !(regnostarlist[0] & frontend::REGFLAG_R(regnum)))
drcuml->log_printf("*");
}
for (regnum = 0; regnum < 32; regnum++)
- if (reglist[1] & REGFLAG_FR(regnum))
+ if (reglist[1] & frontend::REGFLAG_FR(regnum))
{
drcuml->log_printf("%sfr%d", (count++ == 0) ? "" : ",", regnum);
- if (regnostarlist != nullptr && !(regnostarlist[1] & REGFLAG_FR(regnum)))
+ if (regnostarlist != nullptr && !(regnostarlist[1] & frontend::REGFLAG_FR(regnum)))
drcuml->log_printf("*");
}
for (regnum = 0; regnum < 8; regnum++)
- if (reglist[2] & REGFLAG_CR(regnum))
+ if (reglist[2] & frontend::REGFLAG_CR(regnum))
{
- if ((reglist[2] & REGFLAG_CR(regnum)) == REGFLAG_CR(regnum) && (regnostarlist == nullptr || (regnostarlist[2] & REGFLAG_CR(regnum)) == REGFLAG_CR(regnum)))
+ if ((reglist[2] & frontend::REGFLAG_CR(regnum)) == frontend::REGFLAG_CR(regnum) && (regnostarlist == nullptr || (regnostarlist[2] & frontend::REGFLAG_CR(regnum)) == frontend::REGFLAG_CR(regnum)))
{
drcuml->log_printf("%scr%d", (count++ == 0) ? "" : ",", regnum);
- if (regnostarlist != nullptr && !(regnostarlist[2] & REGFLAG_CR(regnum)))
+ if (regnostarlist != nullptr && !(regnostarlist[2] & frontend::REGFLAG_CR(regnum)))
drcuml->log_printf("*");
}
else
{
for (crnum = 0; crnum < 4; crnum++)
- if (reglist[2] & REGFLAG_CR_BIT(regnum * 4 + crnum))
+ if (reglist[2] & frontend::REGFLAG_CR_BIT(regnum * 4 + crnum))
{
drcuml->log_printf("%scr%d[%s]", (count++ == 0) ? "" : ",", regnum, crtext[crnum]);
- if (regnostarlist != nullptr && !(regnostarlist[2] & REGFLAG_CR_BIT(regnum * 4 + crnum)))
+ if (regnostarlist != nullptr && !(regnostarlist[2] & frontend::REGFLAG_CR_BIT(regnum * 4 + crnum)))
drcuml->log_printf("*");
}
}
}
- if (reglist[3] & REGFLAG_XER_CA)
+ if (reglist[3] & frontend::REGFLAG_XER_CA)
{
drcuml->log_printf("%sxer_ca", (count++ == 0) ? "" : ",");
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_XER_CA))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_XER_CA))
drcuml->log_printf("*");
}
- if (reglist[3] & REGFLAG_XER_OV)
+ if (reglist[3] & frontend::REGFLAG_XER_OV)
{
drcuml->log_printf("%sxer_ov", (count++ == 0) ? "" : ",");
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_XER_OV))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_XER_OV))
drcuml->log_printf("*");
}
- if (reglist[3] & REGFLAG_XER_SO)
+ if (reglist[3] & frontend::REGFLAG_XER_SO)
{
drcuml->log_printf("%sxer_so", (count++ == 0) ? "" : ",");
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_XER_SO))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_XER_SO))
drcuml->log_printf("*");
}
- if (reglist[3] & REGFLAG_XER_COUNT)
+ if (reglist[3] & frontend::REGFLAG_XER_COUNT)
{
drcuml->log_printf("%sxer_count", (count++ == 0) ? "" : ",");
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_XER_COUNT))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_XER_COUNT))
drcuml->log_printf("*");
}
- if (reglist[3] & REGFLAG_CTR)
+ if (reglist[3] & frontend::REGFLAG_CTR)
{
drcuml->log_printf("%sctr", (count++ == 0) ? "" : ",");
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_CTR))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_CTR))
drcuml->log_printf("*");
}
- if (reglist[3] & REGFLAG_LR)
+ if (reglist[3] & frontend::REGFLAG_LR)
{
drcuml->log_printf("%slr", (count++ == 0) ? "" : ",");
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_LR))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_LR))
drcuml->log_printf("*");
}
for (regnum = 0; regnum < 8; regnum++)
- if (reglist[3] & REGFLAG_FPSCR(regnum))
+ if (reglist[3] & frontend::REGFLAG_FPSCR(regnum))
{
drcuml->log_printf("%sfpscr%d", (count++ == 0) ? "" : ",", regnum);
- if (regnostarlist != nullptr && !(regnostarlist[3] & REGFLAG_FPSCR(regnum)))
+ if (regnostarlist != nullptr && !(regnostarlist[3] & frontend::REGFLAG_FPSCR(regnum)))
drcuml->log_printf("*");
}
diff --git a/src/devices/cpu/powerpc/ppcfe.cpp b/src/devices/cpu/powerpc/ppcfe.cpp
index 956fad03374..67c90d37897 100644
--- a/src/devices/cpu/powerpc/ppcfe.cpp
+++ b/src/devices/cpu/powerpc/ppcfe.cpp
@@ -53,12 +53,12 @@
//**************************************************************************
//-------------------------------------------------
-// ppc_frontend - constructor
+// frontend - constructor
//-------------------------------------------------
-ppc_frontend::ppc_frontend(ppc_device *ppc, uint32_t window_start, uint32_t window_end, uint32_t max_sequence)
- : drc_frontend(*ppc, window_start, window_end, max_sequence),
- m_ppc(ppc)
+ppc_device::frontend::frontend(ppc_device &ppc, uint32_t window_start, uint32_t window_end, uint32_t max_sequence)
+ : drc_frontend(ppc, window_start, window_end, max_sequence)
+ , m_ppc(ppc)
{
}
@@ -68,13 +68,13 @@ ppc_frontend::ppc_frontend(ppc_device *ppc, uint32_t window_start, uint32_t wind
// instruction
//-------------------------------------------------
-bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
+bool ppc_device::frontend::describe(opcode_desc &desc, const opcode_desc *prev)
{
uint32_t op, opswitch;
int regnum;
// compute the physical PC
- if (!m_ppc->memory_translate(AS_PROGRAM, TRANSLATE_FETCH, desc.physpc))
+ if (!m_ppc.memory_translate(AS_PROGRAM, TRANSLATE_FETCH, desc.physpc))
{
// uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and
// mark as needing to validate; otherwise, just end the sequence here
@@ -83,7 +83,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
}
// fetch the opcode
- op = desc.opptr.l[0] = m_ppc->m_direct->read_dword(desc.physpc, m_ppc->m_codexor);
+ op = desc.opptr.l[0] = m_ppc.m_direct->read_dword(desc.physpc, m_ppc.m_codexor);
// all instructions are 4 bytes and default to a single cycle each
desc.length = 4;
@@ -172,7 +172,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
return true;
case 0x11: // SC
- if (!(m_ppc->m_cap & (PPCCAP_OEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_OEA | PPCCAP_4XX)))
return false;
desc.flags |= OPFLAG_WILL_CAUSE_EXCEPTION;
if (is_601_class())
@@ -305,7 +305,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
case 0x30: // LFS
case 0x32: // LFD
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
FPR_MODIFIED(desc, G_RD(op));
@@ -314,7 +314,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
case 0x31: // LFSU
case 0x33: // LFDU
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
if (G_RA(op) == 0)
return false;
@@ -326,7 +326,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
case 0x34: // STFS
case 0x36: // STFD
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
FPR_USED(desc, G_RS(op));
@@ -335,7 +335,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
case 0x35: // STFSU
case 0x37: // STFDU
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
if (G_RA(op) == 0)
return false;
@@ -362,7 +362,7 @@ bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
0x13 group
-------------------------------------------------*/
-bool ppc_frontend::describe_13(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
+bool ppc_device::frontend::describe_13(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
{
uint32_t opswitch = (op >> 1) & 0x3ff;
@@ -411,7 +411,7 @@ bool ppc_frontend::describe_13(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x032: // RFI
- if (!(m_ppc->m_cap & (PPCCAP_OEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_OEA | PPCCAP_4XX)))
return false;
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_CAUSE_EXCEPTION;
desc.targetpc = BRANCH_TARGET_DYNAMIC;
@@ -424,14 +424,14 @@ bool ppc_frontend::describe_13(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x033: // RFCI
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_CAUSE_EXCEPTION;
desc.targetpc = BRANCH_TARGET_DYNAMIC;
return true;
case 0x096: // ISYNC
- if (!(m_ppc->m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
return false;
if (is_601_class())
desc.cycles = 6; // 601
@@ -463,7 +463,7 @@ bool ppc_frontend::describe_13(uint32_t op, opcode_desc &desc, const opcode_desc
0x1f group
-------------------------------------------------*/
-bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
+bool ppc_device::frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
{
uint32_t opswitch = (op >> 1) & 0x3ff;
int spr, regnum;
@@ -709,7 +709,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x136: // ECIWX
- if (!(m_ppc->m_cap & PPCCAP_VEA))
+ if (!(m_ppc.m_cap & PPCCAP_VEA))
return false;
case 0x014: // LWARX
case 0x017: // LWZX
@@ -774,14 +774,14 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
case 0x116: // DCBT
case 0x2f6: // DCBA
case 0x3d6: // ICBI
- if (!(m_ppc->m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
return true;
case 0x1d6: // DCBI
- if (!(m_ppc->m_cap & (PPCCAP_OEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_OEA | PPCCAP_4XX)))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
@@ -817,11 +817,11 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
}
if (spr & 0x010)
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
- if ((m_ppc->m_cap & PPCCAP_4XX) && spr == SPR4XX_TBLU)
+ if ((m_ppc.m_cap & PPCCAP_4XX) && spr == SPR4XX_TBLU)
desc.cycles = POWERPC_COUNT_READ_TBL;
- else if ((m_ppc->m_cap & PPCCAP_VEA) && spr == SPRVEA_TBL_R)
+ else if ((m_ppc.m_cap & PPCCAP_VEA) && spr == SPRVEA_TBL_R)
desc.cycles = POWERPC_COUNT_READ_TBL;
- else if ((m_ppc->m_cap & PPCCAP_OEA) && spr == SPROEA_DEC)
+ else if ((m_ppc.m_cap & PPCCAP_OEA) && spr == SPROEA_DEC)
desc.cycles = POWERPC_COUNT_READ_DEC;
return true;
@@ -844,7 +844,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x173: // MFTB
- if (!(m_ppc->m_cap & PPCCAP_VEA))
+ if (!(m_ppc.m_cap & PPCCAP_VEA))
return false;
GPR_MODIFIED(desc, G_RD(op));
spr = compute_spr(G_SPR(op));
@@ -893,7 +893,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x0d2: // MTSR
- if (!(m_ppc->m_cap & PPCCAP_OEA))
+ if (!(m_ppc.m_cap & PPCCAP_OEA))
return false;
GPR_USED(desc, G_RS(op));
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
@@ -918,7 +918,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x1b6: // ECOWX
- if (!(m_ppc->m_cap & PPCCAP_VEA))
+ if (!(m_ppc.m_cap & PPCCAP_VEA))
return false;
case 0x096: // STWCX.
case 0x097: // STWX
@@ -945,7 +945,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x0f2: // MTSRIN
- if (!(m_ppc->m_cap & PPCCAP_OEA))
+ if (!(m_ppc.m_cap & PPCCAP_OEA))
return false;
GPR_USED(desc, G_RS(op));
GPR_USED(desc, G_RB(op));
@@ -953,21 +953,21 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x132: // TLBIE
- if (!(m_ppc->m_cap & PPCCAP_OEA))
+ if (!(m_ppc.m_cap & PPCCAP_OEA))
return false;
GPR_USED(desc, G_RB(op));
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
return true;
case 0x172: // TLBIA
- if (!(m_ppc->m_cap & PPCCAP_OEA) || (m_ppc->m_cap & PPCCAP_603_MMU))
+ if (!(m_ppc.m_cap & PPCCAP_OEA) || (m_ppc.m_cap & PPCCAP_603_MMU))
return false;
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
return true;
case 0x3d2: // TLBLD
case 0x3f2: // TLBLI
- if (!(m_ppc->m_cap & PPCCAP_603_MMU) && !is_602_class())
+ if (!(m_ppc.m_cap & PPCCAP_603_MMU) && !is_602_class())
return false;
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
return true;
@@ -993,7 +993,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
case 0x217: // LFSX
case 0x257: // LFDX
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
@@ -1002,7 +1002,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x236: // TLBSYNC
- if (!(m_ppc->m_cap & PPCCAP_OEA))
+ if (!(m_ppc.m_cap & PPCCAP_OEA))
return false;
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
return true;
@@ -1011,13 +1011,13 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x356: // EIEIO
- if (!(m_ppc->m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
return false;
return true;
case 0x237: // LFSUX
case 0x277: // LFDUX
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
if (G_RA(op) == 0)
return false;
@@ -1056,7 +1056,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
case 0x297: // STFSX
case 0x2d7: // STFDX
case 0x3d7: // STFIWX
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
@@ -1066,7 +1066,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
case 0x2b7: // STFSUX
case 0x2f7: // STFDUX
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
if (G_RA(op) == 0)
return false;
@@ -1089,7 +1089,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x3f6: // DCBZ
- if (!(m_ppc->m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
+ if (!(m_ppc.m_cap & (PPCCAP_VEA | PPCCAP_4XX)))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
@@ -1099,7 +1099,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
case 0x106: // ICBT
case 0x1c6: // DCCCI
case 0x3c6: // ICCCI
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
@@ -1108,7 +1108,7 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
case 0x1e6: // DCREAD
case 0x3e6: // ICREAD
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
GPR_USED_OR_ZERO(desc, G_RA(op));
GPR_USED(desc, G_RB(op));
@@ -1117,28 +1117,28 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
return true;
case 0x143: // MFDCR
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
GPR_MODIFIED(desc, G_RD(op));
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
return true;
case 0x1c3: // MTDCR
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
GPR_USED(desc, G_RS(op));
desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
return true;
case 0x083: // WRTEE
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
GPR_USED(desc, G_RS(op));
desc.flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
return true;
case 0x0a3: // WRTEEI
- if (!(m_ppc->m_cap & PPCCAP_4XX))
+ if (!(m_ppc.m_cap & PPCCAP_4XX))
return false;
if (op & MSR_EE)
desc.flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
@@ -1162,11 +1162,11 @@ bool ppc_frontend::describe_1f(uint32_t op, opcode_desc &desc, const opcode_desc
0x3b group
-------------------------------------------------*/
-bool ppc_frontend::describe_3b(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
+bool ppc_device::frontend::describe_3b(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
{
uint32_t opswitch = (op >> 1) & 0x1f;
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
switch (opswitch)
@@ -1238,11 +1238,11 @@ bool ppc_frontend::describe_3b(uint32_t op, opcode_desc &desc, const opcode_desc
0x3f group
-------------------------------------------------*/
-bool ppc_frontend::describe_3f(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
+bool ppc_device::frontend::describe_3f(uint32_t op, opcode_desc &desc, const opcode_desc *prev)
{
uint32_t opswitch = (op >> 1) & 0x3ff;
- if (!(m_ppc->m_cap & PPCCAP_FPU))
+ if (!(m_ppc.m_cap & PPCCAP_FPU))
return false;
if (opswitch & 0x10)
diff --git a/src/devices/cpu/powerpc/ppcfe.h b/src/devices/cpu/powerpc/ppcfe.h
index 697cd9b2438..40b82bd8756 100644
--- a/src/devices/cpu/powerpc/ppcfe.h
+++ b/src/devices/cpu/powerpc/ppcfe.h
@@ -7,49 +7,45 @@
Front-end for PowerPC recompiler
***************************************************************************/
+#ifndef MAME_CPU_POWERPC_PPCFE_H
+#define MAME_CPU_POWERPC_PPCFE_H
-#ifndef __PPCFE_H__
-#define __PPCFE_H__
+#pragma once
#include "ppc.h"
-#include "cpu/drcfe.h"
-
-
-//**************************************************************************
-// MACROS
-//**************************************************************************
-
-// register flags 0
-#define REGFLAG_R(n) (1 << (n))
-#define REGFLAG_RZ(n) (((n) == 0) ? 0 : REGFLAG_R(n))
-
-// register flags 1
-#define REGFLAG_FR(n) (1 << (n))
-
-// register flags 2
-#define REGFLAG_CR(n) (0xf0000000 >> (4 * (n)))
-#define REGFLAG_CR_BIT(n) (0x80000000 >> (n))
-
-// register flags 3
-#define REGFLAG_XER_CA (1 << 0)
-#define REGFLAG_XER_OV (1 << 1)
-#define REGFLAG_XER_SO (1 << 2)
-#define REGFLAG_XER_COUNT (1 << 3)
-#define REGFLAG_CTR (1 << 4)
-#define REGFLAG_LR (1 << 5)
-#define REGFLAG_FPSCR(n) (1 << (6 + (n)))
+#include "cpu/drcfe.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
-class ppc_frontend : public drc_frontend
+class ppc_device::frontend : public drc_frontend
{
public:
+ // register flags 0
+ static constexpr u32 REGFLAG_R(unsigned n) { return 1U << n; }
+ static constexpr u32 REGFLAG_RZ(unsigned n) { return !n ? 0U : REGFLAG_R(n); }
+
+ // register flags 1
+ static constexpr u32 REGFLAG_FR(unsigned n) { return 1U << n; }
+
+ // register flags 2
+ static constexpr u32 REGFLAG_CR(unsigned n) { return 0xf0000000U >> (4 * n); }
+ static constexpr u32 REGFLAG_CR_BIT(unsigned n) { return 0x80000000U >> n; }
+
+ // register flags 3
+ static constexpr u32 REGFLAG_XER_CA = 1U << 0;
+ static constexpr u32 REGFLAG_XER_OV = 1U << 1;
+ static constexpr u32 REGFLAG_XER_SO = 1U << 2;
+ static constexpr u32 REGFLAG_XER_COUNT = 1U << 3;
+ static constexpr u32 REGFLAG_CTR = 1U << 4;
+ static constexpr u32 REGFLAG_LR = 1U << 5;
+ static constexpr u32 REGFLAG_FPSCR(unsigned n) { return 1U << (6 + n); }
+
// construction/destruction
- ppc_frontend(ppc_device *ppc, uint32_t window_start, uint32_t window_end, uint32_t max_sequence);
+ frontend(ppc_device &ppc, uint32_t window_start, uint32_t window_end, uint32_t max_sequence);
protected:
// required overrides
@@ -58,10 +54,10 @@ protected:
private:
// inlines
uint32_t compute_spr(uint32_t spr) const { return ((spr >> 5) | (spr << 5)) & 0x3ff; }
- bool is_403_class() const { return (m_ppc->m_flavor == ppc_device::PPC_MODEL_403GA || m_ppc->m_flavor == ppc_device::PPC_MODEL_403GB || m_ppc->m_flavor == ppc_device::PPC_MODEL_403GC || m_ppc->m_flavor == ppc_device::PPC_MODEL_403GCX || m_ppc->m_flavor == ppc_device::PPC_MODEL_405GP); }
- bool is_601_class() const { return (m_ppc->m_flavor == ppc_device::PPC_MODEL_601); }
- bool is_602_class() const { return (m_ppc->m_flavor == ppc_device::PPC_MODEL_602); }
- bool is_603_class() const { return (m_ppc->m_flavor == ppc_device::PPC_MODEL_603 || m_ppc->m_flavor == ppc_device::PPC_MODEL_603E || m_ppc->m_flavor == ppc_device::PPC_MODEL_603EV || m_ppc->m_flavor == ppc_device::PPC_MODEL_603R); }
+ bool is_403_class() const { return (m_ppc.m_flavor == ppc_device::PPC_MODEL_403GA || m_ppc.m_flavor == ppc_device::PPC_MODEL_403GB || m_ppc.m_flavor == ppc_device::PPC_MODEL_403GC || m_ppc.m_flavor == ppc_device::PPC_MODEL_403GCX || m_ppc.m_flavor == ppc_device::PPC_MODEL_405GP); }
+ bool is_601_class() const { return (m_ppc.m_flavor == ppc_device::PPC_MODEL_601); }
+ bool is_602_class() const { return (m_ppc.m_flavor == ppc_device::PPC_MODEL_602); }
+ bool is_603_class() const { return (m_ppc.m_flavor == ppc_device::PPC_MODEL_603 || m_ppc.m_flavor == ppc_device::PPC_MODEL_603E || m_ppc.m_flavor == ppc_device::PPC_MODEL_603EV || m_ppc.m_flavor == ppc_device::PPC_MODEL_603R); }
// internal helpers
bool describe_13(uint32_t op, opcode_desc &desc, const opcode_desc *prev);
@@ -70,8 +66,8 @@ private:
bool describe_3f(uint32_t op, opcode_desc &desc, const opcode_desc *prev);
// internal state
- ppc_device *m_ppc;
+ ppc_device &m_ppc;
};
-#endif /* __PPCFE_H__ */
+#endif // MAME_CPU_POWERPC_PPCFE_H