// Debugging methods.
void dump() const;
- void print(std::ostream &OS) const;
void print(raw_ostream &OS) const;
/// getNumber - MachineBasicBlocks are uniquely numbered at the function
void removePredecessor(MachineBasicBlock *pred);
};
-std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB);
raw_ostream& operator<<(raw_ostream &OS, const MachineBasicBlock &MBB);
//===--------------------------------------------------------------------===//
/// print - Print out the MachineFunction in a format suitable for debugging
/// to the specified stream.
///
- void print(std::ostream &OS) const;
void print(raw_ostream &OS) const;
/// viewCFG - This function is meant for use from the debugger. You can just
#ifndef LLVM_CODEGEN_PASSES_H
#define LLVM_CODEGEN_PASSES_H
-#include <iosfwd>
#include <string>
namespace llvm {
class TargetMachine;
class TargetLowering;
class RegisterCoalescer;
+ class raw_ostream;
/// createUnreachableBlockEliminationPass - The LLVM code generator does not
/// work well with unreachable basic blocks (what live ranges make sense for a
/// MachineFunctionPrinter pass - This pass prints out the machine function to
/// the given stream, as a debugging tool.
- FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
+ FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner ="");
/// MachineLoopInfo pass - This pass is a loop analysis pass.
/// Creates a pass to print GC metadata.
///
- FunctionPass *createGCInfoPrinter(std::ostream &OS);
+ FunctionPass *createGCInfoPrinter(raw_ostream &OS);
/// createMachineLICMPass - This pass performs LICM on machine instructions.
///
#include "llvm/Function.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
-
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
class VISIBILITY_HIDDEN Printer : public FunctionPass {
static char ID;
- std::ostream &OS;
+ raw_ostream &OS;
public:
- explicit Printer(std::ostream &OS = *cerr);
+ Printer() : FunctionPass(&ID), OS(errs()) {}
+ explicit Printer(raw_ostream &OS) : FunctionPass(&ID), OS(OS) {}
+
const char *getPassName() const;
void getAnalysisUsage(AnalysisUsage &AU) const;
char Printer::ID = 0;
-FunctionPass *llvm::createGCInfoPrinter(std::ostream &OS) {
+FunctionPass *llvm::createGCInfoPrinter(raw_ostream &OS) {
return new Printer(OS);
}
-Printer::Printer(std::ostream &OS)
- : FunctionPass(&ID), OS(OS) {}
const char *Printer::getPassName() const {
return "Print Garbage Collector Information";
PM.add(createDebugLabelFoldingPass());
if (PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
if (addPreEmitPass(PM, OptLevel) && PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
if (OptLevel != CodeGenOpt::None)
PM.add(createCodePlacementOptPass());
return true;
if (addPreEmitPass(PM, OptLevel) && PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
addCodeEmitter(PM, OptLevel, MCE);
if (PrintEmittedAsm)
return true;
if (addPreEmitPass(PM, OptLevel) && PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
addCodeEmitter(PM, OptLevel, JCE);
if (PrintEmittedAsm)
static void printAndVerify(PassManagerBase &PM,
bool allowDoubleDefs = false) {
if (PrintMachineCode)
- PM.add(createMachineFunctionPrinterPass(cerr));
+ PM.add(createMachineFunctionPrinterPass(errs()));
if (VerifyMachineCode)
PM.add(createMachineVerifierPass(allowDoubleDefs));
printAndVerify(PM);
if (PrintGCInfo)
- PM.add(createGCInfoPrinter(*cerr));
+ PM.add(createGCInfoPrinter(errs()));
return false;
}
LeakDetector::removeGarbageObject(this);
}
-std::ostream &llvm::operator<<(std::ostream &OS, const MachineBasicBlock &MBB) {
- MBB.print(OS);
- return OS;
-}
raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
MBB.print(OS);
return OS;
}
void MachineBasicBlock::dump() const {
- print(*cerr.stream());
+ print(errs());
}
static inline void OutputReg(raw_ostream &os, unsigned RegNo,
os << " %reg" << RegNo;
}
-void MachineBasicBlock::print(std::ostream &OS) const {
- raw_os_ostream RawOS(OS);
- print(RawOS);
-}
-
void MachineBasicBlock::print(raw_ostream &OS) const {
const MachineFunction *MF = getParent();
if (!MF) {
#include "llvm/Support/Compiler.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
-#include <fstream>
-#include <sstream>
using namespace llvm;
namespace {
struct VISIBILITY_HIDDEN Printer : public MachineFunctionPass {
static char ID;
- std::ostream *OS;
+ raw_ostream &OS;
const std::string Banner;
- Printer(std::ostream *os, const std::string &banner)
+ Printer(raw_ostream &os, const std::string &banner)
: MachineFunctionPass(&ID), OS(os), Banner(banner) {}
const char *getPassName() const { return "MachineFunction Printer"; }
}
bool runOnMachineFunction(MachineFunction &MF) {
- (*OS) << Banner;
- MF.print (*OS);
+ OS << Banner;
+ MF.print(OS);
return false;
}
};
/// Returns a newly-created MachineFunction Printer pass. The default banner is
/// empty.
///
-FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS,
+FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner){
return new Printer(OS, Banner);
}
print(errs());
}
-void MachineFunction::print(std::ostream &OS) const {
- raw_os_ostream RawOS(OS);
- print(RawOS);
-}
-
void MachineFunction::print(raw_ostream &OS) const {
OS << "# Machine code for " << Fn->getName() << "():\n";
!Node->getBasicBlock()->getName().empty())
return Node->getBasicBlock()->getNameStr() + ":";
- std::ostringstream Out;
- if (ShortNames) {
- Out << Node->getNumber() << ':';
- return Out.str();
+ std::string OutStr;
+ {
+ raw_string_ostream OSS(OutStr);
+
+ if (ShortNames)
+ OSS << Node->getNumber() << ':';
+ else
+ Node->print(OSS);
}
- Node->print(Out);
-
- std::string OutStr = Out.str();
if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
// Process string output to make it nicer...
if (MI->getParent() == SuccToSinkTo)
return false;
- DEBUG(cerr << "Sink instr " << *MI);
- DEBUG(cerr << "to block " << *SuccToSinkTo);
+ DEBUG(errs() << "Sink instr " << *MI);
+ DEBUG(errs() << "to block " << *SuccToSinkTo);
// If the block has multiple predecessors, this would introduce computation on
// a path that it doesn't already exist. We could split the critical edge,
// but for now we just punt.
// FIXME: Split critical edges if not backedges.
if (SuccToSinkTo->pred_size() > 1) {
- DEBUG(cerr << " *** PUNTING: Critical edge found\n");
+ DEBUG(errs() << " *** PUNTING: Critical edge found\n");
return false;
}
// the verifier errors.
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SetOperations.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/LiveVariables.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SetOperations.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"