From 961ad7e2171b4470e6675a592a5c4f48996d83ef Mon Sep 17 00:00:00 2001 From: whh8b <whh8b@git.zephyr-software.com> Date: Sun, 10 Jan 2016 21:17:34 +0000 Subject: [PATCH] Give another parameter to AddressDollop Give the source address for the instruction that is targeting the dollop to be placed. This will give another signal to placement plugins to help them make a decision. --- include/plugin_man.h | 2 +- src/plugin_man.cpp | 4 ++-- src/zipr.cpp | 20 +++++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/plugin_man.h b/include/plugin_man.h index c167f0b53..0b6cef846 100644 --- a/include/plugin_man.h +++ b/include/plugin_man.h @@ -42,7 +42,7 @@ class ZiprPluginManager_t : public ZiprPluginInterface_t virtual bool DoesPluginPlop(libIRDB::Instruction_t*,DLFunctionHandle_t&); - virtual bool DoesPluginAddress(const Dollop_t *, Range_t &, DLFunctionHandle_t &); + virtual bool DoesPluginAddress(const Dollop_t *, const RangeAddress_t &, Range_t &, DLFunctionHandle_t &); private: void open_plugins diff --git a/src/plugin_man.cpp b/src/plugin_man.cpp index 7b39dae2d..08b4ddbdc 100644 --- a/src/plugin_man.cpp +++ b/src/plugin_man.cpp @@ -81,13 +81,13 @@ void ZiprPluginManager_t::CallbackLinkingEnd() dispatch_to(CallbackLinkingEnd); } -bool ZiprPluginManager_t::DoesPluginAddress(const Dollop_t *dollop, Range_t &place, DLFunctionHandle_t &placer) +bool ZiprPluginManager_t::DoesPluginAddress(const Dollop_t *dollop, const RangeAddress_t &source, Range_t &place, DLFunctionHandle_t &placer) { DLFunctionHandleSet_t::iterator it=m_handleList.begin(); for(m_handleList.begin();it!=m_handleList.end();++it) { ZiprPluginInterface_t* zpi=(ZiprPluginInterface_t*)*it; - if (Must == zpi->AddressDollop(dollop, place)) + if (Must == zpi->AddressDollop(dollop, source, place)) { placer = zpi; return true; diff --git a/src/zipr.cpp b/src/zipr.cpp index 5a516d9cf..ed9bfa831 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -1325,7 +1325,7 @@ void ZiprImpl_t::WriteDollops() void ZiprImpl_t::PlaceDollops() { - list<Dollop_t*> placement_queue; + list<pair<Dollop_t*, RangeAddress_t>> placement_queue; multimap<const UnresolvedUnpinned_t,Patch_t>::const_iterator pin_it, pin_it_end; /* @@ -1344,12 +1344,14 @@ void ZiprImpl_t::PlaceDollops() target_dollop = m_dollop_mgr.GetContainingDollop(target_insn); assert(target_dollop); - placement_queue.push_back(target_dollop); + placement_queue.push_back(pair<Dollop_t*,RangeAddress_t>(target_dollop,0)); } while (!placement_queue.empty()) { + pair<Dollop_t*, RangeAddress_t> pq_entry; Dollop_t *to_place = NULL; + RangeAddress_t from_address; size_t minimum_valid_req_size = 0; Range_t placement; DLFunctionHandle_t placer = NULL; @@ -1359,9 +1361,12 @@ void ZiprImpl_t::PlaceDollops() bool has_fallthrough = false; Dollop_t *fallthrough = NULL; - to_place = placement_queue.front(); + pq_entry = placement_queue.front(); placement_queue.pop_front(); + to_place = pq_entry.first; + from_address = pq_entry.second; + if (to_place->IsPlaced()) continue; @@ -1373,6 +1378,7 @@ void ZiprImpl_t::PlaceDollops() * that want to tell us where to place this dollop. */ if (plugman.DoesPluginAddress(to_place, + from_address, placement, placer)) { @@ -1461,7 +1467,9 @@ void ZiprImpl_t::PlaceDollops() if (m_verbose) cout << "Adding " << std::hex << dollop_entry->TargetDollop() << " to placement queue." << endl; - placement_queue.push_back(dollop_entry->TargetDollop()); + placement_queue.push_back(pair<Dollop_t*, RangeAddress_t>( + dollop_entry->TargetDollop(), + cur_addr)); } } else @@ -1514,7 +1522,9 @@ void ZiprImpl_t::PlaceDollops() << fallthrough << ")." << endl; } - placement_queue.push_back(fallthrough); + placement_queue.push_back(pair<Dollop_t*, RangeAddress_t>( + fallthrough, + cur_addr)); } /* -- GitLab