llvm-6502/include/llvm/Assembly/CachedWriter.h
Reid Spencer 798ff64328 Part of bug 122:
This change removes the BuildBytecodeInfo flag from the SlotCalculator
class. This flag was needed to distinguish between the Bytecode/Writer
and the AsmWriter. Now that AsmWriter doesn't use SlotCalculator, we can
remove this flag and simplify some code. Also, some minor name changes
to CachedWriter.h needed to be committed (missed in previous commit).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13785 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 07:37:11 +00:00

90 lines
2.3 KiB
C++

//===-- 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 <iostream>
namespace {
class SlotMachine; // Internal private class
}
namespace llvm {
class Module;
class PointerType;
class AssemblyWriter; // Internal private class
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);
inline CachedWriter &operator<<(const Value &X) {
return *this << &X;
}
CachedWriter &operator<<(const Type *X);
inline CachedWriter &operator<<(const PointerType *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<<(const std::string &X) {
*Out << X;
return *this;
}
inline CachedWriter &operator<<(enum TypeWriter tw) {
SymbolicTypes = (tw == SymTypeOn);
return *this;
}
inline std::ostream& getStream() { return *Out; }
void setStream(std::ostream &os);
};
} // End llvm namespace
#endif