Update a bunch of stale comments that dated from when this folled the
[oota-llvm.git] / lib / CodeGen / ExpandPostRAPseudos.cpp
index 623b67ddcd67a0481db35a53932e7c63a61a6110..b14afc286d497599381ebbc97c7e4dbfd10e893d 100644 (file)
@@ -36,10 +36,6 @@ public:
   static char ID; // Pass identification, replacement for typeid
   ExpandPostRA() : MachineFunctionPass(ID) {}
 
-  const char *getPassName() const {
-    return "Post-RA pseudo instruction expansion pass";
-  }
-
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesCFG();
     AU.addPreservedID(MachineLoopInfoID);
@@ -61,10 +57,10 @@ private:
 } // end anonymous namespace
 
 char ExpandPostRA::ID = 0;
+char &llvm::ExpandPostRAPseudosID = ExpandPostRA::ID;
 
-FunctionPass *llvm::createExpandPostRAPseudosPass() {
-  return new ExpandPostRA();
-}
+INITIALIZE_PASS(ExpandPostRA, "postrapseudos",
+                "Post-RA pseudo instruction expansion pass", false, false)
 
 /// TransferDeadFlag - MI is a pseudo-instruction with DstReg dead,
 /// and the lowered replacement instructions immediately precede it.
@@ -205,6 +201,18 @@ bool ExpandPostRA::runOnMachineFunction(MachineFunction &MF) {
       MachineInstr *MI = mi;
       // Advance iterator here because MI may be erased.
       ++mi;
+
+      // Only expand pseudos.
+      if (!MI->isPseudo())
+        continue;
+
+      // Give targets a chance to expand even standard pseudos.
+      if (TII->expandPostRAPseudo(MI)) {
+        MadeChange = true;
+        continue;
+      }
+
+      // Expand standard pseudos.
       switch (MI->getOpcode()) {
       case TargetOpcode::SUBREG_TO_REG:
         MadeChange |= LowerSubregToReg(MI);
@@ -217,10 +225,6 @@ bool ExpandPostRA::runOnMachineFunction(MachineFunction &MF) {
       case TargetOpcode::INSERT_SUBREG:
       case TargetOpcode::EXTRACT_SUBREG:
         llvm_unreachable("Sub-register pseudos should have been eliminated.");
-      default:
-        if (MI->getDesc().isPseudo())
-          MadeChange |= TII->expandPostRAPseudo(MI);
-        break;
       }
     }
   }