Replaced a couple of static_cast downcasts with dynamic_cast for safety, cleaned up some formatting.

This commit is contained in:
Vas Crabb 2022-04-16 07:47:02 +10:00
parent 7b8e04e00c
commit 6985fb1f90
6 changed files with 31 additions and 31 deletions

View File

@ -134,7 +134,7 @@ public:
// describe a block // describe a block
opcode_desc const *describe_code(offs_t startpc); opcode_desc const *describe_code(offs_t startpc);
// get last opcode of block // get last opcode of block
opcode_desc const* get_last() { return m_desc_live_list.last(); }; opcode_desc const *get_last() { return m_desc_live_list.last(); }
protected: protected:
// required overrides // required overrides

View File

@ -624,7 +624,7 @@ private:
void generate_update_mode(drcuml_block &block); void generate_update_mode(drcuml_block &block);
void generate_update_cycles(drcuml_block &block, compiler_state &compiler, uml::parameter param, bool allow_exception); void generate_update_cycles(drcuml_block &block, compiler_state &compiler, uml::parameter param, bool allow_exception);
void generate_checksum_block(drcuml_block &block, compiler_state &compiler, const opcode_desc *seqhead, const opcode_desc *seqlast, const opcode_desc* codelast); void generate_checksum_block(drcuml_block &block, compiler_state &compiler, const opcode_desc *seqhead, const opcode_desc *seqlast, const opcode_desc *codelast);
void generate_sequence_instruction(drcuml_block &block, compiler_state &compiler, const opcode_desc *desc); void generate_sequence_instruction(drcuml_block &block, compiler_state &compiler, const opcode_desc *desc);
void generate_delay_slot_and_branch(drcuml_block &block, compiler_state &compiler, const opcode_desc *desc, uint8_t linkreg); void generate_delay_slot_and_branch(drcuml_block &block, compiler_state &compiler, const opcode_desc *desc, uint8_t linkreg);
@ -969,6 +969,7 @@ private:
/*************************************************************************** /***************************************************************************
COMPILER-SPECIFIC OPTIONS COMPILER-SPECIFIC OPTIONS
***************************************************************************/ ***************************************************************************/
#define MIPS3DRC_STRICT_VERIFY 0x0001 /* verify all instructions */ #define MIPS3DRC_STRICT_VERIFY 0x0001 /* verify all instructions */
#define MIPS3DRC_STRICT_COP0 0x0002 /* validate all COP0 instructions */ #define MIPS3DRC_STRICT_COP0 0x0002 /* validate all COP0 instructions */
#define MIPS3DRC_STRICT_COP1 0x0004 /* validate all COP1 instructions */ #define MIPS3DRC_STRICT_COP1 0x0004 /* validate all COP1 instructions */
@ -981,8 +982,4 @@ COMPILER-SPECIFIC OPTIONS
#define MIPS3DRC_COMPATIBLE_OPTIONS (MIPS3DRC_STRICT_VERIFY | MIPS3DRC_STRICT_COP1 | MIPS3DRC_STRICT_COP0 | MIPS3DRC_STRICT_COP2) #define MIPS3DRC_COMPATIBLE_OPTIONS (MIPS3DRC_STRICT_VERIFY | MIPS3DRC_STRICT_COP1 | MIPS3DRC_STRICT_COP0 | MIPS3DRC_STRICT_COP2)
#define MIPS3DRC_FASTEST_OPTIONS (0) #define MIPS3DRC_FASTEST_OPTIONS (0)
/* Use with STRICT_VERIFY to print debug info to console for extra validation checks */
/* Set to 1 to activate and use MIPS3DRC_STRICT_VERIFY in the drc options */
#define DEBUG_STRICT_VERIFY 0
#endif // MAME_CPU_MIPS_MIPS3_H #endif // MAME_CPU_MIPS_MIPS3_H

View File

@ -33,6 +33,11 @@
#include "cpu/drcumlsh.h" #include "cpu/drcumlsh.h"
/* Use with STRICT_VERIFY to print debug info to console for extra validation checks */
/* Set to 1 to activate and use MIPS3DRC_STRICT_VERIFY in the drc options */
#define DEBUG_STRICT_VERIFY 0
/*************************************************************************** /***************************************************************************
MACROS MACROS
***************************************************************************/ ***************************************************************************/
@ -291,7 +296,7 @@ void mips3_device::code_compile_block(uint8_t mode, offs_t pc)
{ {
compiler_state compiler = { 0 }; compiler_state compiler = { 0 };
const opcode_desc *seqhead, *seqlast; const opcode_desc *seqhead, *seqlast;
const opcode_desc* codelast; const opcode_desc *codelast;
const opcode_desc *desclist; const opcode_desc *desclist;
bool override = false; bool override = false;
@ -1109,7 +1114,7 @@ void mips3_device::generate_update_cycles(drcuml_block &block, compiler_state &c
validate a sequence of opcodes validate a sequence of opcodes
-------------------------------------------------*/ -------------------------------------------------*/
void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state &compiler, const opcode_desc *seqhead, const opcode_desc *seqlast, const opcode_desc* codelast) void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state &compiler, const opcode_desc *seqhead, const opcode_desc *seqlast, const opcode_desc *codelast)
{ {
const opcode_desc *curdesc; const opcode_desc *curdesc;
if (m_drcuml->logging()) if (m_drcuml->logging())
@ -1203,10 +1208,9 @@ void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state &
if (DEBUG_STRICT_VERIFY) if (DEBUG_STRICT_VERIFY)
{ {
// This code will do additional checks on the last instruction and last delay slot and indicate if the check failed // This code will do additional checks on the last instruction and last delay slot and indicate if the check failed
uml::code_label check_passed, check_failed, check_second; uml::code_label check_second = compiler.labelnum++;
check_second = compiler.labelnum++; uml::code_label check_failed = compiler.labelnum++;
check_failed = compiler.labelnum++; uml::code_label check_passed = compiler.labelnum++;
check_passed = compiler.labelnum++;
// Check the last instruction // Check the last instruction
if (!(codelast->flags & OPFLAG_VIRTUAL_NOOP) && codelast->physpc != seqhead->physpc) if (!(codelast->flags & OPFLAG_VIRTUAL_NOOP) && codelast->physpc != seqhead->physpc)
{ {
@ -1263,21 +1267,19 @@ void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state &
void mips3_device::generate_sequence_instruction(drcuml_block &block, compiler_state &compiler, const opcode_desc *desc) void mips3_device::generate_sequence_instruction(drcuml_block &block, compiler_state &compiler, const opcode_desc *desc)
{ {
offs_t expc;
int hotnum;
/* add an entry for the log */ /* add an entry for the log */
if (m_drcuml->logging() && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) if (m_drcuml->logging() && !(desc->flags & OPFLAG_VIRTUAL_NOOP))
log_add_disasm_comment(block, desc->pc, desc->opptr.l[0]); log_add_disasm_comment(block, desc->pc, desc->opptr.l[0]);
/* set the PC map variable */ /* set the PC map variable */
expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc; offs_t expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc;
UML_MAPVAR(block, MAPVAR_PC, expc); // mapvar PC,expc UML_MAPVAR(block, MAPVAR_PC, expc); // mapvar PC,expc
/* accumulate total cycles */ /* accumulate total cycles */
compiler.cycles += desc->cycles; compiler.cycles += desc->cycles;
/* is this a hotspot? */ /* is this a hotspot? */
for (hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++) for (int hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++)
if (m_hotspot[hotnum].pc != 0 && desc->pc == m_hotspot[hotnum].pc && desc->opptr.l[0] == m_hotspot[hotnum].opcode) if (m_hotspot[hotnum].pc != 0 && desc->pc == m_hotspot[hotnum].pc && desc->opptr.l[0] == m_hotspot[hotnum].opcode)
{ {
compiler.cycles += m_hotspot[hotnum].cycles; compiler.cycles += m_hotspot[hotnum].cycles;

View File

@ -185,20 +185,21 @@
**************************************************************************/ **************************************************************************/
#include "emu.h" #include "emu.h"
#include "audio/cage.h" #include "audio/cage.h"
#include "audio/dcs.h" #include "audio/dcs.h"
#include "machine/midwayic.h"
#include "bus/ata/idehd.h"
#include "cpu/adsp2100/adsp2100.h" #include "cpu/adsp2100/adsp2100.h"
#include "cpu/mips/mips3.h" #include "cpu/mips/mips3.h"
#include "machine/midwayic.h"
#include "machine/nvram.h"
#include "machine/smc91c9x.h"
#include "machine/pci.h"
#include "machine/gt64xxx.h" #include "machine/gt64xxx.h"
#include "machine/nvram.h"
#include "machine/pci-ide.h" #include "machine/pci-ide.h"
#include "bus/ata/idehd.h" #include "machine/pci.h"
#include "machine/smc91c9x.h"
#include "video/voodoo_pci.h" #include "video/voodoo_pci.h"
#include "screen.h" #include "screen.h"
#include "calspeed.lh" #include "calspeed.lh"
@ -445,7 +446,7 @@ private:
void carnevil_cs3_map(address_map &map); void carnevil_cs3_map(address_map &map);
void flagstaff_cs3_map(address_map &map); void flagstaff_cs3_map(address_map &map);
static void hdd_config(device_t* device); static void hdd_config(device_t *device);
}; };
/************************************* /*************************************
@ -2048,10 +2049,10 @@ void seattle_state::seattle_common(machine_config &config)
m_screen->set_screen_update(PCI_ID_VIDEO, FUNC(voodoo_1_pci_device::screen_update)); m_screen->set_screen_update(PCI_ID_VIDEO, FUNC(voodoo_1_pci_device::screen_update));
} }
void seattle_state::hdd_config(device_t* device) void seattle_state::hdd_config(device_t *device)
{ {
// Set the disk dma transfer speed // Set the disk dma transfer speed
static_cast<ide_hdd_device*>(device)->set_dma_transfer_time(attotime::from_usec(15)); dynamic_cast<ide_hdd_device *>(device)->set_dma_transfer_time(attotime::from_usec(15));
} }
void seattle_state::phoenix(machine_config &config) void seattle_state::phoenix(machine_config &config)

View File

@ -274,6 +274,7 @@
#include "emu.h" #include "emu.h"
#include "audio/dcs.h" #include "audio/dcs.h"
#include "machine/midwayic.h"
#include "bus/ata/idehd.h" #include "bus/ata/idehd.h"
#include "bus/rs232/rs232.h" #include "bus/rs232/rs232.h"
@ -282,7 +283,6 @@
#include "machine/idectrl.h" #include "machine/idectrl.h"
#include "machine/input_merger.h" #include "machine/input_merger.h"
#include "machine/ins8250.h" #include "machine/ins8250.h"
#include "machine/midwayic.h"
#include "machine/pci-ide.h" #include "machine/pci-ide.h"
#include "machine/pci.h" #include "machine/pci.h"
#include "machine/smc91c9x.h" #include "machine/smc91c9x.h"
@ -473,7 +473,7 @@ private:
void vegas_cs7_map(address_map &map); void vegas_cs7_map(address_map &map);
void vegas_cs8_map(address_map &map); void vegas_cs8_map(address_map &map);
static void hdd_config(device_t* device); static void hdd_config(device_t *device);
}; };
/************************************* /*************************************
@ -1950,12 +1950,12 @@ void vegas_state::vegascore(machine_config &config)
screen.set_screen_update(PCI_ID_VIDEO, FUNC(voodoo_pci_device::screen_update)); screen.set_screen_update(PCI_ID_VIDEO, FUNC(voodoo_pci_device::screen_update));
} }
void vegas_state::hdd_config(device_t* device) void vegas_state::hdd_config(device_t *device)
{ {
// Set the disk dma transfer speed // Set the disk dma transfer speed
static_cast<ide_hdd_device*>(device)->set_dma_transfer_time(attotime::from_usec(15)); dynamic_cast<ide_hdd_device *>(device)->set_dma_transfer_time(attotime::from_usec(15));
// Allow ultra dma // Allow ultra dma
//uint16_t *identify_device = static_cast<ide_hdd_device*>(device)->identify_device_buffer(); //uint16_t *identify_device = dynamic_cast<ide_hdd_device *>(device)->identify_device_buffer();
//identify_device[88] = 0x7f; //identify_device[88] = 0x7f;
} }