diff options
author | Rahul Joshi <rjoshi@nvidia.com> | 2025-05-01 07:45:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-01 07:45:22 -0700 |
commit | 64f552cefacbb36ccb5f6df7b57f532bb63f0006 (patch) | |
tree | 84ac9295bd98a370c46fac2fce7aa6584986e0a9 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 80233751f9f3c9c8c5b1d66cd93399615f4d3ba2 (diff) | |
download | llvm-64f552cefacbb36ccb5f6df7b57f532bb63f0006.zip llvm-64f552cefacbb36ccb5f6df7b57f532bb63f0006.tar.gz llvm-64f552cefacbb36ccb5f6df7b57f532bb63f0006.tar.bz2 |
[NFC][LLVM][CodeGen] Refactor MachineInstr operand accessors (#137261)
- Change MachineInstr operand accessors to use `ArrayRef` internally to
slice the operand array into sub-arrays.
- Minor: remove unnecessary {} on `MachineInstrBuilder::add`.
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 2bc1800..da3665b 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -821,8 +821,7 @@ unsigned MachineInstr::getNumExplicitOperands() const { if (!MCID->isVariadic()) return NumOperands; - for (unsigned I = NumOperands, E = getNumOperands(); I != E; ++I) { - const MachineOperand &MO = getOperand(I); + for (const MachineOperand &MO : operands_impl().drop_front(NumOperands)) { // The operands must always be in the following order: // - explicit reg defs, // - other explicit operands (reg uses, immediates, etc.), @@ -840,8 +839,7 @@ unsigned MachineInstr::getNumExplicitDefs() const { if (!MCID->isVariadic()) return NumDefs; - for (unsigned I = NumDefs, E = getNumOperands(); I != E; ++I) { - const MachineOperand &MO = getOperand(I); + for (const MachineOperand &MO : operands_impl().drop_front(NumDefs)) { if (!MO.isReg() || !MO.isDef() || MO.isImplicit()) break; ++NumDefs; @@ -1196,9 +1194,9 @@ void MachineInstr::tieOperands(unsigned DefIdx, unsigned UseIdx) { assert(!DefMO.isTied() && "Def is already tied to another use"); assert(!UseMO.isTied() && "Use is already tied to another def"); - if (DefIdx < TiedMax) + if (DefIdx < TiedMax) { UseMO.TiedTo = DefIdx + 1; - else { + } else { // Inline asm can use the group descriptors to find tied operands, // statepoint tied operands are trivial to match (1-1 reg def with reg use), // but on normal instruction, the tied def must be within the first TiedMax |