From d170a254a53bce54596ed0f94aa86ffa3eede42b Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Fri, 3 Feb 2023 09:42:25 +0000 Subject: [CodeGen] Define and use MachineOperand::getOperandNo This is a helper function to very slightly simplify many calls to MachineInstruction::getOperandNo. Differential Revision: https://reviews.llvm.org/D143250 --- llvm/lib/CodeGen/MachineOperand.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/CodeGen/MachineOperand.cpp') diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index 0a7b12e..1178a93 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -53,6 +53,11 @@ static MachineFunction *getMFIfAvailable(MachineOperand &MO) { getMFIfAvailable(const_cast(MO))); } +unsigned MachineOperand::getOperandNo() const { + assert(getParent() && "Operand does not belong to any instruction!"); + return getParent()->getOperandNo(this); +} + void MachineOperand::setReg(Register Reg) { if (getReg() == Reg) return; // No change. -- cgit v1.1