From 3bb506ce0e88c0841764653f8a98e846cb0f8534 Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Fri, 1 Feb 2019 08:09:31 -0500 Subject: [PATCH] formalizing libtransform --- include/inc-transform/rewrite_util.hpp | 28 ++++++++++++++++ include/inc-transform/transform.hpp | 44 ++++++++++++++++++++++++++ include/irdb-transform | 9 ++++++ 3 files changed, 81 insertions(+) create mode 100644 include/inc-transform/rewrite_util.hpp create mode 100644 include/inc-transform/transform.hpp create mode 100644 include/irdb-transform diff --git a/include/inc-transform/rewrite_util.hpp b/include/inc-transform/rewrite_util.hpp new file mode 100644 index 0000000..c3925ef --- /dev/null +++ b/include/inc-transform/rewrite_util.hpp @@ -0,0 +1,28 @@ + +#include <irdb-core> + +namespace IRDB_SDK +{ + +using namespace std; + +Instruction_t* insertAssemblyBefore (FileIR_t* firp, Instruction_t* before, string assembly, Instruction_t *target=nullptr); +Instruction_t* insertAssemblyAfter (FileIR_t* firp, Instruction_t* after , string assembly, Instruction_t *target=nullptr); +Instruction_t* insertDataBitsBefore (FileIR_t* firp, Instruction_t* before, string dataBits, Instruction_t *target=nullptr); +Instruction_t* insertDataBitsAfter (FileIR_t* firp, Instruction_t* after , string dataBits, Instruction_t *target=nullptr); + +Instruction_t* addNewDataBits (FileIR_t* firp, string p_bits); +Instruction_t* addNewAssembly (FileIR_t* firp, string p_asm); +Instruction_t* addNewDataBits (FileIR_t* firp, Instruction_t* p_after, string p_bits); +Instruction_t* addNewAssembly (FileIR_t* firp, Instruction_t* p_after, string p_asm); + +void setInstructionAssembly( + FileIR_t* firp, + Instruction_t* instr, + const string& p_asm, + Instruction_t *p_new_fallthrough, + Instruction_t* p_new_target=nullptr); +void setInstructionAssembly(FileIR_t* firp, Instruction_t* instr, const string& p_asm); + + +} diff --git a/include/inc-transform/transform.hpp b/include/inc-transform/transform.hpp new file mode 100644 index 0000000..c03d815 --- /dev/null +++ b/include/inc-transform/transform.hpp @@ -0,0 +1,44 @@ +#include <string> +#include <set> +#include <map> +#include <irdb-core> + +namespace IRDB_SDK +{ + + using namespace std; + + class Transform + { + + public: + Transform(FileIR_t * file); + virtual ~Transform() { } + + Instruction_t* insertAssemblyBefore (Instruction_t* p_before, const string &p_asm, Instruction_t* p_targ=nullptr); + Instruction_t* insertAssemblyAfter (Instruction_t* p_after , const string &p_asm, Instruction_t* p_targ=nullptr); + Instruction_t* insertDataBitsBefore (Instruction_t* p_before, const string &p_asm, Instruction_t* p_targ=nullptr); + Instruction_t* insertDataBitsAfter (Instruction_t* p_after , const string &p_asm, Instruction_t* p_targ=nullptr); + + Instruction_t* addNewDataBits (const string& p_bits); + Instruction_t* addNewAssembly (const string& p_asm); + + void setInstructionAssembly( + Instruction_t* instr, + const string& p_asm, + Instruction_t *p_new_fallthrough, + Instruction_t* p_new_target=nullptr); + + void setInstructionAssembly(Instruction_t* instr, const string& p_asm); + + + virtual FileIR_t* getFileIR(); + + private: + + FileIR_t *m_fileIR; + }; + +} + + diff --git a/include/irdb-transform b/include/irdb-transform new file mode 100644 index 0000000..a878e56 --- /dev/null +++ b/include/irdb-transform @@ -0,0 +1,9 @@ + + +#ifndef IRDB_SDK_transform +#define IRDB_SDK_transform + +#include "inc-transform/transform.hpp" +#include "inc-transform/rewrite_util.hpp" + +#endif -- GitLab