Also compute register mask lists under -new-live-intervals.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 27 Jul 2012 21:56:39 +0000 (21:56 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 27 Jul 2012 21:56:39 +0000 (21:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160898 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveIntervalAnalysis.h
lib/CodeGen/LiveIntervalAnalysis.cpp

index fe22d8af027db7217dc4014d24159c266a87d3cd..1ba8df01cc3175e268ce0b51d7a53038e56d114f 100644 (file)
@@ -347,6 +347,12 @@ namespace llvm {
     /// computeIntervals - Compute live intervals.
     void computeIntervals();
 
+    /// Compute live intervals for all virtual registers.
+    void computeVirtRegs();
+
+    /// Compute RegMaskSlots and RegMaskBits.
+    void computeRegMasks();
+
     /// handleRegisterDef - update intervals for a register def
     /// (calls handleVirtualRegisterDef)
     void handleRegisterDef(MachineBasicBlock *MBB,
index c58b8d778cab3d1963cea1cba7805262cb93a33e..31f938e43546ed85d6bb58f0cd0b9a3a0c2ee423 100644 (file)
@@ -117,14 +117,8 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
   if (NewLiveIntervals) {
     // This is the new way of computing live intervals.
     // It is independent of LiveVariables, and it can run at any time.
-    for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
-      unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
-      if (MRI->reg_nodbg_empty(Reg))
-        continue;
-      LiveInterval *LI = createInterval(Reg);
-      VirtRegIntervals[Reg] = LI;
-      computeVirtRegInterval(LI);
-    }
+    computeVirtRegs();
+    computeRegMasks();
   } else {
     // This is the old way of computing live intervals.
     // It depends on LiveVariables.
@@ -475,6 +469,38 @@ void LiveIntervals::computeVirtRegInterval(LiveInterval *LI) {
   LRCalc->extendToUses(LI);
 }
 
+void LiveIntervals::computeVirtRegs() {
+  for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
+    unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
+    if (MRI->reg_nodbg_empty(Reg))
+      continue;
+    LiveInterval *LI = createInterval(Reg);
+    VirtRegIntervals[Reg] = LI;
+    computeVirtRegInterval(LI);
+  }
+}
+
+void LiveIntervals::computeRegMasks() {
+  RegMaskBlocks.resize(MF->getNumBlockIDs());
+
+  // Find all instructions with regmask operands.
+  for (MachineFunction::iterator MBBI = MF->begin(), E = MF->end();
+       MBBI != E; ++MBBI) {
+    MachineBasicBlock *MBB = MBBI;
+    std::pair<unsigned, unsigned> &RMB = RegMaskBlocks[MBB->getNumber()];
+    RMB.first = RegMaskSlots.size();
+    for (MachineBasicBlock::iterator MI = MBB->begin(), ME = MBB->end();
+         MI != ME; ++MI)
+      for (MIOperands MO(MI); MO.isValid(); ++MO) {
+        if (!MO->isRegMask())
+          continue;
+          RegMaskSlots.push_back(Indexes->getInstructionIndex(MI).getRegSlot());
+          RegMaskBits.push_back(MO->getRegMask());
+      }
+    // Compute the number of register mask instructions in this block.
+    RMB.second = RegMaskSlots.size() - RMB.first;;
+  }
+}
 
 //===----------------------------------------------------------------------===//
 //                           Register Unit Liveness