diff --git a/include/llvm/Assembly/CachedWriter.h b/include/llvm/Assembly/CachedWriter.h deleted file mode 100644 index 5d5049c5e67..00000000000 --- a/include/llvm/Assembly/CachedWriter.h +++ /dev/null @@ -1,74 +0,0 @@ -//===-- llvm/Assembly/CachedWriter.h - Printer Accellerator -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a 'CachedWriter' class that is used to accelerate printing -// chunks of LLVM. This is used when a module is not being changed, but random -// parts of it need to be printed. This can greatly speed up printing of LLVM -// output. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ASSEMBLY_CACHEDWRITER_H -#define LLVM_ASSEMBLY_CACHEDWRITER_H - -#include "llvm/Value.h" -#include - -namespace llvm { - -class Module; -class PointerType; -class AssemblyWriter; // Internal private class -class SlotMachine; - -class CachedWriter { - AssemblyWriter *AW; - SlotMachine *SC; - bool SymbolicTypes; - std::ostream &Out; - -public: - enum TypeWriter { - SymTypeOn, - SymTypeOff - }; - - CachedWriter(std::ostream &O = std::cout) - : AW(0), SC(0), SymbolicTypes(false), Out(O) { } - CachedWriter(const Module *M, std::ostream &O = std::cout) - : AW(0), SC(0), SymbolicTypes(false), Out(O) { - setModule(M); - } - ~CachedWriter(); - - // setModule - Invalidate internal state, use the new module instead. - void setModule(const Module *M); - - CachedWriter &operator<<(const Value &V); - - CachedWriter &operator<<(const Type &X); - - inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) { - Out << Manip; return *this; - } - - inline CachedWriter& operator<<(const char *X) { - Out << X; - return *this; - } - - inline CachedWriter &operator<<(enum TypeWriter tw) { - SymbolicTypes = (tw == SymTypeOn); - return *this; - } -}; - -} // End llvm namespace - -#endif diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 4bfe4ecc844..30baed4c64c 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -14,7 +14,6 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Assembly/CachedWriter.h" #include "llvm/Assembly/Writer.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Assembly/AsmAnnotationWriter.h" @@ -32,6 +31,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/Streams.h" #include +#include using namespace llvm; namespace llvm { @@ -322,10 +322,10 @@ static void calcTypeName(const Type *Ty, break; default: Result += ""; + break; } TypeStack.pop_back(); // Remove self from stack... - return; } @@ -364,16 +364,14 @@ std::ostream &llvm::WriteTypeSymbolic(std::ostream &Out, const Type *Ty, const Module *M) { Out << ' '; - // If they want us to print out a type, attempt to make it symbolic if there - // is a symbol table in the module... - if (M) { - std::map TypeNames; - fillTypeNameTable(M, TypeNames); - - return printTypeInt(Out, Ty, TypeNames); - } else { + // If they want us to print out a type, but there is no context, we can't + // print it symbolically. + if (!M) return Out << Ty->getDescription(); - } + + std::map TypeNames; + fillTypeNameTable(M, TypeNames); + return printTypeInt(Out, Ty, TypeNames); } // PrintEscapedString - Print each character of the specified string, escaping @@ -391,7 +389,7 @@ static void PrintEscapedString(const std::string &Str, std::ostream &Out) { } } -static const char * getPredicateText(unsigned predicate) { +static const char *getPredicateText(unsigned predicate) { const char * pred = "unknown"; switch (predicate) { case FCmpInst::FCMP_FALSE: pred = "false"; break; @@ -1337,51 +1335,7 @@ void Value::dump() const { print(std::cerr); llvm_cerr << '\n'; } void Type::dump() const { print(std::cerr); llvm_cerr << '\n'; } //===----------------------------------------------------------------------===// -// CachedWriter Class Implementation -//===----------------------------------------------------------------------===// - -void CachedWriter::setModule(const Module *M) { - delete SC; delete AW; - if (M) { - SC = new SlotMachine(M); - AW = new AssemblyWriter(Out, *SC, M, 0); - } else { - SC = 0; AW = 0; - } -} - -CachedWriter::~CachedWriter() { - delete AW; - delete SC; -} - -CachedWriter &CachedWriter::operator<<(const Value &V) { - assert(AW && SC && "CachedWriter does not have a current module!"); - if (const Instruction *I = dyn_cast(&V)) - AW->write(I); - else if (const BasicBlock *BB = dyn_cast(&V)) - AW->write(BB); - else if (const Function *F = dyn_cast(&V)) - AW->write(F); - else if (const GlobalVariable *GV = dyn_cast(&V)) - AW->write(GV); - else - AW->writeOperand(&V, true); - return *this; -} - -CachedWriter& CachedWriter::operator<<(const Type &Ty) { - if (SymbolicTypes) { - const Module *M = AW->getModule(); - if (M) WriteTypeSymbolic(Out, &Ty, M); - } else { - AW->write(&Ty); - } - return *this; -} - -//===----------------------------------------------------------------------===// -//===-- SlotMachine Implementation +// SlotMachine Implementation //===----------------------------------------------------------------------===// #if 0