diff --git a/include/inc-transform/rewrite_util.hpp b/include/inc-transform/rewrite_util.hpp index 3ea2dacf5ad44c9caf840033f1bad8ea5023b493..0efc6e042a9c1291af62d57583d1b9a5a33467dc 100644 --- a/include/inc-transform/rewrite_util.hpp +++ b/include/inc-transform/rewrite_util.hpp @@ -25,28 +25,30 @@ namespace IRDB_SDK extern Instruction_t* insertAssemblyBefore (FileIR_t* firp, Instruction_t* before, string assembly, Instruction_t *target=nullptr); extern Instruction_t* insertAssemblyAfter (FileIR_t* firp, Instruction_t* after , string assembly, Instruction_t *target=nullptr); /* - * The insertAssemblyInstructionsBefore function takes in a group of (semicolon-seperated) assembly statements and inserts them into the + * The insertAssemblyInstructionsBefore function takes in a group of (semicolon/newline-seperated) assembly statements and other template parameters, and insert them into the * program before the "before" instruction. * Param: firp -- The current FileIR_t object * before -- The instruction that the new instructions will be inserted before - * instructions -- The assembly to be inserted. Typical assembly formatting applies: instructions + * templateins -- The assembly template to be inserted. Typical assembly formatting applies: instructions * start on new lines, defined labels are allowed. For x86, the format must be in NASM style assembly. + * templateParams -- The template arguments to be substituted into the template string. * Returns: A vector of the newly inserted instructions. * Side Effect: The new instructions are inserted into the IRDB data structures. */ - extern std::vector<Instruction_t*> insertAssemblyInstructionsBefore (FileIR_t* firp, Instruction_t* before, string instructions, Instruction_t *target=nullptr); + extern std::vector<Instruction_t*> insertAssemblyInstructionsBefore (FileIR_t* firp, Instruction_t* before, string templateIns, vector<string> templateParams); /* - * The insertAssemblyInstructionsAfter function takes in a group of (semicolon-seperated) assembly statements and inserts them into the + * The insertAssemblyInstructionsAfter function takes in a group of (semicolon/newline-seperated) assembly statements and other template parameters, and insert them into the * program after the "after" instruction. * Param: firp -- The current FileIR_t object * after -- The instruction that the new instructions will be inserted after - * instructions -- The assembly to be inserted. Typical assembly formatting applies: instructions + * templateins -- The assembly template to be inserted. Typical assembly formatting applies: instructions * start on new lines, defined labels are allowed. For x86, the format must be in NASM style assembly. + * templateParams -- The template arguments to be substituted into the template string. * Returns: A vector of the newly inserted instructions. * Side Effect: The new instructions are inserted into the IRDB data structures. */ - extern std::vector<Instruction_t*> insertAssemblyInstructionsAfter (FileIR_t* firp, Instruction_t* after , string instructions, Instruction_t *target=nullptr); + extern std::vector<Instruction_t*> insertAssemblyInstructionsAfter (FileIR_t* firp, Instruction_t* after , string templateIns, vector<string> templateParams); extern Instruction_t* insertDataBitsBefore (FileIR_t* firp, Instruction_t* before, string dataBits, Instruction_t *target=nullptr); extern Instruction_t* insertDataBitsAfter (FileIR_t* firp, Instruction_t* after , string dataBits, Instruction_t *target=nullptr); diff --git a/include/inc-transform/transform.hpp b/include/inc-transform/transform.hpp index 7523a5f51ec8f93b6753196ce967ba61f933f161..2af180f4e9133b221c4b4a387eb638eb98e35ded 100644 --- a/include/inc-transform/transform.hpp +++ b/include/inc-transform/transform.hpp @@ -36,6 +36,8 @@ namespace IRDB_SDK 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); + vector<Instruction_t*> insertAssemblyInstructionsBefore(Instruction_t* before, string templateIns, vector<string> templateParams); + vector<Instruction_t*> insertAssemblyInstructionsAfter(Instruction_t* after, string templateIns, vector<string> templateParams); Instruction_t* addNewDataBits (const string& p_bits); Instruction_t* addNewAssembly (const string& p_asm);