Make load->store deletion a bit smarter. This allows us to compile this:
[oota-llvm.git] / lib / CodeGen / LiveIntervalAnalysis.cpp
index f32ada750358f230a4c4dfe0ff3e50927cc8c2d8..80d3547e4b41798b68e8d3d19bbdad5d7d0a44a0 100644 (file)
@@ -615,10 +615,9 @@ bool LiveIntervals::isReMaterializable(const LiveInterval &li,
     return false;
 
   isLoad = false;
-  const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
-  if ((TID->Flags & M_IMPLICIT_DEF_FLAG) ||
-      tii_->isTriviallyReMaterializable(MI)) {
-    isLoad = TID->isSimpleLoad();
+  const TargetInstrDesc &TID = MI->getDesc();
+  if (TID.isImplicitDef() || tii_->isTriviallyReMaterializable(MI)) {
+    isLoad = TID.isSimpleLoad();
     return true;
   }
 
@@ -680,9 +679,9 @@ bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI,
                                          SmallVector<unsigned, 2> &Ops,
                                          bool isSS, int Slot, unsigned Reg) {
   unsigned MRInfo = 0;
-  const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
+  const TargetInstrDesc &TID = MI->getDesc();
   // If it is an implicit def instruction, just delete it.
-  if (TID->Flags & M_IMPLICIT_DEF_FLAG) {
+  if (TID.isImplicitDef()) {
     RemoveMachineInstrFromMaps(MI);
     vrm.RemoveMachineInstrFromMaps(MI);
     MI->eraseFromParent();
@@ -700,7 +699,7 @@ bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI,
       MRInfo |= (unsigned)VirtRegMap::isMod;
     else {
       // Filter out two-address use operand(s).
-      if (TID->getOperandConstraint(OpIdx, TOI::TIED_TO) != -1) {
+      if (TID.getOperandConstraint(OpIdx, TOI::TIED_TO) != -1) {
         MRInfo = VirtRegMap::isModRef;
         continue;
       }
@@ -709,8 +708,8 @@ bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI,
     FoldOps.push_back(OpIdx);
   }
 
-  MachineInstr *fmi = isSS ? mri_->foldMemoryOperand(MI, FoldOps, Slot)
-                           : mri_->foldMemoryOperand(MI, FoldOps, DefMI);
+  MachineInstr *fmi = isSS ? tii_->foldMemoryOperand(MI, FoldOps, Slot)
+                           : tii_->foldMemoryOperand(MI, FoldOps, DefMI);
   if (fmi) {
     // Attempt to fold the memory reference into the instruction. If
     // we can do this, we don't need to insert spill code.
@@ -746,7 +745,7 @@ bool LiveIntervals::canFoldMemoryOperand(MachineInstr *MI,
     FoldOps.push_back(OpIdx);
   }
 
-  return mri_->canFoldMemoryOperand(MI, FoldOps);
+  return tii_->canFoldMemoryOperand(MI, FoldOps);
 }
 
 bool LiveIntervals::intervalIsInOneMBB(const LiveInterval &li) const {
@@ -1226,7 +1225,7 @@ addIntervalsForSpills(const LiveInterval &li,
     int LdSlot = 0;
     bool isLoadSS = DefIsReMat && tii_->isLoadFromStackSlot(ReMatDefMI, LdSlot);
     bool isLoad = isLoadSS ||
-      (DefIsReMat && (ReMatDefMI->getInstrDescriptor()->isSimpleLoad()));
+      (DefIsReMat && (ReMatDefMI->getDesc().isSimpleLoad()));
     bool IsFirstRange = true;
     for (LiveInterval::Ranges::const_iterator
            I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) {
@@ -1308,7 +1307,7 @@ addIntervalsForSpills(const LiveInterval &li,
     int LdSlot = 0;
     bool isLoadSS = DefIsReMat && tii_->isLoadFromStackSlot(ReMatDefMI, LdSlot);
     bool isLoad = isLoadSS ||
-      (DefIsReMat && ReMatDefMI->getInstrDescriptor()->isSimpleLoad());
+      (DefIsReMat && ReMatDefMI->getDesc().isSimpleLoad());
     rewriteInstructionsForSpills(li, TrySplit, I, ReMatOrigDefMI, ReMatDefMI,
                                Slot, LdSlot, isLoad, isLoadSS, DefIsReMat,
                                CanDelete, vrm, RegInfo, rc, ReMatIds, loopInfo,
@@ -1423,7 +1422,7 @@ addIntervalsForSpills(const LiveInterval &li,
           int LdSlot = 0;
           bool isLoadSS = tii_->isLoadFromStackSlot(ReMatDefMI, LdSlot);
           // If the rematerializable def is a load, also try to fold it.
-          if (isLoadSS || ReMatDefMI->getInstrDescriptor()->isSimpleLoad())
+          if (isLoadSS || ReMatDefMI->getDesc().isSimpleLoad())
             Folded = tryFoldMemoryOperand(MI, vrm, ReMatDefMI, index,
                                           Ops, isLoadSS, LdSlot, VReg);
         }
@@ -1451,8 +1450,8 @@ addIntervalsForSpills(const LiveInterval &li,
         MachineInstr *LastUse = getInstructionFromIndex(LastUseIdx);
         int UseIdx = LastUse->findRegisterUseOperandIdx(LI->reg);
         assert(UseIdx != -1);
-        if (LastUse->getInstrDescriptor()->
-            getOperandConstraint(UseIdx, TOI::TIED_TO) == -1) {
+        if (LastUse->getDesc().getOperandConstraint(UseIdx, TOI::TIED_TO) ==
+            -1) {
           LastUse->getOperand(UseIdx).setIsKill();
           vrm.addKillPoint(LI->reg, LastUseIdx);
         }