mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
if -bitcode is specified, read and write a bitcode file instead of a bytecode file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36830 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -10,6 +10,6 @@ LEVEL = ../..
|
|||||||
TOOLNAME = opt
|
TOOLNAME = opt
|
||||||
REQUIRES_EH := 1
|
REQUIRES_EH := 1
|
||||||
|
|
||||||
LINK_COMPONENTS := bcreader bcwriter instrumentation scalaropts ipo
|
LINK_COMPONENTS := bcreader bcwriter bitreader bitwriter instrumentation scalaropts ipo
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
#include "llvm/Bytecode/Reader.h"
|
||||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
#include "llvm/Bytecode/WriteBytecodePass.h"
|
||||||
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Assembly/PrintModulePass.h"
|
#include "llvm/Assembly/PrintModulePass.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/Analysis/LoopPass.h"
|
#include "llvm/Analysis/LoopPass.h"
|
||||||
@ -24,6 +25,7 @@
|
|||||||
#include "llvm/Support/PassNameParser.h"
|
#include "llvm/Support/PassNameParser.h"
|
||||||
#include "llvm/System/Signals.h"
|
#include "llvm/System/Signals.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/PluginLoader.h"
|
#include "llvm/Support/PluginLoader.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/Support/SystemUtils.h"
|
#include "llvm/Support/SystemUtils.h"
|
||||||
@ -35,6 +37,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
static cl::opt<bool> Bitcode("bitcode");
|
||||||
|
|
||||||
// The OptimizationList is automatically populated with registered Passes by the
|
// The OptimizationList is automatically populated with registered Passes by the
|
||||||
// PassNameParser.
|
// PassNameParser.
|
||||||
//
|
//
|
||||||
@ -262,8 +266,26 @@ int main(int argc, char **argv) {
|
|||||||
std::string ErrorMessage;
|
std::string ErrorMessage;
|
||||||
|
|
||||||
// Load the input module...
|
// Load the input module...
|
||||||
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
|
std::auto_ptr<Module> M;
|
||||||
Compressor::decompressToNewBuffer, &ErrorMessage));
|
if (Bitcode) {
|
||||||
|
MemoryBuffer *Buffer;
|
||||||
|
if (InputFilename == "-") {
|
||||||
|
Buffer = MemoryBuffer::getSTDIN();
|
||||||
|
} else {
|
||||||
|
Buffer = MemoryBuffer::getFile(&InputFilename[0], InputFilename.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Buffer == 0)
|
||||||
|
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||||
|
else
|
||||||
|
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
|
||||||
|
|
||||||
|
delete Buffer;
|
||||||
|
} else {
|
||||||
|
M.reset(ParseBytecodeFile(InputFilename,
|
||||||
|
Compressor::decompressToNewBuffer,
|
||||||
|
&ErrorMessage));
|
||||||
|
}
|
||||||
if (M.get() == 0) {
|
if (M.get() == 0) {
|
||||||
cerr << argv[0] << ": ";
|
cerr << argv[0] << ": ";
|
||||||
if (ErrorMessage.size())
|
if (ErrorMessage.size())
|
||||||
@ -355,8 +377,12 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Write bytecode out to disk or cout as the last step...
|
// Write bytecode out to disk or cout as the last step...
|
||||||
OStream L(*Out);
|
OStream L(*Out);
|
||||||
if (!NoOutput && !AnalyzeOnly)
|
if (!NoOutput && !AnalyzeOnly) {
|
||||||
Passes.add(new WriteBytecodePass(&L, false, !NoCompress));
|
if (Bitcode)
|
||||||
|
Passes.add(CreateBitcodeWriterPass(*Out));
|
||||||
|
else
|
||||||
|
Passes.add(new WriteBytecodePass(&L, false, !NoCompress));
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we have all of the passes ready, run them.
|
// Now that we have all of the passes ready, run them.
|
||||||
Passes.run(*M.get());
|
Passes.run(*M.get());
|
||||||
|
Reference in New Issue
Block a user