revert r76602, 76603, and r76615, pending design discussions.
authorChris Lattner <sabre@nondot.org>
Tue, 21 Jul 2009 21:12:58 +0000 (21:12 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 21 Jul 2009 21:12:58 +0000 (21:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76646 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveIntervalAnalysis.h
include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineFunction.h
include/llvm/Support/Dump.h [deleted file]
lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/MachineBasicBlock.cpp
lib/CodeGen/MachineFunction.cpp

index ea67cdbba24b15730d80ebad2a6e48389464e72a..40991e74e3c0a77a8a0b6cfc4066ddb504afa391 100644 (file)
@@ -27,9 +27,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/Dump.h"
 #include <cmath>
-#include <sstream>
 
 namespace llvm {
 
@@ -81,7 +79,7 @@ namespace llvm {
     /// FunctionSize - The number of instructions present in the function
     uint64_t FunctionSize;
 
-    typedef DenseMap<const MachineInstr*, unsigned> Mi2IndexMap;
+    typedef DenseMap<MachineInstr*, unsigned> Mi2IndexMap;
     Mi2IndexMap mi2iMap_;
 
     typedef std::vector<MachineInstr*> Index2MiMap;
@@ -200,7 +198,7 @@ namespace llvm {
     }
 
     /// getInstructionIndex - returns the base index of instr
-    unsigned getInstructionIndex(const MachineInstr* instr) const {
+    unsigned getInstructionIndex(MachineInstr* instr) const {
       Mi2IndexMap::const_iterator it = mi2iMap_.find(instr);
       assert(it != mi2iMap_.end() && "Invalid instruction!");
       return it->second;
@@ -540,26 +538,6 @@ namespace llvm {
     void printRegName(unsigned reg) const;
   };
 
-  // IntervalPrefixPrinter - Print live interval indices before each
-  // instruction.
-  class IntervalPrefixPrinter : public PrefixPrinter {
-  private:
-    const LiveIntervals &liinfo;
-
-  public:
-    IntervalPrefixPrinter(const LiveIntervals &lii)
-        : liinfo(lii) {};
-
-    std::string operator()(const MachineBasicBlock &) const {
-      return("");
-    };
-    
-    std::string operator()(const MachineInstr &instr) const {
-      std::stringstream out;
-      out << liinfo.getInstructionIndex(&instr);
-      return(out.str());
-    };  
-  };
 } // End llvm namespace
 
 #endif
index b5278b688d2f69c9ca51c8403b2e7e3be3e9fd49..aacc31455eab793f5f2235d1ee5179fd6e8345d1 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/ADT/GraphTraits.h"
-#include "llvm/Support/Dump.h"
 
 namespace llvm {
 
@@ -310,12 +309,8 @@ public:
 
   // Debugging methods.
   void dump() const;
-  void print(std::ostream &OS,
-             const PrefixPrinter &prefix = PrefixPrinter()) const;
-  void print(std::ostream *OS,
-             const PrefixPrinter &prefix = PrefixPrinter()) const {
-    if (OS) print(*OS, prefix); 
-  }
+  void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// getNumber - MachineBasicBlocks are uniquely numbered at the function
   /// level, unless they're not in a MachineFunction yet, in which case this
index 4937b23a6d966dc26ddb635b0b88a45248bdffd1..ea6a384d2287243b3f93fda831d8ad36abd233bc 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "llvm/ADT/ilist.h"
 #include "llvm/Support/DebugLoc.h"
-#include "llvm/Support/Dump.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/Support/Annotation.h"
 #include "llvm/Support/Allocator.h"
@@ -208,12 +207,8 @@ public:
   /// print - Print out the MachineFunction in a format suitable for debugging
   /// to the specified stream.
   ///
-  void print(std::ostream &OS, 
-             const PrefixPrinter &prefix = PrefixPrinter()) const;
-  void print(std::ostream *OS,
-             const PrefixPrinter &prefix = PrefixPrinter()) const {
-    if (OS) print(*OS, prefix); 
-  }
+  void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// viewCFG - This function is meant for use from the debugger.  You can just
   /// say 'call F->viewCFG()' and a ghostview window should pop up from the
diff --git a/include/llvm/Support/Dump.h b/include/llvm/Support/Dump.h
deleted file mode 100644 (file)
index a95875b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//===- llvm/Support/Dump.h - Easy way to tailor dump output -----*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the PrefixPrinter interface to pass to MachineFunction
-// and MachineBasicBlock print methods to output additional information before
-// blocks and instructions are printed.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_DUMP_H
-#define LLVM_SUPPORT_DUMP_H
-
-namespace llvm {
-
-class MachineBasicBlock;
-class MachineInstr;
-
-// PrefixPrinter - Print some additional information before printing
-// basic blocks and instructions.
-class PrefixPrinter {
-public:
-  virtual ~PrefixPrinter() {}
-
-  virtual std::string operator()(const MachineBasicBlock &) const {
-    return("");
-  };
-
-  virtual std::string operator()(const MachineInstr &) const {
-    return("");
-  };  
-};
-} // End llvm namespace
-
-#endif
index aba6ff11b42fcb6817782e2fe412010056b1f637..261fa5e0f865f766a631581d9b45c8f4ea808fed 100644 (file)
@@ -464,7 +464,7 @@ void LiveIntervals::scaleNumbering(int factor) {
   i2miMap_.resize(highestSlot + 1);
   for (Mi2IndexMap::iterator MI = mi2iMap_.begin(), ME = mi2iMap_.end();
        MI != ME; ++MI) {
-    i2miMap_[MI->second] = const_cast<MachineInstr *>(MI->first);
+    i2miMap_[MI->second] = MI->first;
   }
 
 }
@@ -501,7 +501,14 @@ void LiveIntervals::print(std::ostream &O, const Module* ) const {
   }
 
   O << "********** MACHINEINSTRS **********\n";
-  mf_->print(O, IntervalPrefixPrinter(*this));
+  for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
+       mbbi != mbbe; ++mbbi) {
+    O << ((Value*)mbbi->getBasicBlock())->getName() << ":\n";
+    for (MachineBasicBlock::iterator mii = mbbi->begin(),
+           mie = mbbi->end(); mii != mie; ++mii) {
+      O << getInstructionIndex(mii) << '\t' << *mii;
+    }
+  }
 }
 
 /// conflictsWithPhysRegDef - Returns true if the specified register
index 82ff769c1d05275467b7b6c47b1fdd0c18bb54f2..71e6b3e4d0f8694d9cd1d3e94b131cd5a712bdeb 100644 (file)
@@ -148,8 +148,7 @@ static inline void OutputReg(std::ostream &os, unsigned RegNo,
     os << " %reg" << RegNo;
 }
 
-void MachineBasicBlock::print(std::ostream &OS,
-                              const PrefixPrinter &prefix) const {
+void MachineBasicBlock::print(std::ostream &OS) const {
   const MachineFunction *MF = getParent();
   if(!MF) {
     OS << "Can't print out MachineBasicBlock because parent MachineFunction"
@@ -182,7 +181,6 @@ void MachineBasicBlock::print(std::ostream &OS,
   }
   
   for (const_iterator I = begin(); I != end(); ++I) {
-    OS << prefix(*I);
     OS << "\t";
     I->print(OS, &getParent()->getTarget());
   }
index 324e3a5b9215e7baf632b47dbf164b763f27985e..599efb8bd276c4c132d6f8c6e7f3bc6b06049ed3 100644 (file)
@@ -252,8 +252,7 @@ void MachineFunction::dump() const {
   print(*cerr.stream());
 }
 
-void MachineFunction::print(std::ostream &OS,
-                            const PrefixPrinter &prefix) const {
+void MachineFunction::print(std::ostream &OS) const {
   OS << "# Machine code for " << Fn->getName () << "():\n";
 
   // Print Frame Information
@@ -295,10 +294,8 @@ void MachineFunction::print(std::ostream &OS,
     OS << "\n";
   }
   
-  for (const_iterator BB = begin(); BB != end(); ++BB) {
-    OS << prefix(*BB);
-    BB->print(OS, prefix);
-  }
+  for (const_iterator BB = begin(); BB != end(); ++BB)
+    BB->print(OS);
 
   OS << "\n# End machine code for " << Fn->getName () << "().\n\n";
 }