Add a getFirstNonPHI utility function.
authorDan Gohman <gohman@apple.com>
Wed, 7 Jul 2010 14:33:51 +0000 (14:33 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 7 Jul 2010 14:33:51 +0000 (14:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107778 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MachineBasicBlock.cpp

index dcbcb25cfb890770db0e6734d3cfbbfbad92a6d2..3cfc47ac4d8464d08470dd88d7529ddfa324e39d 100644 (file)
@@ -282,6 +282,13 @@ public:
   /// branch to do so (e.g., a table jump).  True is a conservative answer.
   bool canFallThrough();
 
+  /// Returns a pointer to the first instructon in this block that is not a 
+  /// PHINode instruction. When adding instruction to the beginning of the
+  /// basic block, they should be added before the returned value, not before
+  /// the first instruction, which might be PHI.
+  /// Returns end() is there's no non-PHI instruction.
+  iterator getFirstNonPHI();
+
   /// getFirstTerminator - returns an iterator to the first terminator
   /// instruction of this basic block. If a terminator does not exist,
   /// it returns end()
index dee478671f6094116974b5af1ef07ec23a3967f3..a27ee479433beb67f45c20e673494cf5d5e79be9 100644 (file)
@@ -139,6 +139,13 @@ void ilist_traits<MachineInstr>::deleteNode(MachineInstr* MI) {
   Parent->getParent()->DeleteMachineInstr(MI);
 }
 
+MachineBasicBlock::iterator MachineBasicBlock::getFirstNonPHI() {
+  iterator I = begin();
+  while (I != end() && I->isPHI())
+    ++I;
+  return I;
+}
+
 MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
   iterator I = end();
   while (I != begin() && (--I)->getDesc().isTerminator())