summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-08-23 22:23:09 +0000
committerChris Lattner <sabre@nondot.org>2008-08-23 22:23:09 +0000
commit944fac71e082cc2664cc71b4d3f6c72bab7143fb (patch)
tree819eb000a7e9c8270a44f821fdee01b904b97334 /include/llvm
parentef5dc366e713f5d596f3625344d4ec6c10159ad5 (diff)
downloadllvm-944fac71e082cc2664cc71b4d3f6c72bab7143fb.tar.gz
llvm-944fac71e082cc2664cc71b4d3f6c72bab7143fb.tar.bz2
llvm-944fac71e082cc2664cc71b4d3f6c72bab7143fb.tar.xz
Switch the asmprinter (.ll) and all the stuff it requires over to
use raw_ostream instead of std::ostream. Among other goodness, this speeds up llvm-dis of kc++ with a release build from 0.85s to 0.49s (88% faster). Other interesting changes: 1) This makes Value::print be non-virtual. 2) AP[S]Int and ConstantRange can no longer print to ostream directly, use raw_ostream instead. 3) This fixes a bug in raw_os_ostream where it didn't flush itself when destroyed. 4) This adds a new SDNode::print method, instead of only allowing "dump". A lot of APIs have both std::ostream and raw_ostream versions, it would be useful to go through and systematically anihilate the std::ostream versions. This passes dejagnu, but there may be minor fallout, plz let me know if so and I'll fix it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55263 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/ADT/APInt.h7
-rw-r--r--include/llvm/ADT/APSInt.h2
-rw-r--r--include/llvm/Argument.h5
-rw-r--r--include/llvm/Assembly/AsmAnnotationWriter.h11
-rw-r--r--include/llvm/Assembly/Writer.h4
-rw-r--r--include/llvm/BasicBlock.h4
-rw-r--r--include/llvm/CodeGen/MachineConstantPool.h11
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h1
-rw-r--r--include/llvm/Constant.h3
-rw-r--r--include/llvm/Function.h4
-rw-r--r--include/llvm/GlobalAlias.h3
-rw-r--r--include/llvm/GlobalVariable.h3
-rw-r--r--include/llvm/InlineAsm.h5
-rw-r--r--include/llvm/Instruction.h6
-rw-r--r--include/llvm/Module.h17
-rw-r--r--include/llvm/Support/ConstantRange.h7
-rw-r--r--include/llvm/Support/raw_ostream.h5
-rw-r--r--include/llvm/Type.h4
-rw-r--r--include/llvm/Value.h14
19 files changed, 51 insertions, 65 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index 25505c836e..6baf12383b 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -19,13 +19,13 @@
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <cstring>
-#include <iosfwd>
#include <string>
namespace llvm {
class Serializer;
class Deserializer;
class FoldingSetNodeID;
+ class raw_ostream;
template<typename T>
class SmallVectorImpl;
@@ -1115,8 +1115,7 @@ public:
/// @}
/// @name Conversion Functions
/// @{
-
- void print(std::ostream &OS, bool isSigned) const;
+ void print(raw_ostream &OS, bool isSigned) const;
/// toString - Converts an APInt to a string and append it to Str. Str is
/// commonly a SmallString.
@@ -1385,7 +1384,7 @@ inline bool operator!=(uint64_t V1, const APInt& V2) {
return V2 != V1;
}
-inline std::ostream &operator<<(std::ostream &OS, const APInt &I) {
+inline raw_ostream &operator<<(raw_ostream &OS, const APInt &I) {
I.print(OS, true);
return OS;
}
diff --git a/include/llvm/ADT/APSInt.h b/include/llvm/ADT/APSInt.h
index 00bece62ad..f16f49dc79 100644
--- a/include/llvm/ADT/APSInt.h
+++ b/include/llvm/ADT/APSInt.h
@@ -239,7 +239,7 @@ public:
void Profile(FoldingSetNodeID& ID) const;
};
-inline std::ostream &operator<<(std::ostream &OS, const APSInt &I) {
+inline raw_ostream &operator<<(raw_ostream &OS, const APSInt &I) {
I.print(OS, I.isSigned());
return OS;
}
diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h
index 650bee3d10..c69caab831 100644
--- a/include/llvm/Argument.h
+++ b/include/llvm/Argument.h
@@ -65,11 +65,6 @@ public:
/// removeAttr - Remove a ParamAttr from an argument
void removeAttr(ParameterAttributes);
- virtual void print(std::ostream &OS) const;
- void print(std::ostream *OS) const {
- if (OS) print(*OS);
- }
-
/// classof - Methods for support type inquiry through isa, cast, and
/// dyn_cast:
///
diff --git a/include/llvm/Assembly/AsmAnnotationWriter.h b/include/llvm/Assembly/AsmAnnotationWriter.h
index 62926bb007..b254940722 100644
--- a/include/llvm/Assembly/AsmAnnotationWriter.h
+++ b/include/llvm/Assembly/AsmAnnotationWriter.h
@@ -17,13 +17,12 @@
#ifndef LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H
#define LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H
-#include <iosfwd>
-
namespace llvm {
class Function;
class BasicBlock;
class Instruction;
+class raw_ostream;
struct AssemblyAnnotationWriter {
@@ -31,21 +30,21 @@ struct AssemblyAnnotationWriter {
// emitFunctionAnnot - This may be implemented to emit a string right before
// the start of a function.
- virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {}
+ virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {}
// emitBasicBlockStartAnnot - This may be implemented to emit a string right
// after the basic block label, but before the first instruction in the block.
- virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, std::ostream &OS){
+ virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, raw_ostream &OS){
}
// emitBasicBlockEndAnnot - This may be implemented to emit a string right
// after the basic block.
- virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){
+ virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS){
}
// emitInstructionAnnot - This may be implemented to emit a string right
// before an instruction is emitted.
- virtual void emitInstructionAnnot(const Instruction *I, std::ostream &OS) {}
+ virtual void emitInstructionAnnot(const Instruction *I, raw_ostream &OS) {}
};
} // End llvm namespace
diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h
index b4765df7a5..c9f8edb352 100644
--- a/include/llvm/Assembly/Writer.h
+++ b/include/llvm/Assembly/Writer.h
@@ -24,12 +24,14 @@ namespace llvm {
class Type;
class Module;
class Value;
+class raw_ostream;
// WriteTypeSymbolic - This attempts to write the specified type as a symbolic
// type, iff there is an entry in the Module's symbol table for the specified
// type or one of its component types. This is slower than a simple x << Type;
//
void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M);
+void WriteTypeSymbolic(raw_ostream &, const Type *, const Module *M);
// WriteAsOperand - Write the name of the specified value out to the specified
// ostream. This can be useful when you just want to print int %reg126, not the
@@ -39,6 +41,8 @@ void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M);
//
void WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true,
const Module *Context = 0);
+void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy = true,
+ const Module *Context = 0);
} // End llvm namespace
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index 6614a93883..fd729acd28 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -157,10 +157,6 @@ public:
const InstListType &getInstList() const { return InstList; }
InstListType &getInstList() { return InstList; }
- virtual void print(std::ostream &OS) const { print(OS, 0); }
- void print(std::ostream *OS) const { if (OS) print(*OS); }
- void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
-
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BasicBlock *) { return true; }
static inline bool classof(const Value *V) {
diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h
index ba491ce255..b6bf566f3f 100644
--- a/include/llvm/CodeGen/MachineConstantPool.h
+++ b/include/llvm/CodeGen/MachineConstantPool.h
@@ -29,6 +29,7 @@ class TargetData;
class TargetMachine;
class Type;
class MachineConstantPool;
+class raw_ostream;
/// Abstract base class for all machine specific constantpool value subclasses.
///
@@ -50,8 +51,9 @@ public:
/// print - Implement operator<<...
///
- virtual void print(std::ostream &O) const = 0;
+ void print(std::ostream &O) const;
void print(std::ostream *O) const { if (O) print(*O); }
+ virtual void print(raw_ostream &O) const = 0;
};
inline std::ostream &operator<<(std::ostream &OS,
@@ -59,6 +61,13 @@ inline std::ostream &operator<<(std::ostream &OS,
V.print(OS);
return OS;
}
+
+inline raw_ostream &operator<<(raw_ostream &OS,
+ const MachineConstantPoolValue &V) {
+ V.print(OS);
+ return OS;
+}
+
/// This class is a data container for one entry in a MachineConstantPool.
/// It contains a pointer to the value and an offset from the start of
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index 9796e066dd..6c1565916e 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -1260,6 +1260,7 @@ public:
///
std::string getOperationName(const SelectionDAG *G = 0) const;
static const char* getIndexedModeName(ISD::MemIndexedMode AM);
+ void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
void dump() const;
void dump(const SelectionDAG *G) const;
diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h
index faaced8041..12e1dd2db9 100644
--- a/include/llvm/Constant.h
+++ b/include/llvm/Constant.h
@@ -58,9 +58,6 @@ public:
/// getNullValue.
virtual bool isNullValue() const = 0;
- virtual void print(std::ostream &O) const;
- void print(std::ostream *O) const { if (O) print(*O); }
-
/// canTrap - Return true if evaluation of this constant could trap. This is
/// true for things like constant expressions that could divide by zero.
bool canTrap() const;
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index 04e0535ace..f302ff570f 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -301,10 +301,6 @@ public:
size_t arg_size() const;
bool arg_empty() const;
- virtual void print(std::ostream &OS) const { print(OS, 0); }
- void print(std::ostream *OS) const { if (OS) print(*OS); }
- void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
-
/// 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
/// program, displaying the CFG of the current function with the code for each
diff --git a/include/llvm/GlobalAlias.h b/include/llvm/GlobalAlias.h
index 124cf94fa9..4dfc9c4d5e 100644
--- a/include/llvm/GlobalAlias.h
+++ b/include/llvm/GlobalAlias.h
@@ -62,9 +62,6 @@ public:
///
void eraseFromParent();
- virtual void print(std::ostream &OS) const;
- void print(std::ostream *OS) const { if (OS) print(*OS); }
-
/// set/getAliasee - These methods retrive and set alias target.
void setAliasee(Constant* GV);
const Constant* getAliasee() const {
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index b6910d54c9..aae17e409d 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -133,9 +133,6 @@ public:
/// replace constant initializers.
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
- virtual void print(std::ostream &OS) const;
- void print(std::ostream *OS) const { if (OS) print(*OS); }
-
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const GlobalVariable *) { return true; }
static inline bool classof(const Value *V) {
diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h
index bb046c2a3c..325b777dd4 100644
--- a/include/llvm/InlineAsm.h
+++ b/include/llvm/InlineAsm.h
@@ -21,7 +21,6 @@
namespace llvm {
-struct AssemblyAnnotationWriter;
class PointerType;
class FunctionType;
class Module;
@@ -58,10 +57,6 @@ public:
const std::string &getAsmString() const { return AsmString; }
const std::string &getConstraintString() const { return Constraints; }
- virtual void print(std::ostream &O) const { print(O, 0); }
- void print(std::ostream *O) const { if (O) print(*O); }
- void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
-
/// Verify - This static method can be used by the parser to check to see if
/// the specified constraint string is legal for the type. This returns true
/// if legal, false if not.
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index ac33a68bbf..cec9144e35 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -20,8 +20,6 @@
namespace llvm {
-struct AssemblyAnnotationWriter;
-
template<typename ValueSubClass, typename ItemParentClass>
class SymbolTableListTraits;
@@ -180,10 +178,6 @@ public:
}
static bool isTrapping(unsigned op);
- virtual void print(std::ostream &OS) const { print(OS, 0); }
- void print(std::ostream *OS) const { if (OS) print(*OS); }
- void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
-
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Instruction *) { return true; }
static inline bool classof(const Value *V) {
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index 56207a0af2..de12157875 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -350,15 +350,11 @@ public:
/// @name Utility functions for printing and dumping Module objects
/// @{
public:
- /// Print the module to an output stream
- void print(std::ostream &OS) const { print(OS, 0); }
- void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Print the module to an output stream with AssemblyAnnotationWriter.
+ void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const;
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
- void print(std::ostream *OS, AssemblyAnnotationWriter *AAW) const {
- if (OS) print(*OS, AAW);
- }
- /// Dump the module to std::cerr (for debugging).
+
+ /// Dump the module to stderr (for debugging).
void dump() const;
/// This function causes all the subinstructions to "let go" of all references
/// that they are maintaining. This allows one to 'delete' a whole class at
@@ -385,9 +381,14 @@ public:
/// An iostream inserter for modules.
inline std::ostream &operator<<(std::ostream &O, const Module &M) {
- M.print(O);
+ M.print(O, 0);
+ return O;
+}
+inline raw_ostream &operator<<(raw_ostream &O, const Module &M) {
+ M.print(O, 0);
return O;
}
+
inline ValueSymbolTable *
ilist_traits<Function>::getSymTab(Module *M) {
diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h
index 2e477cf899..1a8907666f 100644
--- a/include/llvm/Support/ConstantRange.h
+++ b/include/llvm/Support/ConstantRange.h
@@ -32,8 +32,6 @@
#include "llvm/ADT/APInt.h"
#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Streams.h"
-#include <iosfwd>
namespace llvm {
@@ -180,15 +178,14 @@ class ConstantRange {
/// print - Print out the bounds to a stream...
///
- void print(std::ostream &OS) const;
- void print(std::ostream *OS) const { if (OS) print(*OS); }
+ void print(raw_ostream &OS) const;
/// dump - Allow printing from a debugger easily...
///
void dump() const;
};
-inline std::ostream &operator<<(std::ostream &OS, const ConstantRange &CR) {
+inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) {
CR.print(OS);
return OS;
}
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index e78cfe8641..9fb5f6cb38 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/include/llvm/Support/raw_ostream.h
@@ -96,7 +96,7 @@ public:
raw_ostream &operator<<(long N);
raw_ostream &operator<<(unsigned long long N);
raw_ostream &operator<<(long long N);
-
+ raw_ostream &operator<<(const void *P);
raw_ostream &operator<<(unsigned int N) {
return this->operator<<(static_cast<unsigned long>(N));
}
@@ -201,7 +201,8 @@ class raw_os_ostream : public raw_ostream {
std::ostream &OS;
public:
raw_os_ostream(std::ostream &O) : OS(O) {}
-
+ ~raw_os_ostream();
+
/// flush_impl - The is the piece of the class that is implemented by
/// subclasses. This outputs the currently buffered data and resets the
/// buffer to empty.
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 5bcb654a4a..ec970565dc 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -14,7 +14,6 @@
#include "llvm/AbstractTypeUser.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Streams.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator.h"
#include <string>
@@ -26,6 +25,7 @@ class DerivedType;
class PointerType;
class IntegerType;
class TypeMapBase;
+class raw_ostream;
/// This file contains the declaration of the Type class. For more "Type" type
/// stuff, look in DerivedTypes.h.
@@ -156,6 +156,7 @@ protected:
PATypeHandle *ContainedTys;
public:
+ void print(raw_ostream &O) const;
void print(std::ostream &O) const;
void print(std::ostream *O) const { if (O) print(*O); }
@@ -450,6 +451,7 @@ template <> inline bool isa_impl<PointerType, Type>(const Type &Ty) {
}
std::ostream &operator<<(std::ostream &OS, const Type &T);
+raw_ostream &operator<<(raw_ostream &OS, const Type &T);
} // End llvm namespace
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index 82e1502e58..ceb1ad246d 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -35,6 +35,8 @@ class ValueSymbolTable;
class TypeSymbolTable;
template<typename ValueTy> class StringMapEntry;
typedef StringMapEntry<Value*> ValueName;
+class raw_ostream;
+class AssemblyAnnotationWriter;
//===----------------------------------------------------------------------===//
// Value Class
@@ -76,10 +78,10 @@ public:
//
virtual void dump() const;
- /// print - Implement operator<< on Value...
+ /// print - Implement operator<< on Value.
///
- virtual void print(std::ostream &O) const = 0;
- void print(std::ostream *O) const { if (O) print(*O); }
+ void print(std::ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
+ void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
/// All values are typed, get the type of this value.
///
@@ -237,7 +239,11 @@ inline std::ostream &operator<<(std::ostream &OS, const Value &V) {
V.print(OS);
return OS;
}
-
+inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
+ V.print(OS);
+ return OS;
+}
+
void Use::init(Value *V, User *) {
Val = V;
if (V) V->addUse(*this);