2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/Assembly/CachedWriter.h - Printer Accellerator -----*- C++ -*-===//
|
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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-07 04:20:50 +00:00
|
|
|
//
|
|
|
|
// This file defines a 'CacheWriter' class that is used to accelerate printing
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ASSEMBLY_CACHED_WRITER_H
|
|
|
|
#define LLVM_ASSEMBLY_CACHED_WRITER_H
|
|
|
|
|
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;
|
2001-11-07 04:20:50 +00:00
|
|
|
class SlotCalculator;
|
2002-04-08 21:52:32 +00:00
|
|
|
class AssemblyWriter; // Internal private class
|
|
|
|
|
2001-11-07 04:20:50 +00:00
|
|
|
class CachedWriter {
|
|
|
|
AssemblyWriter *AW;
|
|
|
|
SlotCalculator *SC;
|
2001-11-07 05:31:53 +00:00
|
|
|
public:
|
2002-01-20 22:54:45 +00:00
|
|
|
std::ostream &Out;
|
2001-11-07 04:20:50 +00:00
|
|
|
public:
|
2002-01-20 22:54:45 +00:00
|
|
|
CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { }
|
|
|
|
CachedWriter(const Module *M, std::ostream &O = std::cout)
|
|
|
|
: AW(0), SC(0), 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);
|
|
|
|
|
|
|
|
CachedWriter &operator<<(const Value *V);
|
|
|
|
|
2001-11-07 05:31:53 +00:00
|
|
|
inline CachedWriter &operator<<(Value *X) {
|
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
|
|
|
inline CachedWriter &operator<<(const GlobalVariable *X) {
|
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
2002-03-26 17:49:55 +00:00
|
|
|
inline CachedWriter &operator<<(const Function *X) {
|
2001-11-07 05:31:53 +00:00
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
2002-04-09 19:59:31 +00:00
|
|
|
inline CachedWriter &operator<<(const Argument *X) {
|
2001-11-07 05:31:53 +00:00
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
|
|
|
inline CachedWriter &operator<<(const BasicBlock *X) {
|
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
|
|
|
inline CachedWriter &operator<<(const Instruction *X) {
|
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
2001-12-03 22:26:30 +00:00
|
|
|
inline CachedWriter &operator<<(const Constant *X) {
|
2001-11-07 05:31:53 +00:00
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
|
|
|
inline CachedWriter &operator<<(const Type *X) {
|
|
|
|
return *this << (const Value*)X;
|
|
|
|
}
|
|
|
|
inline CachedWriter &operator<<(const PointerType *X) {
|
|
|
|
return *this << (const Value*)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 &)) {
|
2001-11-26 18:49:33 +00:00
|
|
|
Out << Manip; return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class X>
|
|
|
|
inline CachedWriter &operator<<(const X &v) {
|
|
|
|
Out << v;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
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
|