Skip to content
Snippets Groups Projects
Commit 71c3b1b2 authored by whh8b's avatar whh8b
Browse files

Track fallback dollops.

parent acccedee
No related branches found
No related tags found
No related merge requests found
......@@ -36,12 +36,25 @@
class ZiprDollopManager_t : public DollopManager_t {
public:
ZiprDollopManager_t() : m_refresh_stats(true) {}
/*
* Adders.
*/
void AddDollops(Dollop_t *dollop_head);
Zipr_SDK::Dollop_t *AddNewDollops(libIRDB::Instruction_t *start);
/*
* Getters.
*/
Zipr_SDK::Dollop_t *GetContainingDollop(libIRDB::Instruction_t *insn);
size_t Size() {
return m_dollops.size();
}
/*
* Patch functions.
*/
void AddDollopPatch(Zipr_SDK::DollopPatch_t *new_patch) {
m_patches_to_dollops[new_patch->Target()].push_back(new_patch);
}
......@@ -53,29 +66,51 @@ class ZiprDollopManager_t : public DollopManager_t {
*/
return m_patches_to_dollops.at(target);
}
void PrintDollopPatches(const std::ostream &);
/*
* Dollop target update functions.
*/
bool UpdateTargets(Dollop_t *);
void UpdateAllTargets();
/*
* Iteration functions.
*/
std::list<Dollop_t*>::const_iterator dollops_begin() {
return m_dollops.begin();
}
std::list<Dollop_t*>::const_iterator dollops_end() {
return m_dollops.end();
}
friend std::ostream &operator<<(std::ostream &out, const ZiprDollopManager_t &dollop_man);
/*
* Printing/output functions.
*/
void PrintDollopPatches(const std::ostream &);
friend std::ostream &operator<<(std::ostream &out,
const ZiprDollopManager_t &dollop_man);
void PrintStats(std::ostream &out);
void PrintPlacementMap(const MemorySpace_t &memory_space,
const std::string &map_filename);
private:
/*
* Helper functions.
*/
void AddDollop(Dollop_t *dollop);
void CalculateStats();
/*
* Support variables.
*/
std::list<Dollop_t*> m_dollops;
std::map<libIRDB::Instruction_t*,Dollop_t*> m_insn_to_dollop;
std::list<DollopPatch_t*> m_patches;
std::map<Dollop_t*, std::list<DollopPatch_t*>> m_patches_to_dollops;
bool m_refresh_stats;
/*
* Statistics.
*/
bool m_refresh_stats;
size_t m_total_dollop_space, m_total_dollop_entries;
unsigned int m_total_dollops, m_truncated_dollops;
};
......
......@@ -7,6 +7,7 @@ namespace Zipr_SDK {
Dollop_t::Dollop_t(Instruction_t *start) :
m_size(0),
m_fallthrough_dollop(NULL),
m_fallback_dollop(NULL),
m_fallthrough_patched(false),
m_coalesced(false),
m_was_truncated(false)
......@@ -96,6 +97,18 @@ namespace Zipr_SDK {
new_dollop = new Dollop_t();
/*
* Set fallthrough and fallback dollop pointers.
* ----- ----
* | | | |
* this - new - fallthrough
* |
* |-----
*/
if (m_fallthrough_dollop)
m_fallthrough_dollop->FallbackDollop(new_dollop);
new_dollop->FallbackDollop(this);
new_dollop->FallthroughDollop(m_fallthrough_dollop);
m_fallthrough_dollop = new_dollop;
......@@ -162,13 +175,15 @@ namespace Zipr_SDK {
}
std::ostream &operator<<(std::ostream &out, const Dollop_t &d) {
std::list<DollopEntry_t*>::const_iterator it, it_end;
Dollop_t *fallthrough = NULL;
Dollop_t *fallthrough = NULL, *fallback = NULL;
for (it = d.begin(), it_end = d.end();
it != it_end;
it++) {
out << std::hex << *(*it) << std::endl;
}
if ((fallback = d.FallbackDollop()) != NULL)
out << "Fallback: " << std::hex << fallback << std::endl;
if ((fallthrough = d.FallthroughDollop()) != NULL)
out << "Fallthrough: " << std::hex << fallthrough << std::endl;
return out;
......
......@@ -73,6 +73,7 @@ namespace zipr {
* the updated fallthrough dollop!
*/
new_dollop->FallthroughDollop(fallthrough_dollop);
fallthrough_dollop->FallbackDollop(new_dollop);
/*
* Delete the overlapping instructions.
......@@ -116,6 +117,7 @@ namespace zipr {
{
assert(existing_dollop->front()->Instruction() == fallthrough);
new_dollop->FallthroughDollop(existing_dollop);
existing_dollop->FallbackDollop(new_dollop);
break;
}
/*
......@@ -125,6 +127,7 @@ namespace zipr {
previous_dollop = new_dollop;
new_dollop = Dollop_t::CreateNewDollop(fallthrough);
previous_dollop->FallthroughDollop(new_dollop);
new_dollop->FallbackDollop(previous_dollop);
}
AddDollops(original_new_dollop);
return original_new_dollop;
......
......@@ -180,7 +180,9 @@ bool TestAddNewDollopSplitsExistingDollop(void) {
return success &&
a->GetDollopEntryCount() == 2 &&
b->GetDollopEntryCount() == 2 &&
dollop_man.Size() == 2;
dollop_man.Size() == 2 &&
a->FallthroughDollop() == b &&
b->FallbackDollop() == a;
}
bool TestUpdateTargetsDollopManager(void) {
......@@ -349,7 +351,8 @@ bool TestDollopSplit(void) {
cout << "Dollop B: " << endl;
cout << *b << endl;
return a->GetDollopEntryCount() == 1 && b->GetDollopEntryCount() == 4;
return a->GetDollopEntryCount() == 1 && b->GetDollopEntryCount() == 4 &&
a->FallthroughDollop() == b && b->FallbackDollop() == a;
}
bool TestDollopEntryEquals(void) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment