[llvm-commits] [llvm] r55268 - in /llvm/trunk: include/llvm/CodeGen/MachineConstantPool.h lib/CodeGen/MachineFunction.cpp lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
Chris Lattner
sabre at nondot.org
Sat Aug 23 15:53:13 PDT 2008
Author: lattner
Date: Sat Aug 23 17:53:13 2008
New Revision: 55268
URL: http://llvm.org/viewvc/llvm-project?rev=55268&view=rev
Log:
get MachineConstantPool off std::ostream, onto raw_ostream. It would be
really nice if someone converted MachineFunction::print to raw_ostream.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h
llvm/trunk/lib/CodeGen/MachineFunction.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h?rev=55268&r1=55267&r2=55268&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h Sat Aug 23 17:53:13 2008
@@ -16,10 +16,8 @@
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
#include "llvm/ADT/FoldingSet.h"
-#include "llvm/Support/Streams.h"
#include <cassert>
#include <vector>
-#include <iosfwd>
namespace llvm {
@@ -49,19 +47,10 @@
virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID) = 0;
- /// print - Implement operator<<...
- ///
- void print(std::ostream &O) const;
- void print(std::ostream *O) const { if (O) print(*O); }
+ /// print - Implement operator<<
virtual void print(raw_ostream &O) const = 0;
};
-inline std::ostream &operator<<(std::ostream &OS,
- const MachineConstantPoolValue &V) {
- V.print(OS);
- return OS;
-}
-
inline raw_ostream &operator<<(raw_ostream &OS,
const MachineConstantPoolValue &V) {
V.print(OS);
@@ -147,11 +136,9 @@
/// print - Used by the MachineFunction printer to print information about
/// constant pool objects. Implemented in MachineFunction.cpp
///
- void print(std::ostream &OS) const;
- void print(std::ostream *OS) const { if (OS) print(*OS); }
+ void print(raw_ostream &OS) const;
- /// dump - Call print(std::cerr) to be called from the debugger.
- ///
+ /// dump - Call print(cerr) to be called from the debugger.
void dump() const;
};
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=55268&r1=55267&r2=55268&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Aug 23 17:53:13 2008
@@ -248,7 +248,10 @@
JumpTableInfo->print(OS);
// Print Constant Pool
- ConstantPool->print(OS);
+ {
+ raw_os_ostream OSS(OS);
+ ConstantPool->print(OSS);
+ }
const TargetRegisterInfo *TRI = getTarget().getRegisterInfo();
@@ -526,12 +529,7 @@
return Constants.size()-1;
}
-void MachineConstantPoolValue::print(std::ostream &o) const {
- raw_os_ostream OS(o);
- print(OS);
-}
-
-void MachineConstantPool::print(std::ostream &OS) const {
+void MachineConstantPool::print(raw_ostream &OS) const {
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
OS << " <cp #" << i << "> is";
if (Constants[i].isMachineConstantPoolEntry())
@@ -543,4 +541,4 @@
}
}
-void MachineConstantPool::dump() const { print(*cerr.stream()); }
+void MachineConstantPool::dump() const { print(errs()); errs().flush(); }
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=55268&r1=55267&r2=55268&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Sat Aug 23 17:53:13 2008
@@ -23,10 +23,10 @@
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/GraphWriter.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/config.h"
#include <fstream>
-#include <sstream>
using namespace llvm;
namespace llvm {
@@ -138,18 +138,24 @@
Op += " " + itostr(JTDN->getIndex());
} else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Node)){
if (CP->isMachineConstantPoolEntry()) {
- std::ostringstream SS;
- CP->getMachineCPVal()->print(SS);
- Op += "<" + SS.str() + ">";
+ Op += '<';
+ {
+ raw_string_ostream OSS(Op);
+ OSS << *CP->getMachineCPVal();
+ }
+ Op += '>';
} else {
if (ConstantFP *CFP = dyn_cast<ConstantFP>(CP->getConstVal()))
Op += "<" + ftostr(CFP->getValueAPF()) + ">";
else if (ConstantInt *CI = dyn_cast<ConstantInt>(CP->getConstVal()))
Op += "<" + utostr(CI->getZExtValue()) + ">";
else {
- std::ostringstream SS;
- WriteAsOperand(SS, CP->getConstVal(), false);
- Op += "<" + SS.str() + ">";
+ Op += '<';
+ {
+ raw_string_ostream OSS(Op);
+ WriteAsOperand(OSS, CP->getConstVal(), false);
+ }
+ Op += '>';
}
}
} else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(Node)) {
@@ -188,9 +194,10 @@
Op += "(unknown)";
} else if (isa<PseudoSourceValue>(V)) {
// PseudoSourceValues don't have names, so use their print method.
- std::ostringstream SS;
- M->MO.getValue()->print(SS);
- Op += SS.str();
+ {
+ raw_string_ostream OSS(Op);
+ OSS << *M->MO.getValue();
+ }
} else {
Op += V->getName();
}
More information about the llvm-commits
mailing list