diff options
author | Olivier Galibert <galibert@pobox.com> | 2020-12-28 12:40:22 +0100 |
---|---|---|
committer | Olivier Galibert <galibert@pobox.com> | 2020-12-28 12:40:22 +0100 |
commit | 4586e514f71321e750334f1e08e8cec3c5787aeb (patch) | |
tree | aac84c9640931b543a460d10ddaeec22200c1e55 | |
parent | 60714508334845bb4044144d0ff074d2f1463cb2 (diff) |
views: Remove the lambdas, seems to make the compiler usage resources less catastrophic
-rw-r--r-- | src/emu/emumem.h | 2 | ||||
-rw-r--r-- | src/emu/emumem_mview.cpp | 150 |
2 files changed, 78 insertions, 74 deletions
diff --git a/src/emu/emumem.h b/src/emu/emumem.h index e16e5e20858..662db2ad77d 100644 --- a/src/emu/emumem.h +++ b/src/emu/emumem.h @@ -1859,8 +1859,6 @@ private: address_space * m_space; handler_entry * m_handler_read; handler_entry * m_handler_write; - std::function<void (int)> m_select_a; - std::function<void (int)> m_select_u; int m_cur_id; int m_cur_slot; std::string m_context; diff --git a/src/emu/emumem_mview.cpp b/src/emu/emumem_mview.cpp index ac5474a925c..e8248d7727e 100644 --- a/src/emu/emumem_mview.cpp +++ b/src/emu/emumem_mview.cpp @@ -587,7 +587,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> void memory_v } // Force the slot to exist, in case the map is empty - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); // install the handlers, using the original, unadjusted memory map for(const address_map_entry &entry : map->m_entrylist) { @@ -615,14 +616,15 @@ void memory_view::register_state() { m_device.machine().save().save_item(&m_device, "view", m_name.c_str(), 0, NAME(m_cur_slot)); m_device.machine().save().save_item(&m_device, "view", m_name.c_str(), 0, NAME(m_cur_id)); - m_device.machine().save().register_postload(save_prepost_delegate(NAME([this]() { m_select_a(m_cur_id); }))); + m_device.machine().save().register_postload(save_prepost_delegate(NAME([this]() { m_handler_read->select_a(m_cur_id); m_handler_write->select_a(m_cur_id); }))); } void memory_view::disable() { m_cur_slot = -1; m_cur_id = -1; - m_select_a(-1); + m_handler_read->select_a(-1); + m_handler_write->select_a(-1); } void memory_view::select(int slot) @@ -633,7 +635,8 @@ void memory_view::select(int slot) m_cur_slot = slot; m_cur_id = i->second; - m_select_a(m_cur_id); + m_handler_read->select_a(m_cur_id); + m_handler_write->select_a(m_cur_id); } int memory_view::id_to_slot(int id) const @@ -655,78 +658,73 @@ void memory_view::initialize_from_address_map(offs_t addrstart, offs_t addrend, } namespace { - template<int HighBits, int Width, int AddrShift, endianness_t Endian> void h_make_1(address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w, std::function<void (int)> &sa, std::function<void (int)> &su) { - auto rx = new handler_entry_read_dispatch <HighBits, Width, AddrShift, Endian>(&space, view); - auto wx = new handler_entry_write_dispatch<HighBits, Width, AddrShift, Endian>(&space, view); - r = rx; - w = wx; - - sa = [rx, wx](int s) { rx->select_a(s); wx->select_a(s); }; - su = [rx, wx](int s) { rx->select_u(s); wx->select_u(s); }; + template<int HighBits, int Width, int AddrShift, endianness_t Endian> void h_make_1(address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w) { + r = new handler_entry_read_dispatch <HighBits, Width, AddrShift, Endian>(&space, view); + w = new handler_entry_write_dispatch<HighBits, Width, AddrShift, Endian>(&space, view); } - template<int Width, int AddrShift, endianness_t Endian> void h_make_2(int HighBits, address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w, std::function<void (int)> &sa, std::function<void (int)> &su) { + template<int Width, int AddrShift, endianness_t Endian> void h_make_2(int HighBits, address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w) { switch(HighBits) { - case 0: h_make_1<std::max(0, Width), Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 1: h_make_1<std::max(1, Width), Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 2: h_make_1<std::max(2, Width), Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 3: h_make_1<std::max(3, Width), Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 4: h_make_1< 4, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 5: h_make_1< 5, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 6: h_make_1< 6, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 7: h_make_1< 7, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 8: h_make_1< 8, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 9: h_make_1< 9, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 10: h_make_1<10, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 11: h_make_1<11, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 12: h_make_1<12, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 13: h_make_1<13, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 14: h_make_1<14, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 15: h_make_1<15, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 16: h_make_1<16, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 17: h_make_1<17, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 18: h_make_1<18, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 19: h_make_1<19, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 20: h_make_1<20, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 21: h_make_1<21, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 22: h_make_1<22, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 23: h_make_1<23, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 24: h_make_1<24, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 25: h_make_1<25, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 26: h_make_1<26, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 27: h_make_1<27, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 28: h_make_1<28, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 29: h_make_1<29, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 30: h_make_1<20, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 31: h_make_1<31, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; - case 32: h_make_1<32, Width, AddrShift, Endian>(space, view, r, w, sa, su); break; + case 0: h_make_1<std::max(0, Width), Width, AddrShift, Endian>(space, view, r, w); break; + case 1: h_make_1<std::max(1, Width), Width, AddrShift, Endian>(space, view, r, w); break; + case 2: h_make_1<std::max(2, Width), Width, AddrShift, Endian>(space, view, r, w); break; + case 3: h_make_1<std::max(3, Width), Width, AddrShift, Endian>(space, view, r, w); break; + case 4: h_make_1< 4, Width, AddrShift, Endian>(space, view, r, w); break; + case 5: h_make_1< 5, Width, AddrShift, Endian>(space, view, r, w); break; + case 6: h_make_1< 6, Width, AddrShift, Endian>(space, view, r, w); break; + case 7: h_make_1< 7, Width, AddrShift, Endian>(space, view, r, w); break; + case 8: h_make_1< 8, Width, AddrShift, Endian>(space, view, r, w); break; + case 9: h_make_1< 9, Width, AddrShift, Endian>(space, view, r, w); break; + case 10: h_make_1<10, Width, AddrShift, Endian>(space, view, r, w); break; + case 11: h_make_1<11, Width, AddrShift, Endian>(space, view, r, w); break; + case 12: h_make_1<12, Width, AddrShift, Endian>(space, view, r, w); break; + case 13: h_make_1<13, Width, AddrShift, Endian>(space, view, r, w); break; + case 14: h_make_1<14, Width, AddrShift, Endian>(space, view, r, w); break; + case 15: h_make_1<15, Width, AddrShift, Endian>(space, view, r, w); break; + case 16: h_make_1<16, Width, AddrShift, Endian>(space, view, r, w); break; + case 17: h_make_1<17, Width, AddrShift, Endian>(space, view, r, w); break; + case 18: h_make_1<18, Width, AddrShift, Endian>(space, view, r, w); break; + case 19: h_make_1<19, Width, AddrShift, Endian>(space, view, r, w); break; + case 20: h_make_1<20, Width, AddrShift, Endian>(space, view, r, w); break; + case 21: h_make_1<21, Width, AddrShift, Endian>(space, view, r, w); break; + case 22: h_make_1<22, Width, AddrShift, Endian>(space, view, r, w); break; + case 23: h_make_1<23, Width, AddrShift, Endian>(space, view, r, w); break; + case 24: h_make_1<24, Width, AddrShift, Endian>(space, view, r, w); break; + case 25: h_make_1<25, Width, AddrShift, Endian>(space, view, r, w); break; + case 26: h_make_1<26, Width, AddrShift, Endian>(space, view, r, w); break; + case 27: h_make_1<27, Width, AddrShift, Endian>(space, view, r, w); break; + case 28: h_make_1<28, Width, AddrShift, Endian>(space, view, r, w); break; + case 29: h_make_1<29, Width, AddrShift, Endian>(space, view, r, w); break; + case 30: h_make_1<20, Width, AddrShift, Endian>(space, view, r, w); break; + case 31: h_make_1<31, Width, AddrShift, Endian>(space, view, r, w); break; + case 32: h_make_1<32, Width, AddrShift, Endian>(space, view, r, w); break; default: abort(); } } - template<int Width, int AddrShift> void h_make_3(int HighBits, endianness_t Endian, address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w, std::function<void (int)> &sa, std::function<void (int)> &su) { + template<int Width, int AddrShift> void h_make_3(int HighBits, endianness_t Endian, address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w) { switch(Endian) { - case ENDIANNESS_LITTLE: h_make_2<Width, AddrShift, ENDIANNESS_LITTLE>(HighBits, space, view, r, w, sa, su); break; - case ENDIANNESS_BIG: h_make_2<Width, AddrShift, ENDIANNESS_BIG> (HighBits, space, view, r, w, sa, su); break; + case ENDIANNESS_LITTLE: h_make_2<Width, AddrShift, ENDIANNESS_LITTLE>(HighBits, space, view, r, w); break; + case ENDIANNESS_BIG: h_make_2<Width, AddrShift, ENDIANNESS_BIG> (HighBits, space, view, r, w); break; default: abort(); } } - void h_make(int HighBits, int Width, int AddrShift, endianness_t Endian, address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w, std::function<void (int)> &sa, std::function<void (int)> &su) { + void h_make(int HighBits, int Width, int AddrShift, endianness_t Endian, address_space &space, memory_view &view, handler_entry *&r, handler_entry *&w) { switch (Width | (AddrShift + 4)) { - case 8|(4+1): h_make_3<0, 1>(HighBits, Endian, space, view, r, w, sa, su); break; - case 8|(4-0): h_make_3<0, 0>(HighBits, Endian, space, view, r, w, sa, su); break; - case 16|(4+3): h_make_3<1, 3>(HighBits, Endian, space, view, r, w, sa, su); break; - case 16|(4-0): h_make_3<1, 0>(HighBits, Endian, space, view, r, w, sa, su); break; - case 16|(4-1): h_make_3<1, -1>(HighBits, Endian, space, view, r, w, sa, su); break; - case 32|(4+3): h_make_3<2, 3>(HighBits, Endian, space, view, r, w, sa, su); break; - case 32|(4-0): h_make_3<2, 0>(HighBits, Endian, space, view, r, w, sa, su); break; - case 32|(4-1): h_make_3<2, -1>(HighBits, Endian, space, view, r, w, sa, su); break; - case 32|(4-2): h_make_3<2, -2>(HighBits, Endian, space, view, r, w, sa, su); break; - case 64|(4-0): h_make_3<3, 0>(HighBits, Endian, space, view, r, w, sa, su); break; - case 64|(4-1): h_make_3<3, -1>(HighBits, Endian, space, view, r, w, sa, su); break; - case 64|(4-2): h_make_3<3, -2>(HighBits, Endian, space, view, r, w, sa, su); break; - case 64|(4-3): h_make_3<3, -3>(HighBits, Endian, space, view, r, w, sa, su); break; + case 8|(4+1): h_make_3<0, 1>(HighBits, Endian, space, view, r, w); break; + case 8|(4-0): h_make_3<0, 0>(HighBits, Endian, space, view, r, w); break; + case 16|(4+3): h_make_3<1, 3>(HighBits, Endian, space, view, r, w); break; + case 16|(4-0): h_make_3<1, 0>(HighBits, Endian, space, view, r, w); break; + case 16|(4-1): h_make_3<1, -1>(HighBits, Endian, space, view, r, w); break; + case 32|(4+3): h_make_3<2, 3>(HighBits, Endian, space, view, r, w); break; + case 32|(4-0): h_make_3<2, 0>(HighBits, Endian, space, view, r, w); break; + case 32|(4-1): h_make_3<2, -1>(HighBits, Endian, space, view, r, w); break; + case 32|(4-2): h_make_3<2, -2>(HighBits, Endian, space, view, r, w); break; + case 64|(4-0): h_make_3<3, 0>(HighBits, Endian, space, view, r, w); break; + case 64|(4-1): h_make_3<3, -1>(HighBits, Endian, space, view, r, w); break; + case 64|(4-2): h_make_3<3, -2>(HighBits, Endian, space, view, r, w); break; + case 64|(4-3): h_make_3<3, -3>(HighBits, Endian, space, view, r, w); break; default: abort(); } } @@ -757,7 +755,7 @@ std::pair<handler_entry *, handler_entry *> memory_view::make_handlers(address_s break; } - h_make(awidth, m_config->data_width(), m_config->addr_shift(), m_config->endianness(), space, *this, m_handler_read, m_handler_write, m_select_a, m_select_u); + h_make(awidth, m_config->data_width(), m_config->addr_shift(), m_config->endianness(), space, *this, m_handler_read, m_handler_write); } return std::make_pair(m_handler_read, m_handler_write); @@ -802,7 +800,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> void memory_v offs_t nstart, nend, nmask, nmirror; check_range_optimize_mirror("install_ram_generic", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); // map for read if (readorwrite == read_or_write::READ || readorwrite == read_or_write::READWRITE) @@ -834,7 +833,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> void memory_v offs_t nstart, nend, nmask, nmirror; check_range_optimize_mirror("unmap_generic", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); // read space if (readorwrite == read_or_write::READ || readorwrite == read_or_write::READWRITE) { @@ -858,7 +858,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> void memory_v offs_t nstart, nend, nmask, nmirror; check_range_optimize_mirror("install_view", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); auto handlers = view.make_handlers(*m_view.m_space, addrstart, addrend); r()->populate(nstart, nend, nmirror, static_cast<handler_entry_read <Width, AddrShift, Endian> *>(handlers.first)); @@ -873,7 +874,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> memory_passth if (!mph) mph = m_view.m_space->make_mph(); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); auto handler = new handler_entry_read_tap<Width, AddrShift, Endian>(m_view.m_space, *mph, name, tap); r()->populate_passthrough(nstart, nend, nmirror, handler); @@ -891,7 +893,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> memory_passth if (!mph) mph = m_view.m_space->make_mph(); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); auto handler = new handler_entry_write_tap<Width, AddrShift, Endian>(m_view.m_space, *mph, name, tap); w()->populate_passthrough(nstart, nend, nmirror, handler); @@ -909,7 +912,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> memory_passth if (!mph) mph = m_view.m_space->make_mph(); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); auto rhandler = new handler_entry_read_tap <Width, AddrShift, Endian>(m_view.m_space, *mph, name, tapr); r() ->populate_passthrough(nstart, nend, nmirror, rhandler); @@ -942,7 +946,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> void memory_v offs_t nstart, nend, nmask, nmirror; check_range_optimize_mirror("install_readwrite_port", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); // read handler if (rtag != "") @@ -981,7 +986,8 @@ template<int Level, int Width, int AddrShift, endianness_t Endian> void memory_v offs_t nstart, nend, nmask, nmirror; check_range_optimize_mirror("install_bank_generic", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror); - m_view.m_select_u(m_id); + r()->select_u(m_id); + w()->select_u(m_id); // map the read bank if (rbank != nullptr) |