Add lvxl
[oota-llvm.git] / include / llvm / Assembly / CachedWriter.h
1 //===-- llvm/Assembly/CachedWriter.h - Printer Accellerator -----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a 'CachedWriter' class that is used to accelerate printing
11 // chunks of LLVM.  This is used when a module is not being changed, but random
12 // parts of it need to be printed.  This can greatly speed up printing of LLVM
13 // output.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ASSEMBLY_CACHEDWRITER_H
18 #define LLVM_ASSEMBLY_CACHEDWRITER_H
19
20 #include "llvm/Value.h"
21 #include <iostream>
22
23 namespace llvm {
24
25 class Module;
26 class PointerType;
27 class AssemblyWriter;  // Internal private class
28 class SlotMachine;
29
30 class CachedWriter {
31   AssemblyWriter *AW;
32   SlotMachine *SC;
33   bool SymbolicTypes;
34   std::ostream &Out;
35
36 public:
37   enum TypeWriter {
38     SymTypeOn,
39     SymTypeOff
40   };
41
42   CachedWriter(std::ostream &O = std::cout)
43     : AW(0), SC(0), SymbolicTypes(false), Out(O) { }
44   CachedWriter(const Module *M, std::ostream &O = std::cout)
45     : AW(0), SC(0), SymbolicTypes(false), Out(O) {
46     setModule(M);
47   }
48   ~CachedWriter();
49
50   // setModule - Invalidate internal state, use the new module instead.
51   void setModule(const Module *M);
52
53   CachedWriter &operator<<(const Value &V);
54
55   CachedWriter &operator<<(const Type &X);
56
57   inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
58     Out << Manip; return *this;
59   }
60
61   inline CachedWriter& operator<<(const char *X) {
62     Out << X;
63     return *this;
64   }
65
66   inline CachedWriter &operator<<(enum TypeWriter tw) {
67     SymbolicTypes = (tw == SymTypeOn);
68     return *this;
69   }
70 };
71
72 } // End llvm namespace
73
74 #endif