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