LLVM API Documentation
00001 //===-- llvm/Assembly/CachedWriter.h - Printer Accellerator -----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines a 'CachedWriter' class that is used to accelerate printing 00011 // chunks of LLVM. This is used when a module is not being changed, but random 00012 // parts of it need to be printed. This can greatly speed up printing of LLVM 00013 // output. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #ifndef LLVM_ASSEMBLY_CACHEDWRITER_H 00018 #define LLVM_ASSEMBLY_CACHEDWRITER_H 00019 00020 #include "llvm/Value.h" 00021 #include <iostream> 00022 00023 namespace llvm { 00024 00025 class Module; 00026 class PointerType; 00027 class AssemblyWriter; // Internal private class 00028 class SlotMachine; 00029 00030 class CachedWriter { 00031 AssemblyWriter *AW; 00032 SlotMachine *SC; 00033 bool SymbolicTypes; 00034 std::ostream &Out; 00035 00036 public: 00037 enum TypeWriter { 00038 SymTypeOn, 00039 SymTypeOff 00040 }; 00041 00042 CachedWriter(std::ostream &O = std::cout) 00043 : AW(0), SC(0), SymbolicTypes(false), Out(O) { } 00044 CachedWriter(const Module *M, std::ostream &O = std::cout) 00045 : AW(0), SC(0), SymbolicTypes(false), Out(O) { 00046 setModule(M); 00047 } 00048 ~CachedWriter(); 00049 00050 // setModule - Invalidate internal state, use the new module instead. 00051 void setModule(const Module *M); 00052 00053 CachedWriter &operator<<(const Value &V); 00054 00055 CachedWriter &operator<<(const Type &X); 00056 00057 inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) { 00058 Out << Manip; return *this; 00059 } 00060 00061 inline CachedWriter& operator<<(const char *X) { 00062 Out << X; 00063 return *this; 00064 } 00065 00066 inline CachedWriter &operator<<(enum TypeWriter tw) { 00067 SymbolicTypes = (tw == SymTypeOn); 00068 return *this; 00069 } 00070 }; 00071 00072 } // End llvm namespace 00073 00074 #endif