diff options
author | 2020-05-25 16:42:42 +0200 | |
---|---|---|
committer | 2020-05-25 16:42:57 +0200 | |
commit | 22513fb6fe281f5ccb75aaddb6417a12a66c313d (patch) | |
tree | 3cf84032cc6482d685a8dbb57e015bd17c7f7fdc /src/devices/cpu/asap | |
parent | e42c2d2874cf9c1092c01ab5ce9ef997d465ce25 (diff) |
emumem: A little more speedup. cache and specific change syntax, and are not pointers anymore [O. Galibert]
The last(?) two changes are:
- Add a template parameter to everything (theoretically the address
space width, in practice a level derived from it to keep as much
compatibility between widths as possible) so that the shift size
becomes a constant.
- Change the syntax of declaring and initializing the caches and
specifics so that they're embedded in the owner device. Solves
lifetime issues and also removes one indirection (looking up the base
dispatch pointer through the cache/specific pointer).
Diffstat (limited to 'src/devices/cpu/asap')
-rw-r--r-- | src/devices/cpu/asap/asap.cpp | 40 | ||||
-rw-r--r-- | src/devices/cpu/asap/asap.h | 4 |
2 files changed, 21 insertions, 23 deletions
diff --git a/src/devices/cpu/asap/asap.cpp b/src/devices/cpu/asap/asap.cpp index 4b2505d847a..9df9049d5ba 100644 --- a/src/devices/cpu/asap/asap.cpp +++ b/src/devices/cpu/asap/asap.cpp @@ -151,9 +151,7 @@ asap_device::asap_device(const machine_config &mconfig, const char *tag, device_ m_ppc(0), m_nextpc(0), m_irq_state(0), - m_icount(0), - m_program(nullptr), - m_cache(nullptr) + m_icount(0) { // initialize the src2val table to contain immediates for low values for (int i = 0; i < REGBASE; i++) @@ -183,8 +181,8 @@ asap_device::asap_device(const machine_config &mconfig, const char *tag, device_ void asap_device::device_start() { // get our address spaces - m_program = &space(AS_PROGRAM); - m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + space(AS_PROGRAM).cache(m_cache); + space(AS_PROGRAM).specific(m_program); // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_pc).noshow(); @@ -321,7 +319,7 @@ std::unique_ptr<util::disasm_interface> asap_device::create_disassembler() inline uint32_t asap_device::readop(offs_t pc) { - return m_cache->read_dword(pc); + return m_cache.read_dword(pc); } @@ -332,7 +330,7 @@ inline uint32_t asap_device::readop(offs_t pc) inline uint8_t asap_device::readbyte(offs_t address) { // no alignment issues with bytes - return m_program->read_byte(address); + return m_program.read_byte(address); } @@ -344,10 +342,10 @@ inline uint16_t asap_device::readword(offs_t address) { // aligned reads are easy if (WORD_ALIGNED(address)) - return m_program->read_word(address); + return m_program.read_word(address); // misaligned reads are tricky - return m_program->read_dword(address & ~3) >> (address & 3); + return m_program.read_dword(address & ~3) >> (address & 3); } @@ -359,10 +357,10 @@ inline uint32_t asap_device::readlong(offs_t address) { // aligned reads are easy if (DWORD_ALIGNED(address)) - return m_program->read_dword(address); + return m_program.read_dword(address); // misaligned reads are tricky - return m_program->read_dword(address & ~3) >> (address & 3); + return m_program.read_dword(address & ~3) >> (address & 3); } @@ -373,7 +371,7 @@ inline uint32_t asap_device::readlong(offs_t address) inline void asap_device::writebyte(offs_t address, uint8_t data) { // no alignment issues with bytes - m_program->write_byte(address, data); + m_program.write_byte(address, data); } @@ -386,18 +384,18 @@ inline void asap_device::writeword(offs_t address, uint16_t data) // aligned writes are easy if (WORD_ALIGNED(address)) { - m_program->write_word(address, data); + m_program.write_word(address, data); return; } // misaligned writes are tricky if (!(address & 2)) { - m_program->write_byte(address + 1, data); - m_program->write_byte(address + 2, data >> 8); + m_program.write_byte(address + 1, data); + m_program.write_byte(address + 2, data >> 8); } else - m_program->write_byte(address + 1, data); + m_program.write_byte(address + 1, data); } @@ -410,7 +408,7 @@ inline void asap_device::writelong(offs_t address, uint32_t data) // aligned writes are easy if (DWORD_ALIGNED(address)) { - m_program->write_dword(address, data); + m_program.write_dword(address, data); return; } @@ -418,14 +416,14 @@ inline void asap_device::writelong(offs_t address, uint32_t data) switch (address & 3) { case 1: - m_program->write_byte(address, data); - m_program->write_word(address + 1, data >> 8); + m_program.write_byte(address, data); + m_program.write_word(address + 1, data >> 8); break; case 2: - m_program->write_word(address, data); + m_program.write_word(address, data); break; case 3: - m_program->write_byte(address, data); + m_program.write_byte(address, data); break; } } diff --git a/src/devices/cpu/asap/asap.h b/src/devices/cpu/asap/asap.h index fe14835f247..3adb9ef37f4 100644 --- a/src/devices/cpu/asap/asap.h +++ b/src/devices/cpu/asap/asap.h @@ -237,8 +237,8 @@ protected: uint32_t m_nextpc; uint8_t m_irq_state; int m_icount; - address_space * m_program; - memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; + memory_access<32, 2, 0, ENDIANNESS_LITTLE>::cache m_cache; + memory_access<32, 2, 0, ENDIANNESS_LITTLE>::specific m_program; // src2val table, registers are at the end uint32_t m_src2val[65536]; |