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