1 //===-- llvm/Assembly/CachedWriter.h - Printer Accellerator ------*- C++ -*--=//
3 // This file defines a 'CacheWriter' class that is used to accelerate printing
4 // chunks of LLVM. This is used when a module is not being changed, but random
5 // parts of it need to be printed. This can greatly speed up printing of LLVM
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_ASSEMBLY_CACHED_WRITER_H
11 #define LLVM_ASSEMBLY_CACHED_WRITER_H
13 #include "llvm/Value.h"
19 class AssemblyWriter; // Internal private class
27 CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { }
28 CachedWriter(const Module *M, std::ostream &O = std::cout)
29 : AW(0), SC(0), Out(O) {
34 // setModule - Invalidate internal state, use the new module instead.
35 void setModule(const Module *M);
37 CachedWriter &operator<<(const Value *V);
39 inline CachedWriter &operator<<(Value *X) {
40 return *this << (const Value*)X;
42 inline CachedWriter &operator<<(const GlobalVariable *X) {
43 return *this << (const Value*)X;
45 inline CachedWriter &operator<<(const Function *X) {
46 return *this << (const Value*)X;
48 inline CachedWriter &operator<<(const Argument *X) {
49 return *this << (const Value*)X;
51 inline CachedWriter &operator<<(const BasicBlock *X) {
52 return *this << (const Value*)X;
54 inline CachedWriter &operator<<(const Instruction *X) {
55 return *this << (const Value*)X;
57 inline CachedWriter &operator<<(const Constant *X) {
58 return *this << (const Value*)X;
60 inline CachedWriter &operator<<(const Type *X) {
61 return *this << (const Value*)X;
63 inline CachedWriter &operator<<(const PointerType *X) {
64 return *this << (const Value*)X;
67 inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
68 Out << Manip; return *this;
72 inline CachedWriter &operator<<(const X &v) {