[PATCH 1/6] add insert_last_instruction()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's relatively common to have to add an instruction at the end of a BB.
More exactly, at the end but just before the terminator instruction.
What is done for this is:
1) remove the terminator
2) add the new instruction
3) add the terminator back

This is a bit tedious, need to declare a temporary variable for the
terminator and, more generally, it's low-level details.

So, add an helper for doing this: insert_last_instruction().

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 linearize.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/linearize.h b/linearize.h
index b6c8bf134065..493f6be1074c 100644
--- a/linearize.h
+++ b/linearize.h
@@ -195,6 +195,14 @@ static inline void add_instruction(struct instruction_list **list, struct instru
 	add_ptr_list(list, insn);
 }
 
+static inline void insert_last_instruction(struct basic_block *bb, struct instruction *insn)
+{
+	struct instruction *last = delete_last_instruction(&bb->insns);
+	add_instruction(&bb->insns, insn);
+	add_instruction(&bb->insns, last);
+	insn->bb = bb;
+}
+
 static inline void add_multijmp(struct multijmp_list **list, struct multijmp *multijmp)
 {
 	add_ptr_list(list, multijmp);
-- 
2.31.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux