From 3380d5c4aaafc3d78d32f583d685d64a67ae5224 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 21 Jul 2009 21:12:58 +0000 Subject: [PATCH] revert r76602, 76603, and r76615, pending design discussions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76646 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveIntervalAnalysis.h | 26 +------------ include/llvm/CodeGen/MachineBasicBlock.h | 9 +---- include/llvm/CodeGen/MachineFunction.h | 9 +---- include/llvm/Support/Dump.h | 41 --------------------- lib/CodeGen/LiveIntervalAnalysis.cpp | 11 +++++- lib/CodeGen/MachineBasicBlock.cpp | 4 +- lib/CodeGen/MachineFunction.cpp | 9 ++--- 7 files changed, 19 insertions(+), 90 deletions(-) delete mode 100644 include/llvm/Support/Dump.h diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index ea67cdbba24..40991e74e3c 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -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 -#include namespace llvm { @@ -81,7 +79,7 @@ namespace llvm { /// FunctionSize - The number of instructions present in the function uint64_t FunctionSize; - typedef DenseMap Mi2IndexMap; + typedef DenseMap Mi2IndexMap; Mi2IndexMap mi2iMap_; typedef std::vector 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 diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index b5278b688d2..aacc31455ea 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -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 diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 4937b23a6d9..ea6a384d228 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -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 index a95875b6816..00000000000 --- a/include/llvm/Support/Dump.h +++ /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 diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index aba6ff11b42..261fa5e0f86 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -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(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 diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 82ff769c1d0..71e6b3e4d0f 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -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()); } diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 324e3a5b921..599efb8bd27 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -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"; }