summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstrBundle.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-29 01:40:37 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-29 01:40:37 +0000
commita36fe736458d242e1ae4200c1a8dd42f662851fb (patch)
treed856e9db79d07f87cb059b54515bf92c559b0528 /lib/CodeGen/MachineInstrBundle.cpp
parentadef06a71458ded0716935a61b3d43d164d4df12 (diff)
downloadllvm-a36fe736458d242e1ae4200c1a8dd42f662851fb.tar.gz
llvm-a36fe736458d242e1ae4200c1a8dd42f662851fb.tar.bz2
llvm-a36fe736458d242e1ae4200c1a8dd42f662851fb.tar.xz
Add an analyzeVirtReg() function.
This function does more or less the same as MI::readsWritesVirtualRegister(), but it supports bundles as well. It also determines if any constraint requires reading and writing operands to use the same register. Most clients want to know. Use the more modern MO.readsReg() instead of trying to sort out undefs and partial redefines. Stop supporting the extra full <imp-def> operand as an alternative to <def,undef> sub-register defines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151690 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstrBundle.cpp')
-rw-r--r--lib/CodeGen/MachineInstrBundle.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineInstrBundle.cpp b/lib/CodeGen/MachineInstrBundle.cpp
index d8b2b3a6ce..81d2abeb1d 100644
--- a/lib/CodeGen/MachineInstrBundle.cpp
+++ b/lib/CodeGen/MachineInstrBundle.cpp
@@ -241,3 +241,36 @@ bool llvm::finalizeBundles(MachineFunction &MF) {
return Changed;
}
+
+//===----------------------------------------------------------------------===//
+// MachineOperand iterator
+//===----------------------------------------------------------------------===//
+
+MachineOperandIteratorBase::RegInfo
+MachineOperandIteratorBase::analyzeVirtReg(unsigned Reg,
+ SmallVectorImpl<std::pair<MachineInstr*, unsigned> > *Ops) {
+ RegInfo RI = { false, false, false };
+ for(; isValid(); ++*this) {
+ MachineOperand &MO = deref();
+ if (!MO.isReg() || MO.getReg() != Reg)
+ continue;
+
+ // Remember each (MI, OpNo) that refers to Reg.
+ if (Ops)
+ Ops->push_back(std::make_pair(MO.getParent(), getOperandNo()));
+
+ // Both defs and uses can read virtual registers.
+ if (MO.readsReg()) {
+ RI.Reads = true;
+ if (MO.isDef())
+ RI.Tied = true;
+ }
+
+ // Only defs can write.
+ if (MO.isDef())
+ RI.Writes = true;
+ else if (!RI.Tied && MO.getParent()->isRegTiedToDefOperand(getOperandNo()))
+ RI.Tied = true;
+ }
+ return RI;
+}