BasicBlock *getPrev() { return Prev; }
const BasicBlock *getPrev() const { return Prev; }
+ /// use_back - Specialize the methods defined in Value, as we know that an
+ /// BasicBlock can only be used by Instructions (specifically PHI and terms).
+ Instruction *use_back() { return cast<Instruction>(*use_begin());}
+ const Instruction *use_back() const { return cast<Instruction>(*use_begin());}
+
/// getTerminator() - If this is a well formed basic block, then this returns
/// a pointer to the terminator instruction. If it is not, then you get a
/// null pointer back.
///
TerminatorInst *getTerminator();
const TerminatorInst *const getTerminator() const;
-
+
+ /// 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 0 is there's no non-PHI instruction.
+ Instruction* getFirstNonPHI();
+
/// removeFromParent - This method unlinks 'this' from the containing
/// function, but does not delete it.
///
///
void eraseFromParent();
- /// moveBefore - Unlink this instruction from its current function and
- /// insert it into the function that MovePos lives in, right before
- /// MovePos.
+ /// moveBefore - Unlink this basic block from its current function and
+ /// insert it into the function that MovePos lives in, right before MovePos.
void moveBefore(BasicBlock *MovePos);
+
+ /// moveAfter - Unlink this basic block from its current function and
+ /// insert it into the function that MovePos lives in, right after MovePos.
+ void moveAfter(BasicBlock *MovePos);
+
/// getSinglePredecessor - If this basic block has a single predecessor block,
/// return the block, otherwise return a null pointer.
InstListType &getInstList() { return InstList; }
virtual void print(std::ostream &OS) const { print(OS, 0); }
+ void print(std::ostream *OS) const { if (OS) print(*OS); }
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast: