aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOperand.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2023-02-03 09:42:25 +0000
committerJay Foad <jay.foad@amd.com>2023-02-07 11:50:57 +0000
commitd170a254a53bce54596ed0f94aa86ffa3eede42b (patch)
treea910e6d7c653f66b9435f0a28d58115de4e4a472 /llvm/lib/CodeGen/MachineOperand.cpp
parent3d6b108a87cc017faf27824b82b90d9aaea707ca (diff)
downloadllvm-d170a254a53bce54596ed0f94aa86ffa3eede42b.zip
llvm-d170a254a53bce54596ed0f94aa86ffa3eede42b.tar.gz
llvm-d170a254a53bce54596ed0f94aa86ffa3eede42b.tar.bz2
[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
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOperand.cpp5
1 files changed, 5 insertions, 0 deletions
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<const MachineOperand &>(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.