R600: Implement TargetInstrInfo::isLegalToSplitMBBAt()
authorTom Stellard <thomas.stellard@amd.com>
Fri, 22 Nov 2013 00:41:08 +0000 (00:41 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 22 Nov 2013 00:41:08 +0000 (00:41 +0000)
Splitting a basic block will create a new ALU clause, so we need to make
sure we aren't moving uses of registers that are local to their
current clause into a new one.

I had a test case for this, but unfortunately unrelated schedule changes
invalidated it, and I wasn't been able to come up with another one.

NOTE: This is a candidate for the 3.4 branch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195399 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/R600InstrInfo.cpp
lib/Target/R600/R600InstrInfo.h

index 1f4741634e1a1097a9915fbee0a824267d0e1f11..c0827fc1ca40a504f47c98ffbb0a9355afe8b05f 100644 (file)
@@ -77,6 +77,18 @@ R600InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
   }
 }
 
+/// \returns true if \p MBBI can be moved into a new basic.
+bool R600InstrInfo::isLegalToSplitMBBAt(MachineBasicBlock &MBB,
+                                       MachineBasicBlock::iterator MBBI) const {
+  for (MachineInstr::const_mop_iterator I = MBBI->operands_begin(),
+                                        E = MBBI->operands_end(); I != E; ++I) {
+    if (I->isReg() && !TargetRegisterInfo::isVirtualRegister(I->getReg()) &&
+        I->isUse() && RI.isPhysRegLiveAcrossClauses(I->getReg()))
+      return false;
+  }
+  return true;
+}
+
 unsigned R600InstrInfo::getIEQOpcode() const {
   return AMDGPU::SETE_INT;
 }
index b29b91f8d7e2b9b3638e12d38da9b263552c128b..13d981094ed5252aa664c0ca7ead0e0ca0b943fa 100644 (file)
@@ -55,6 +55,8 @@ namespace llvm {
                            MachineBasicBlock::iterator MI, DebugLoc DL,
                            unsigned DestReg, unsigned SrcReg,
                            bool KillSrc) const;
+  bool isLegalToSplitMBBAt(MachineBasicBlock &MBB,
+                           MachineBasicBlock::iterator MBBI) const;
 
   bool isTrig(const MachineInstr &MI) const;
   bool isPlaceHolderOpcode(unsigned opcode) const;