The best unbreakage yet, addressing Bill's concerns.
authorJeff Cohen <jeffc@jolt-lang.org>
Sat, 16 Dec 2006 02:15:42 +0000 (02:15 +0000)
committerJeff Cohen <jeffc@jolt-lang.org>
Sat, 16 Dec 2006 02:15:42 +0000 (02:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32622 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveInterval.h
include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineInstr.h
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/MachineBasicBlock.cpp
lib/CodeGen/MachineInstr.cpp

index a64af87d91227108809e37fa9e70c0d45b17311e..b22922c84c054ec9f29ab974ec97b16cf6525d1f 100644 (file)
@@ -56,13 +56,18 @@ namespace llvm {
     }
 
     void dump() const;
+    void print(std::ostream &os) const;
 
   private:
     LiveRange(); // DO NOT IMPLEMENT
   };
 
   std::ostream& operator<<(std::ostream& os, const LiveRange &LR);
-  OStream& operator<<(OStream& os, const LiveRange &LR);
+  inline OStream& operator<<(OStream& os, const LiveRange &LR) {
+    if (os.stream()) LR.print(*os.stream());
+    return os;
+  }
+
 
   inline bool operator<(unsigned V, const LiveRange &LR) {
     return V < LR.start;
index 4cf6a24e45041dbb7dd538fd6f4921ff472ec425..896d9efe03eceea34755c2706c7d1da651f83d9f 100644 (file)
@@ -226,7 +226,10 @@ private:   // Methods used to maintain doubly linked list of blocks...
 };
 
 std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB);
-OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB);
+inline OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB) {
+  if (OS.stream()) MBB.print(*OS.stream());
+  return OS;
+}
 
 //===--------------------------------------------------------------------===//
 // GraphTraits specializations for machine basic block graphs (machine-CFGs)
index e19a3ebfbe8e69d3434437952d10b1f408948b83..77de83768e387a85ddd49270e107d02c1ab4449b 100644 (file)
@@ -76,6 +76,9 @@ private:
   int offset;
 
   MachineOperand() {}
+
+  void print(std::ostream &os) const;
+
 public:
   MachineOperand(const MachineOperand &M) {
     *this = M;
@@ -285,8 +288,14 @@ public:
     IsDead = false;
   }
 
-  friend OStream& operator<<(OStream& os, const MachineOperand& mop);
-  friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
+  friend OStream& operator<<(OStream& os, const MachineOperand& mop) {
+    if (os.stream()) mop.print(*os.stream());
+    return os;
+  }
+  friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop) {
+    mop.print(os);
+    return os;
+  }
 
   friend class MachineInstr;
 };
@@ -398,9 +407,16 @@ public:
     if (OS.stream()) print(*OS.stream(), TM);
   }
   void print(std::ostream &OS, const TargetMachine *TM) const;
+  void print(std::ostream &OS) const;
   void dump() const;
-  friend OStream& operator<<(OStream& os, const MachineInstr& minstr);
-  friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
+  friend OStream& operator<<(OStream& os, const MachineInstr& minstr) {
+    if (os.stream()) minstr.print(*os.stream());
+    return os;
+  }
+  friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr){
+    minstr.print(os);
+    return os;
+  }
 
   //===--------------------------------------------------------------------===//
   // Accessors to add operands when building up machine instructions.
index 78c874cbb93b704a4bb48990589feffa82e20f27..63a80fd16eaf2bd32f6a205585fb7606bf37535a 100644 (file)
@@ -512,7 +512,6 @@ void LiveInterval::dump() const {
 }
 
 
-OStream& llvm::operator<<(OStream& os, const LiveRange &LR) {
-  if (os.stream()) *os.stream() << LR;
-  return os;
+void LiveRange::print(std::ostream &os) const {
+  os << *this;
 }
index 39b142a2f35844b78db932f5444130c1b25e6263..a626f4fdd15ca8a5694091c21f13e698bfb8a653 100644 (file)
@@ -31,11 +31,6 @@ std::ostream& llvm::operator<<(std::ostream &OS, const MachineBasicBlock &MBB) {
   return OS;
 }
 
-OStream& llvm::operator<<(OStream &OS, const MachineBasicBlock &MBB) {
-  if (OS.stream()) *OS.stream() << MBB;
-  return OS;
-}
-
 // MBBs start out as #-1. When a MBB is added to a MachineFunction, it
 // gets the next available unique MBB number. If it is removed from a
 // MachineFunction, it goes back to being #-1.
index a68442511b4ff07cb4a55afc98c44feec41c2b7f..df6205b7d8dbb9e973e16d34ba840c5d2ebf39e5 100644 (file)
@@ -304,74 +304,61 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
   OS << "\n";
 }
 
-std::ostream &llvm::operator<<(std::ostream &os, const MachineInstr &MI) {
+void MachineInstr::print(std::ostream &os) const {
   // If the instruction is embedded into a basic block, we can find the target
   // info for the instruction.
-  if (const MachineBasicBlock *MBB = MI.getParent()) {
+  if (const MachineBasicBlock *MBB = getParent()) {
     const MachineFunction *MF = MBB->getParent();
     if (MF)
-      MI.print(os, &MF->getTarget());
+      print(os, &MF->getTarget());
     else
-      MI.print(os, 0);
-    return os;
+      print(os, 0);
   }
 
   // Otherwise, print it out in the "raw" format without symbolic register names
   // and such.
-  os << MI.getInstrDescriptor()->Name;
+  os << getInstrDescriptor()->Name;
 
-  for (unsigned i = 0, N = MI.getNumOperands(); i < N; i++) {
-    os << "\t" << MI.getOperand(i);
-    if (MI.getOperand(i).isReg() && MI.getOperand(i).isDef())
+  for (unsigned i = 0, N = getNumOperands(); i < N; i++) {
+    os << "\t" << getOperand(i);
+    if (getOperand(i).isReg() && getOperand(i).isDef())
       os << "<d>";
   }
 
-  return os << "\n";
+  os << "\n";
 }
 
-std::ostream &llvm::operator<<(std::ostream &OS, const MachineOperand &MO) {
-  switch (MO.getType()) {
-  case MachineOperand::MO_Register:
-    OutputReg(OS, MO.getReg());
+void MachineOperand::print(std::ostream &OS) const {
+  switch (getType()) {
+  case MO_Register:
+    OutputReg(OS, getReg());
     break;
-  case MachineOperand::MO_Immediate:
-    OS << (long)MO.getImmedValue();
+  case MO_Immediate:
+    OS << (long)getImmedValue();
     break;
-  case MachineOperand::MO_MachineBasicBlock:
+  case MO_MachineBasicBlock:
     OS << "<mbb:"
-       << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
-       << "@" << (void*)MO.getMachineBasicBlock() << ">";
+       << ((Value*)getMachineBasicBlock()->getBasicBlock())->getName()
+       << "@" << (void*)getMachineBasicBlock() << ">";
     break;
-  case MachineOperand::MO_FrameIndex:
-    OS << "<fi#" << MO.getFrameIndex() << ">";
+  case MO_FrameIndex:
+    OS << "<fi#" << getFrameIndex() << ">";
     break;
-  case MachineOperand::MO_ConstantPoolIndex:
-    OS << "<cp#" << MO.getConstantPoolIndex() << ">";
+  case MO_ConstantPoolIndex:
+    OS << "<cp#" << getConstantPoolIndex() << ">";
     break;
-  case MachineOperand::MO_JumpTableIndex:
-    OS << "<jt#" << MO.getJumpTableIndex() << ">";
+  case MO_JumpTableIndex:
+    OS << "<jt#" << getJumpTableIndex() << ">";
     break;
-  case MachineOperand::MO_GlobalAddress:
-    OS << "<ga:" << ((Value*)MO.getGlobal())->getName() << ">";
+  case MO_GlobalAddress:
+    OS << "<ga:" << ((Value*)getGlobal())->getName() << ">";
     break;
-  case MachineOperand::MO_ExternalSymbol:
-    OS << "<es:" << MO.getSymbolName() << ">";
+  case MO_ExternalSymbol:
+    OS << "<es:" << getSymbolName() << ">";
     break;
   default:
     assert(0 && "Unrecognized operand type");
     break;
   }
-
-  return OS;
-}
-
-OStream& llvm::operator<<(OStream& os, const MachineInstr& minstr) {
-  if (os.stream()) *os.stream() << minstr;
-  return os;
-}
-
-OStream& llvm::operator<<(OStream& os, const MachineOperand& mop) {
-  if (os.stream()) *os.stream() << mop;
-  return os;
 }