From ce54579557539408e415da2da9eafaed04a8eed6 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Fri, 29 Dec 2017 22:46:00 +0100 Subject: [PATCH] -e132xs: fix botched DRC merge, nw --- scripts/src/cpu.lua | 3 ++ src/devices/cpu/e132xs/e132xs.cpp | 78 ++++++++++++++++++++++++++++++- src/devices/cpu/e132xs/e132xs.h | 2 + 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua index c5992ad7db3..1c3e33faa21 100644 --- a/scripts/src/cpu.lua +++ b/scripts/src/cpu.lua @@ -810,6 +810,9 @@ if (CPUS["E1"]~=null) then MAME_DIR .. "src/devices/cpu/e132xs/e132xs.h", MAME_DIR .. "src/devices/cpu/e132xs/32xsdefs.h", MAME_DIR .. "src/devices/cpu/e132xs/e132xsop.hxx", + MAME_DIR .. "src/devices/cpu/e132xs/e132xsfe.cpp", + MAME_DIR .. "src/devices/cpu/e132xs/e132xsdrc.cpp", + MAME_DIR .. "src/devices/cpu/e132xs/e132xsdrc_ops.hxx", } end diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index 056b7dfad4f..f7d024a5665 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -682,7 +682,7 @@ do if (m_delay_slot) \ { \ PC = m_delay_pc; \ - m_delay_slot = 0; \ + m_delay_slot = 0; \ } \ } while (0) @@ -1094,7 +1094,11 @@ void hyperstone_device::device_start() void hyperstone_device::init(int scale_mask) { +#if ENABLE_E132XS_DRC m_enable_drc = allow_drc(); +#else + m_enable_drc = false; +#endif #if E132XS_LOG_DRC_REGS || E132XS_LOG_INTERPRETER_REGS if (m_enable_drc) @@ -1103,6 +1107,7 @@ void hyperstone_device::init(int scale_mask) m_trace_log = fopen("e1_interpreter.log", "wb"); #endif + memset(m_op_counts, 0, sizeof(uint32_t) * 256); memset(m_global_regs, 0, sizeof(uint32_t) * 32); memset(m_local_regs, 0, sizeof(uint32_t) * 64); m_op = 0; @@ -1139,6 +1144,38 @@ void hyperstone_device::init(int scale_mask) m_fl_lut[i] = (i ? i : 16); } + uint32_t umlflags = 0; + m_drcuml = std::make_unique(*this, m_cache, umlflags, 1, 32, 1); + + // add UML symbols- + m_drcuml->symbol_add(&m_global_regs[0], sizeof(uint32_t), "pc"); + m_drcuml->symbol_add(&m_global_regs[1], sizeof(uint32_t), "sr"); + m_drcuml->symbol_add(&m_icount, sizeof(m_icount), "icount"); + + char buf[4]; + for (int i=0; i < 32; i++) + { + sprintf(buf, "g%d", i); + m_drcuml->symbol_add(&m_global_regs[i], sizeof(uint32_t), buf); + } + + for (int i=0; i < 64; i++) + { + sprintf(buf, "l%d", i); + m_drcuml->symbol_add(&m_local_regs[i], sizeof(uint32_t), buf); + } + + m_drcuml->symbol_add(&m_drc_arg0, sizeof(uint32_t), "arg0"); + m_drcuml->symbol_add(&m_drc_arg1, sizeof(uint32_t), "arg1"); + m_drcuml->symbol_add(&m_drc_arg2, sizeof(uint32_t), "arg2"); + m_drcuml->symbol_add(&m_drc_arg3, sizeof(uint32_t), "arg3"); + + /* initialize the front-end helper */ + m_drcfe = std::make_unique(this, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE); + + /* mark the cache dirty so it is updated on next execute */ + m_cache_dirty = true; + // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_global_regs[0]).noshow(); state_add(STATE_GENPCBASE, "CURPC", m_global_regs[0]).noshow(); @@ -1412,6 +1449,34 @@ void hyperstone_device::device_stop() #if E132XS_LOG_DRC_REGS || E132XS_LOG_INTERPRETER_REGS fclose(m_trace_log); #endif +#if E132XS_COUNT_INSTRUCTIONS + uint32_t indices[256]; + for (uint32_t i = 0; i < 256; i++) + indices[i] = i; + for (uint32_t i = 0; i < 256; i++) + { + for (uint32_t j = 0; j < 256; j++) + { + if (m_op_counts[j] < m_op_counts[i]) + { + uint32_t temp = m_op_counts[i]; + m_op_counts[i] = m_op_counts[j]; + m_op_counts[j] = temp; + + temp = indices[i]; + indices[i] = indices[j]; + indices[j] = temp; + } + } + } + for (uint32_t i = 0; i < 256; i++) + { + if (m_op_counts[i] != 0) + { + printf("%02x: %d\n", (uint8_t)indices[i], m_op_counts[i]); + } + } +#endif } @@ -1578,6 +1643,12 @@ void hyperstone_device::hyperstone_do() void hyperstone_device::execute_run() { + if (m_enable_drc) + { + execute_run_drc(); + return; + } + if (m_intblock < 0) m_intblock = 0; @@ -1599,6 +1670,9 @@ void hyperstone_device::execute_run() m_instruction_length = (1<<19); +#if E132XS_COUNT_INSTRUCTIONS + m_op_counts[m_op >> 8]++; +#endif switch (m_op >> 8) { case 0x00: hyperstone_chk(); break; @@ -1891,4 +1965,4 @@ DEFINE_DEVICE_TYPE(E132XSR, e132xsr_device, "e132xsr", "E1-32XSR") DEFINE_DEVICE_TYPE(GMS30C2116, gms30c2116_device, "gms30c2116", "GMS30C2116") DEFINE_DEVICE_TYPE(GMS30C2132, gms30c2132_device, "gms30c2132", "GMS30C2132") DEFINE_DEVICE_TYPE(GMS30C2216, gms30c2216_device, "gms30c2216", "GMS30C2216") -DEFINE_DEVICE_TYPE(GMS30C2232, gms30c2232_device, "gms30c2232", "GMS30C2232") +DEFINE_DEVICE_TYPE(GMS30C2232, gms30c2232_device, "gms30c2232", "GMS30C2232") \ No newline at end of file diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index 75825d2a305..ed9d385cab1 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -54,6 +54,7 @@ #define E132XS_LOG_DRC_REGS (0) #define E132XS_LOG_INTERPRETER_REGS (0) +#define E132XS_COUNT_INSTRUCTIONS (0) //************************************************************************** // TYPE DEFINITIONS @@ -292,6 +293,7 @@ protected: static const uint32_t s_trap_entries[8]; static const int32_t s_immediate_values[16]; + uint32_t m_op_counts[256]; uint32_t get_trap_addr(uint8_t trapno); private: