2001-10-18 20:31:42 +00:00
|
|
|
//===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass --*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This file defines a simple pass to write the working module to a file after
|
|
|
|
// pass processing is completed.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_BYTECODE_WRITEBYTECODEPASS_H
|
|
|
|
#define LLVM_BYTECODE_WRITEBYTECODEPASS_H
|
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include "llvm/Bytecode/Writer.h"
|
2002-06-25 22:04:00 +00:00
|
|
|
#include <iostream>
|
2001-10-18 20:31:42 +00:00
|
|
|
|
|
|
|
class WriteBytecodePass : public Pass {
|
2002-06-25 20:22:25 +00:00
|
|
|
std::ostream *Out; // ostream to print on
|
2001-10-18 20:31:42 +00:00
|
|
|
bool DeleteStream;
|
|
|
|
public:
|
2002-07-23 19:56:03 +00:00
|
|
|
WriteBytecodePass() : Out(&std::cout), DeleteStream(false) {}
|
|
|
|
WriteBytecodePass(std::ostream *o, bool DS = false)
|
2001-10-18 20:31:42 +00:00
|
|
|
: Out(o), DeleteStream(DS) {
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ~WriteBytecodePass() {
|
|
|
|
if (DeleteStream) delete Out;
|
|
|
|
}
|
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
bool run(Module &M) {
|
|
|
|
WriteBytecodeToFile(&M, *Out);
|
2001-10-18 20:31:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|