convert some stuff to work on raw_ostreams instead of std::ostream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79803 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-08-23 01:12:47 +00:00
parent 19ef669689
commit d74c556e9a
3 changed files with 22 additions and 21 deletions

View File

@ -18,10 +18,10 @@
#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseSet.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include <cassert> #include <cassert>
#include <iosfwd>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
class raw_ostream;
class TargetData; class TargetData;
class TargetRegisterClass; class TargetRegisterClass;
class Type; class Type;
@ -423,7 +423,7 @@ public:
/// print - Used by the MachineFunction printer to print information about /// print - Used by the MachineFunction printer to print information about
/// stack objects. Implemented in MachineFunction.cpp /// stack objects. Implemented in MachineFunction.cpp
/// ///
void print(const MachineFunction &MF, std::ostream &OS) const; void print(const MachineFunction &MF, raw_ostream &OS) const;
/// dump - Print the function to stderr. /// dump - Print the function to stderr.
void dump(const MachineFunction &MF) const; void dump(const MachineFunction &MF) const;

View File

@ -21,13 +21,13 @@
#define LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H #define LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
#include <vector> #include <vector>
#include <iosfwd>
#include <cassert> #include <cassert>
namespace llvm { namespace llvm {
class MachineBasicBlock; class MachineBasicBlock;
class TargetData; class TargetData;
class raw_ostream;
/// MachineJumpTableEntry - One jump table in the jump table info. /// MachineJumpTableEntry - One jump table in the jump table info.
/// ///
@ -79,8 +79,7 @@ public:
/// print - Used by the MachineFunction printer to print information about /// print - Used by the MachineFunction printer to print information about
/// jump tables. Implemented in MachineFunction.cpp /// jump tables. Implemented in MachineFunction.cpp
/// ///
void print(std::ostream &OS) const; void print(raw_ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// dump - Call to stderr. /// dump - Call to stderr.
/// ///

View File

@ -217,11 +217,16 @@ MachineFunction::DeleteMachineBasicBlock(MachineBasicBlock *MBB) {
} }
void MachineFunction::dump() const { void MachineFunction::dump() const {
print(*cerr.stream()); print(errs());
} }
void MachineFunction::print(std::ostream &OS) const { void MachineFunction::print(std::ostream &OS) const {
OS << "# Machine code for " << Fn->getNameStr() << "():\n"; raw_os_ostream RawOS(OS);
print(RawOS);
}
void MachineFunction::print(raw_ostream &OS) const {
OS << "# Machine code for " << Fn->getName() << "():\n";
// Print Frame Information // Print Frame Information
FrameInfo->print(*this, OS); FrameInfo->print(*this, OS);
@ -230,10 +235,7 @@ void MachineFunction::print(std::ostream &OS) const {
JumpTableInfo->print(OS); JumpTableInfo->print(OS);
// Print Constant Pool // Print Constant Pool
{ ConstantPool->print(OS);
raw_os_ostream OSS(OS);
ConstantPool->print(OSS);
}
const TargetRegisterInfo *TRI = getTarget().getRegisterInfo(); const TargetRegisterInfo *TRI = getTarget().getRegisterInfo();
@ -247,25 +249,25 @@ void MachineFunction::print(std::ostream &OS) const {
OS << " Reg #" << I->first; OS << " Reg #" << I->first;
if (I->second) if (I->second)
OS << " in VR#" << I->second << " "; OS << " in VR#" << I->second << ' ';
} }
OS << "\n"; OS << '\n';
} }
if (RegInfo && !RegInfo->liveout_empty()) { if (RegInfo && !RegInfo->liveout_empty()) {
OS << "Live Outs:"; OS << "Live Outs:";
for (MachineRegisterInfo::liveout_iterator for (MachineRegisterInfo::liveout_iterator
I = RegInfo->liveout_begin(), E = RegInfo->liveout_end(); I != E; ++I) I = RegInfo->liveout_begin(), E = RegInfo->liveout_end(); I != E; ++I)
if (TRI) if (TRI)
OS << " " << TRI->getName(*I); OS << ' ' << TRI->getName(*I);
else else
OS << " Reg #" << *I; OS << " Reg #" << *I;
OS << "\n"; OS << '\n';
} }
for (const_iterator BB = begin(), E = end(); BB != E; ++BB) for (const_iterator BB = begin(), E = end(); BB != E; ++BB)
BB->print(OS); BB->print(OS);
OS << "\n# End machine code for " << Fn->getNameStr() << "().\n\n"; OS << "\n# End machine code for " << Fn->getName() << "().\n\n";
} }
namespace llvm { namespace llvm {
@ -407,7 +409,7 @@ MachineFrameInfo::getPristineRegs(const MachineBasicBlock *MBB) const {
} }
void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{ void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{
const TargetFrameInfo *FI = MF.getTarget().getFrameInfo(); const TargetFrameInfo *FI = MF.getTarget().getFrameInfo();
int ValOffset = (FI ? FI->getOffsetOfLocalArea() : 0); int ValOffset = (FI ? FI->getOffsetOfLocalArea() : 0);
@ -444,7 +446,7 @@ void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
} }
void MachineFrameInfo::dump(const MachineFunction &MF) const { void MachineFrameInfo::dump(const MachineFunction &MF) const {
print(MF, *cerr.stream()); print(MF, errs());
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -483,7 +485,7 @@ MachineJumpTableInfo::ReplaceMBBInJumpTables(MachineBasicBlock *Old,
return MadeChange; return MadeChange;
} }
void MachineJumpTableInfo::print(std::ostream &OS) const { void MachineJumpTableInfo::print(raw_ostream &OS) const {
// FIXME: this is lame, maybe we could print out the MBB numbers or something // FIXME: this is lame, maybe we could print out the MBB numbers or something
// like {1, 2, 4, 5, 3, 0} // like {1, 2, 4, 5, 3, 0}
for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) { for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
@ -492,7 +494,7 @@ void MachineJumpTableInfo::print(std::ostream &OS) const {
} }
} }
void MachineJumpTableInfo::dump() const { print(*cerr.stream()); } void MachineJumpTableInfo::dump() const { print(errs()); }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//