If the target has V9 instructions, this pass is a noop, don't bother
[oota-llvm.git] / lib / Target / Sparc / FPMover.cpp
index cc3d78176603655ed4931a4f33cf280ac225cd37..8bc1009d37b170d9b25f9486c6901760cdb70ac3 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "SparcV8.h"
+#include "SparcV8Subtarget.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/Target/TargetMachine.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
 #include <iostream>
@@ -36,14 +38,7 @@ namespace {
     }
 
     bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
-    bool runOnMachineFunction(MachineFunction &F) {
-      bool Changed = false;
-      for (MachineFunction::iterator FI = F.begin(), FE = F.end();
-           FI != FE; ++FI)
-        Changed |= runOnMachineBasicBlock(*FI);
-      return Changed;
-    }
-
+    bool runOnMachineFunction(MachineFunction &F);
   };
 } // end of anonymous namespace
 
@@ -122,3 +117,16 @@ bool FPMover::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
   }
   return Changed;
 }
+
+bool FPMover::runOnMachineFunction(MachineFunction &F) {
+  // If the target has V9 instructions, the fp-mover pseudos will never be
+  // emitted.  Avoid a scan of the instructions to improve compile time.
+  if (TM.getSubtarget<SparcV8Subtarget>().isV9())
+    return false;
+  
+  bool Changed = false;
+  for (MachineFunction::iterator FI = F.begin(), FE = F.end();
+       FI != FE; ++FI)
+    Changed |= runOnMachineBasicBlock(*FI);
+  return Changed;
+}