aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveRegUnits.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-02-11 12:38:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-11 12:38:11 +0000
commite3b557809604d036af6e00c60f012c2025b59a5e (patch)
tree8a11ba2269a3b669601e2fd41145b174008f4da8 /llvm/lib/CodeGen/LiveRegUnits.cpp
parent08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (diff)
Diffstat (limited to 'llvm/lib/CodeGen/LiveRegUnits.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveRegUnits.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/LiveRegUnits.cpp b/llvm/lib/CodeGen/LiveRegUnits.cpp
index d8d8bd5d61a2..34de09dd2944 100644
--- a/llvm/lib/CodeGen/LiveRegUnits.cpp
+++ b/llvm/lib/CodeGen/LiveRegUnits.cpp
@@ -22,8 +22,10 @@ using namespace llvm;
void LiveRegUnits::removeRegsNotPreserved(const uint32_t *RegMask) {
for (unsigned U = 0, E = TRI->getNumRegUnits(); U != E; ++U) {
for (MCRegUnitRootIterator RootReg(U, TRI); RootReg.isValid(); ++RootReg) {
- if (MachineOperand::clobbersPhysReg(RegMask, *RootReg))
+ if (MachineOperand::clobbersPhysReg(RegMask, *RootReg)) {
Units.reset(U);
+ break;
+ }
}
}
}
@@ -31,42 +33,54 @@ void LiveRegUnits::removeRegsNotPreserved(const uint32_t *RegMask) {
void LiveRegUnits::addRegsInMask(const uint32_t *RegMask) {
for (unsigned U = 0, E = TRI->getNumRegUnits(); U != E; ++U) {
for (MCRegUnitRootIterator RootReg(U, TRI); RootReg.isValid(); ++RootReg) {
- if (MachineOperand::clobbersPhysReg(RegMask, *RootReg))
+ if (MachineOperand::clobbersPhysReg(RegMask, *RootReg)) {
Units.set(U);
+ break;
+ }
}
}
}
void LiveRegUnits::stepBackward(const MachineInstr &MI) {
// Remove defined registers and regmask kills from the set.
- for (const MachineOperand &MOP : phys_regs_and_masks(MI)) {
+ for (const MachineOperand &MOP : MI.operands()) {
+ if (MOP.isReg()) {
+ if (MOP.isDef() && MOP.getReg().isPhysical())
+ removeReg(MOP.getReg());
+ continue;
+ }
+
if (MOP.isRegMask()) {
removeRegsNotPreserved(MOP.getRegMask());
continue;
}
-
- if (MOP.isDef())
- removeReg(MOP.getReg());
}
// Add uses to the set.
- for (const MachineOperand &MOP : phys_regs_and_masks(MI)) {
+ for (const MachineOperand &MOP : MI.operands()) {
if (!MOP.isReg() || !MOP.readsReg())
continue;
- addReg(MOP.getReg());
+
+ if (MOP.getReg().isPhysical())
+ addReg(MOP.getReg());
}
}
void LiveRegUnits::accumulate(const MachineInstr &MI) {
// Add defs, uses and regmask clobbers to the set.
- for (const MachineOperand &MOP : phys_regs_and_masks(MI)) {
+ for (const MachineOperand &MOP : MI.operands()) {
+ if (MOP.isReg()) {
+ if (!MOP.getReg().isPhysical())
+ continue;
+ if (MOP.isDef() || MOP.readsReg())
+ addReg(MOP.getReg());
+ continue;
+ }
+
if (MOP.isRegMask()) {
addRegsInMask(MOP.getRegMask());
continue;
}
- if (!MOP.isDef() && !MOP.readsReg())
- continue;
- addReg(MOP.getReg());
}
}