Revert r110396 to fix buildbots.
[oota-llvm.git] / lib / Target / ARM / NEONMoveFix.cpp
index 3c3b9520ca14ab07d7df4d87fc93918b011df7f9..bbdd3c7f7c3e09553a1c72b4827fd11d90f95d64 100644 (file)
@@ -35,7 +35,6 @@ namespace {
   private:
     const TargetRegisterInfo *TRI;
     const ARMBaseInstrInfo *TII;
-    const ARMSubtarget *Subtarget;
 
     typedef DenseMap<unsigned, const MachineInstr*> RegMap;
 
@@ -52,13 +51,13 @@ bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) {
   MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end();
   MachineBasicBlock::iterator NextMII;
   for (; MII != E; MII = NextMII) {
-    NextMII = next(MII);
+    NextMII = llvm::next(MII);
     MachineInstr *MI = &*MII;
 
-    if (MI->getOpcode() == ARM::FCPYD &&
+    if (MI->getOpcode() == ARM::VMOVD &&
         !TII->isPredicated(MI)) {
       unsigned SrcReg = MI->getOperand(1).getReg();
-      // If we do not found an instruction defining the reg, this means the
+      // If we do not find an instruction defining the reg, this means the
       // register should be live-in for this BB. It's always to better to use
       // NEON reg-reg moves.
       unsigned Domain = ARMII::DomainNEON;
@@ -71,8 +70,8 @@ bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) {
           Domain = ARMII::DomainNEON;
       }
 
-      if ((Domain & ARMII::DomainNEON) && Subtarget->hasNEON()) {
-        // Convert FCPYD to VMOVD.
+      if (Domain & ARMII::DomainNEON) {
+        // Convert VMOVD to VMOVDneon
         unsigned DestReg = MI->getOperand(0).getReg();
 
         DEBUG({errs() << "vmov convert: "; MI->dump();});
@@ -82,8 +81,8 @@ bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) {
         //    afterwards
         //  - The imp-defs / imp-uses are superregs only, we don't care about
         //    them.
-        BuildMI(MBB, *MI, MI->getDebugLoc(),
-                TII->get(ARM::VMOVD), DestReg).addReg(SrcReg);
+        AddDefaultPred(BuildMI(MBB, *MI, MI->getDebugLoc(),
+                             TII->get(ARM::VMOVDneon), DestReg).addReg(SrcReg));
         MBB.erase(MI);
         MachineBasicBlock::iterator I = prior(NextMII);
         MI = &*I;
@@ -93,8 +92,7 @@ bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) {
         Modified = true;
         ++NumVMovs;
       } else {
-        assert((Domain & ARMII::DomainVFP ||
-                !Subtarget->hasNEON()) && "Invalid domain!");
+        assert((Domain & ARMII::DomainVFP) && "Invalid domain!");
         // Do nothing.
       }
     }
@@ -107,8 +105,8 @@ bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) {
       unsigned MOReg = MO.getReg();
 
       Defs[MOReg] = MI;
-      // Catch subregs as well.
-      for (const unsigned *R = TRI->getSubRegisters(MOReg); *R; ++R)
+      // Catch aliases as well.
+      for (const unsigned *R = TRI->getAliasSet(MOReg); *R; ++R)
         Defs[*R] = MI;
     }
   }
@@ -120,11 +118,10 @@ bool NEONMoveFixPass::runOnMachineFunction(MachineFunction &Fn) {
   ARMFunctionInfo *AFI = Fn.getInfo<ARMFunctionInfo>();
   const TargetMachine &TM = Fn.getTarget();
 
-  if (AFI->isThumbFunction())
+  if (AFI->isThumb1OnlyFunction())
     return false;
 
   TRI = TM.getRegisterInfo();
-  Subtarget = &TM.getSubtarget<ARMSubtarget>();
   TII = static_cast<const ARMBaseInstrInfo*>(TM.getInstrInfo());
 
   bool Modified = false;