2003-09-30 20:37:50 +02:00
|
|
|
//===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass -*- C++ -*-===//
|
2005-04-21 22:39:54 +02:00
|
|
|
//
|
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.
|
2005-04-21 22:39:54 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-18 22:31:42 +02:00
|
|
|
//
|
|
|
|
// 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-26 00:04:00 +02:00
|
|
|
#include <iostream>
|
2001-10-18 22:31:42 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2004-09-20 06:48:05 +02:00
|
|
|
class WriteBytecodePass : public ModulePass {
|
2002-06-25 22:22:25 +02:00
|
|
|
std::ostream *Out; // ostream to print on
|
2001-10-18 22:31:42 +02:00
|
|
|
bool DeleteStream;
|
2004-11-07 06:30:43 +01:00
|
|
|
bool CompressFile;
|
2001-10-18 22:31:42 +02:00
|
|
|
public:
|
2005-04-21 22:39:54 +02:00
|
|
|
WriteBytecodePass()
|
2004-11-07 06:30:43 +01:00
|
|
|
: Out(&std::cout), DeleteStream(false), CompressFile(true) {}
|
2005-04-21 22:39:54 +02:00
|
|
|
WriteBytecodePass(std::ostream *o, bool DS = false, bool CF = true)
|
2004-11-08 20:01:03 +01:00
|
|
|
: Out(o), DeleteStream(DS), CompressFile(CF) {}
|
2001-10-18 22:31:42 +02:00
|
|
|
|
|
|
|
inline ~WriteBytecodePass() {
|
|
|
|
if (DeleteStream) delete Out;
|
|
|
|
}
|
2005-04-21 22:39:54 +02:00
|
|
|
|
2004-09-20 06:48:05 +02:00
|
|
|
bool runOnModule(Module &M) {
|
2004-11-07 06:30:43 +01:00
|
|
|
WriteBytecodeToFile(&M, *Out, CompressFile );
|
2001-10-18 22:31:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-10-18 22:31:42 +02:00
|
|
|
#endif
|