2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/Assembly/CachedWriter.h - Printer Accellerator -----*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// 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.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-07 04:20:50 +00:00
|
|
|
//
|
2004-01-08 22:21:58 +00:00
|
|
|
// This file defines a 'CachedWriter' class that is used to accelerate printing
|
2001-11-07 04:20:50 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-01-08 22:21:58 +00:00
|
|
|
#ifndef LLVM_ASSEMBLY_CACHEDWRITER_H
|
|
|
|
#define LLVM_ASSEMBLY_CACHEDWRITER_H
|
2001-11-07 04:20:50 +00:00
|
|
|
|
2002-04-08 21:52:32 +00:00
|
|
|
#include "llvm/Value.h"
|
2002-01-20 22:54:45 +00:00
|
|
|
#include <iostream>
|
2001-11-07 04:20:50 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-04-28 04:47:33 +00:00
|
|
|
class Module;
|
2002-04-08 21:52:32 +00:00
|
|
|
class PointerType;
|
|
|
|
class AssemblyWriter; // Internal private class
|
2004-07-15 02:51:31 +00:00
|
|
|
class SlotMachine;
|
2002-04-08 21:52:32 +00:00
|
|
|
|
2001-11-07 04:20:50 +00:00
|
|
|
class CachedWriter {
|
|
|
|
AssemblyWriter *AW;
|
2004-05-26 07:37:11 +00:00
|
|
|
SlotMachine *SC;
|
2004-04-28 15:30:33 +00:00
|
|
|
bool SymbolicTypes;
|
2004-06-04 21:10:35 +00:00
|
|
|
std::ostream &Out;
|
2004-04-28 15:30:33 +00:00
|
|
|
|
2004-04-28 19:22:58 +00:00
|
|
|
public:
|
2004-04-28 15:30:33 +00:00
|
|
|
enum TypeWriter {
|
|
|
|
SymTypeOn,
|
|
|
|
SymTypeOff
|
|
|
|
};
|
|
|
|
|
|
|
|
CachedWriter(std::ostream &O = std::cout)
|
2004-06-04 21:10:35 +00:00
|
|
|
: AW(0), SC(0), SymbolicTypes(false), Out(O) { }
|
2002-01-20 22:54:45 +00:00
|
|
|
CachedWriter(const Module *M, std::ostream &O = std::cout)
|
2004-06-04 21:10:35 +00:00
|
|
|
: AW(0), SC(0), SymbolicTypes(false), Out(O) {
|
2001-11-07 04:20:50 +00:00
|
|
|
setModule(M);
|
|
|
|
}
|
|
|
|
~CachedWriter();
|
|
|
|
|
|
|
|
// setModule - Invalidate internal state, use the new module instead.
|
|
|
|
void setModule(const Module *M);
|
|
|
|
|
2004-07-15 02:51:31 +00:00
|
|
|
CachedWriter &operator<<(const Value &V);
|
2004-04-28 19:22:58 +00:00
|
|
|
|
2004-07-15 02:51:31 +00:00
|
|
|
CachedWriter &operator<<(const Type &X);
|
2001-11-07 04:20:50 +00:00
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
|
2004-06-04 21:10:35 +00:00
|
|
|
Out << Manip; return *this;
|
2001-11-26 18:49:33 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 19:22:58 +00:00
|
|
|
inline CachedWriter& operator<<(const char *X) {
|
2004-06-04 21:10:35 +00:00
|
|
|
Out << X;
|
2004-04-28 19:22:58 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2004-04-28 15:30:33 +00:00
|
|
|
|
|
|
|
inline CachedWriter &operator<<(enum TypeWriter tw) {
|
|
|
|
SymbolicTypes = (tw == SymTypeOn);
|
|
|
|
return *this;
|
|
|
|
}
|
2001-11-26 18:49:33 +00:00
|
|
|
};
|
2001-11-07 05:31:53 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-11-07 04:20:50 +00:00
|
|
|
#endif
|