aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2023-01-11 12:20:02 +0000
committerJay Foad <jay.foad@amd.com>2023-01-23 14:44:58 +0000
commit073401e59c8c0e03e06be1d516fe8ea821146d2f (patch)
treee7ef611b9a28d76fa4b4031c49fc97113848bfd6 /llvm/lib/CodeGen/MachineInstr.cpp
parent959caaaa7b2954ccc16f60b05d998e336bf36b38 (diff)
downloadllvm-073401e59c8c0e03e06be1d516fe8ea821146d2f.zip
llvm-073401e59c8c0e03e06be1d516fe8ea821146d2f.tar.gz
llvm-073401e59c8c0e03e06be1d516fe8ea821146d2f.tar.bz2
[MC] Define and use MCInstrDesc implicit_uses and implicit_defs. NFC.
The new methods return a range for easier iteration. Use them everywhere instead of getImplicitUses, getNumImplicitUses, getImplicitDefs and getNumImplicitDefs. A future patch will remove the old methods. In some use cases the new methods are less efficient because they always have to scan the whole uses/defs array to count its length, but that will be fixed in a future patch by storing the number of implicit uses/defs explicitly in MCInstrDesc. At that point there will be no need to 0-terminate the arrays. Differential Revision: https://reviews.llvm.org/D142215
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 27564c8..8e0777f 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -84,14 +84,10 @@ static void tryToGetTargetInfo(const MachineInstr &MI,
}
void MachineInstr::addImplicitDefUseOperands(MachineFunction &MF) {
- if (MCID->getImplicitDefs())
- for (const MCPhysReg *ImpDefs = MCID->getImplicitDefs(); *ImpDefs;
- ++ImpDefs)
- addOperand(MF, MachineOperand::CreateReg(*ImpDefs, true, true));
- if (MCID->getImplicitUses())
- for (const MCPhysReg *ImpUses = MCID->getImplicitUses(); *ImpUses;
- ++ImpUses)
- addOperand(MF, MachineOperand::CreateReg(*ImpUses, false, true));
+ for (MCPhysReg ImpDef : MCID->implicit_defs())
+ addOperand(MF, MachineOperand::CreateReg(ImpDef, true, true));
+ for (MCPhysReg ImpUse : MCID->implicit_uses())
+ addOperand(MF, MachineOperand::CreateReg(ImpUse, false, true));
}
/// MachineInstr ctor - This constructor creates a MachineInstr and adds the
@@ -103,8 +99,8 @@ MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &TID,
assert(DbgLoc.hasTrivialDestructor() && "Expected trivial destructor");
// Reserve space for the expected number of operands.
- if (unsigned NumOps = MCID->getNumOperands() +
- MCID->getNumImplicitDefs() + MCID->getNumImplicitUses()) {
+ if (unsigned NumOps = MCID->getNumOperands() + MCID->implicit_defs().size() +
+ MCID->implicit_uses().size()) {
CapOperands = OperandCapacity::get(NumOps);
Operands = MF.allocateOperandArray(CapOperands);
}