add some helper methods for IR passes to use.

Swift SVN r6407
This commit is contained in:
Chris Lattner
2013-07-20 01:36:46 +00:00
parent 1c02badc38
commit f8c8eb1037
2 changed files with 17 additions and 1 deletions

View File

@@ -120,6 +120,13 @@ ArrayRef<Operand> SILInstruction::getAllOperands() const {
return AllOperandsAccessor().visit(const_cast<SILInstruction*>(this));
}
/// getOperandNumber - Return which operand this is in the operand list of the
/// using instruction.
unsigned Operand::getOperandNumber() const {
return this - &cast<SILInstruction>(getUser())->getAllOperands()[0];
}
//===----------------------------------------------------------------------===//
// SILInstruction Subclasses
//===----------------------------------------------------------------------===//