Skip to content
Snippets Groups Projects
Commit 5343f1a0 authored by whh8b's avatar whh8b
Browse files

Merge dollops refactor branch.

parents ab76a5ae 4e5c62ae
No related branches found
No related tags found
No related merge requests found
......@@ -31,16 +31,92 @@
#ifndef dollop_h
#define dollop_h
#include <assert.h>
#include <list>
namespace Zipr_SDK
{
class Dollop_t {
class Placeable_t {
public:
Placeable_t() : m_is_placed(false), m_placed_address(0) {}
void Place(Zipr_SDK::RangeAddress_t place) {
assert(!m_is_placed);
m_is_placed = true;
m_placed_address = place;
};
Zipr_SDK::RangeAddress_t Place() { return m_placed_address; }
bool IsPlaced() const { return m_is_placed; }
friend std::ostream &operator<<(std::ostream &, const Placeable_t &);
protected:
bool m_is_placed;
Zipr_SDK::RangeAddress_t m_placed_address;
};
class Dollop_t;
class DollopPatch_t : public Placeable_t {
public:
DollopPatch_t(Dollop_t *target) : m_target(target) {};
DollopPatch_t() : m_target(NULL) { };
Dollop_t *Target() const { return m_target; }
void Target(Dollop_t *target) { m_target = target; }
friend std::ostream &operator<<(std::ostream &, const DollopPatch_t &);
private:
Dollop_t *m_target;
};
class DollopEntry_t : public Placeable_t {
public:
DollopEntry_t(libIRDB::Instruction_t *insn, Dollop_t *member_of);
libIRDB::Instruction_t *Instruction() const { return m_instruction; }
void TargetDollop(Dollop_t *target) { m_target_dollop = target; }
Dollop_t *TargetDollop() const { return m_target_dollop; }
Dollop_t *MemberOfDollop() const { return m_member_of_dollop; }
void MemberOfDollop(Dollop_t *member_of) { m_member_of_dollop = member_of; }
bool operator==(const DollopEntry_t &);
bool operator!=(const DollopEntry_t &);
friend std::ostream &operator<<(std::ostream &, const DollopEntry_t &);
private:
libIRDB::Instruction_t *m_instruction;
Dollop_t *m_target_dollop, *m_member_of_dollop;
};
class Dollop_t : public Placeable_t, public std::list<DollopEntry_t*> {
public:
static Dollop_t *CreateNewDollop(libIRDB::Instruction_t *start);
Dollop_t(libIRDB::Instruction_t *start);
size_t GetSize() const { return m_size; }
Dollop_t() { m_size = 0; m_was_truncated = false; }
size_t GetSize() const {
return m_size;
}
size_t GetDollopEntryCount() const {
return size();
}
Dollop_t *Split(libIRDB::Instruction_t *split_point);
friend std::ostream &operator<<(std::ostream &, const Dollop_t &);
void FallthroughDollop(Dollop_t *fallthrough) {
m_fallthrough_dollop = fallthrough;
}
Dollop_t *FallthroughDollop(void) const { return m_fallthrough_dollop; }
DollopEntry_t *FallthroughDollopEntry(DollopEntry_t *) const;
void WasTruncated(bool truncated) { m_was_truncated = truncated; }
bool WasTruncated(void) const { return m_was_truncated; }
private:
size_t CalculateWorstCaseSize();
size_t m_size;
libIRDB::Instruction_t *m_start;
Dollop_t *m_fallthrough_dollop;
bool m_was_truncated;
};
}
#endif
......@@ -50,10 +50,12 @@ class Zipr_t
virtual void PreReserve2ByteJumpTargets() = 0;
virtual void ExpandPinnedInstructions() = 0;
virtual void Fix2BytePinnedInstructions() = 0;
virtual void CreateDollops() = 0;
virtual void PlaceDollops() = 0;
virtual void WriteDollops() = 0;
virtual void UpdatePins() = 0;
virtual void OptimizePinnedInstructions() = 0;
virtual void OptimizePinnedFallthroughs() = 0;
virtual void AskPluginsAboutPlopping() = 0;
virtual void PlopTheUnpinnedInstructions() = 0;
virtual void UpdateCallbacks() = 0;
virtual void PrintStats() = 0;
virtual void RecordPinnedInsnAddrs() = 0;
......@@ -63,10 +65,23 @@ class Zipr_t
* These are public functions that the SDK user
* way want to use.
*/
virtual int DetermineWorstCaseInsnSize(libIRDB::Instruction_t*) = 0;
virtual Zipr_SDK::RangeAddress_t PlopInstruction(libIRDB::Instruction_t* insn, Zipr_SDK::RangeAddress_t addr) = 0;
virtual Zipr_SDK::RangeAddress_t PlopWithTarget(libIRDB::Instruction_t* insn, Zipr_SDK::RangeAddress_t at) = 0;
virtual Zipr_SDK::RangeAddress_t PlopWithCallback(libIRDB::Instruction_t* insn, Zipr_SDK::RangeAddress_t at) = 0;
virtual int DetermineWorstCaseInsnSize(libIRDB::Instruction_t*, bool account_for_jump = true) = 0;
virtual Zipr_SDK::RangeAddress_t PlopDollopEntry(
DollopEntry_t *,
RangeAddress_t = 0)
= 0;
virtual Zipr_SDK::RangeAddress_t PlopDollopEntryWithTarget(
DollopEntry_t *,
RangeAddress_t = 0)
= 0;
virtual Zipr_SDK::RangeAddress_t PlopDollopEntryWithCallback(
DollopEntry_t *,
RangeAddress_t = 0)
= 0;
virtual Zipr_SDK::MemorySpace_t *GetMemorySpace()=0;
virtual ELFIO::elfio *GetELFIO()=0;
virtual libIRDB::FileIR_t *GetFileIR()=0;
......
......@@ -31,8 +31,7 @@ class ZiprPluginInterface_t
{
}
virtual ZiprPreference PlopAddress(
const RangeAddress_t &jump, const Dollop_t &dollop, Range_t &place)
virtual ZiprPreference AddressDollop(const Dollop_t *dollop, const RangeAddress_t &source, Range_t &place)
{
return None;
}
......@@ -41,12 +40,11 @@ class ZiprPluginInterface_t
{
return false;
}
virtual size_t WorstCaseInsnSize(libIRDB::Instruction_t*, Zipr_t *)
virtual size_t WorstCaseInsnSize(libIRDB::Instruction_t*, bool, Zipr_t *)
{
return 0;
}
virtual RangeAddress_t PlopInstruction(libIRDB::Instruction_t*,
RangeAddress_t,
virtual RangeAddress_t PlopDollopEntry(Zipr_SDK::DollopEntry_t *,
RangeAddress_t &,
Zipr_t *)
{
......
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