llvm.org GIT mirror llvm / 4bcca0f
switch this to bitcode instead of bytecode git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36867 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
5 changed file(s) with 17 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
88 LEVEL=../..
99 TOOLNAME=ModuleMaker
1010 EXAMPLE_TOOL = 1
11 LINK_COMPONENTS := bcwriter
11 LINK_COMPONENTS := bitwriter
1212
1313 include $(LEVEL)/Makefile.common
1616 #include "llvm/DerivedTypes.h"
1717 #include "llvm/Constants.h"
1818 #include "llvm/Instructions.h"
19 #include "llvm/Bytecode/Writer.h"
20 #include "llvm/Support/Streams.h"
19 #include "llvm/Bitcode/ReaderWriter.h"
20 #include
2121 using namespace llvm;
2222
2323 int main() {
5252 BB->getInstList().push_back(new ReturnInst(Add));
5353
5454 // Output the bytecode file to stdout
55 WriteBytecodeToFile(M, cout);
55 WriteBitcodeToFile(M, std::cout);
5656
5757 // Delete the module and all of its contents.
5858 delete M;
1313 #include "llvm/Debugger/Debugger.h"
1414 #include "llvm/Module.h"
1515 #include "llvm/ModuleProvider.h"
16 #include "llvm/Bytecode/Reader.h"
1716 #include "llvm/Bitcode/ReaderWriter.h"
1817 #include "llvm/Debugger/InferiorProcess.h"
1918 #include "llvm/Support/MemoryBuffer.h"
2120 #include
2221 using namespace llvm;
2322
24 static bool Bitcode = false;
25
2623 /// Debugger constructor - Initialize the debugger to its initial, empty, state.
2724 ///
2825 Debugger::Debugger() : Environment(0), Program(0), Process(0) {
4845
4946 static Module *
5047 getMaterializedModuleProvider(const std::string &Filename) {
51 if (Bitcode) {
52 return ParseBytecodeFile(Filename);
53 } else {
54 std::auto_ptr Buffer;
55 Buffer.reset(MemoryBuffer::getFileOrSTDIN(&Filename[0], Filename.size()));
56 if (Buffer.get())
57 return ParseBitcodeFile(Buffer.get());
58 return 0;
59 }
48 std::auto_ptr Buffer;
49 Buffer.reset(MemoryBuffer::getFileOrSTDIN(&Filename[0], Filename.size()));
50 if (Buffer.get())
51 return ParseBitcodeFile(Buffer.get());
52 return 0;
6053 }
6154
6255 /// loadProgram - If a program is currently loaded, unload it. Then search
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file contains routines to handle linking together LLVM bytecode files,
9 // This file contains routines to handle linking together LLVM bitcode files,
1010 // and to handle annoying things like static libraries.
1111 //
1212 //===----------------------------------------------------------------------===//
1515 #include "llvm/Module.h"
1616 #include "llvm/ModuleProvider.h"
1717 #include "llvm/ADT/SetOperations.h"
18 #include "llvm/Bytecode/Archive.h"
18 #include "llvm/Bitcode/Archive.h"
1919 #include "llvm/Config/config.h"
2020 #include
2121 #include
9595 // Open the archive file
9696 verbose("Linking archive file '" + Filename.toString() + "'");
9797
98 // Find all of the symbols currently undefined in the bytecode program.
98 // Find all of the symbols currently undefined in the bitcode program.
9999 // If all the symbols are defined, the program is complete, and there is
100100 // no reason to link in any archive files.
101101 std::set UndefinedSymbols;
1212
1313 #include "llvm/Linker.h"
1414 #include "llvm/Module.h"
15 #include "llvm/Bytecode/Reader.h"
1615 #include "llvm/Bitcode/ReaderWriter.h"
1716 #include "llvm/Config/config.h"
1817 #include "llvm/Support/MemoryBuffer.h"
1918 #include "llvm/Support/Streams.h"
20 #include "llvm/Support/Compressor.h"
2119 using namespace llvm;
22
23 static const bool Bitcode = false;
2420
2521 Linker::Linker(const std::string& progname, const std::string& modname, unsigned flags)
2622 : Composite(0)
106102 Module *Result = 0;
107103
108104 const std::string &FNS = FN.toString();
109 if (Bitcode) {
110 std::auto_ptr Buffer(
105 std::auto_ptr Buffer(
111106 MemoryBuffer::getFileOrSTDIN(&FNS[0], FNS.size()));
112 if (Buffer.get())
113 Result = ParseBitcodeFile(Buffer.get(), &ParseErrorMessage);
114 else
115 ParseErrorMessage = "Error reading file '" + FNS + "'";
107 if (Buffer.get())
108 Result = ParseBitcodeFile(Buffer.get(), &ParseErrorMessage);
109 else
110 ParseErrorMessage = "Error reading file '" + FNS + "'";
116111
117 } else {
118 Result = ParseBytecodeFile(FNS, Compressor::decompressToNewBuffer,
119 &ParseErrorMessage);
120 }
121112 if (Result)
122113 return std::auto_ptr(Result);
123114 Error = "Bytecode file '" + FN.toString() + "' could not be loaded";