llvm.org GIT mirror llvm / 1a019e5
add bitcode support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36855 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
3 changed file(s) with 23 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1515 #include "llvm/Module.h"
1616 #include "llvm/ModuleProvider.h"
1717 #include "llvm/ADT/SetOperations.h"
18 #include "llvm/Bytecode/Reader.h"
1918 #include "llvm/Bytecode/Archive.h"
2019 #include "llvm/Config/config.h"
2120 #include
8282 return warning("Supposed library '" + Lib + "' isn't a library.");
8383
8484 case sys::Bytecode_FileType:
85 case sys::Bitcode_FileType:
8586 case sys::CompressedBytecode_FileType:
8687 // LLVM ".so" file.
8788 if (LinkInFile(Pathname, is_native))
174175 return error("Cannot link archive '" + File.toString() + "'");
175176 break;
176177
178 case sys::Bitcode_FileType:
177179 case sys::Bytecode_FileType:
178180 case sys::CompressedBytecode_FileType: {
179181 verbose("Linking bytecode file '" + File.toString() + "'");
1313 #include "llvm/Linker.h"
1414 #include "llvm/Module.h"
1515 #include "llvm/Bytecode/Reader.h"
16 #include "llvm/Bitcode/ReaderWriter.h"
1617 #include "llvm/Config/config.h"
18 #include "llvm/Support/MemoryBuffer.h"
1719 #include "llvm/Support/Streams.h"
1820 #include "llvm/Support/Compressor.h"
1921 using namespace llvm;
22
23 static const bool Bitcode = false;
2024
2125 Linker::Linker(const std::string& progname, const std::string& modname, unsigned flags)
2226 : Composite(0)
99103 std::auto_ptr
100104 Linker::LoadObject(const sys::Path &FN) {
101105 std::string ParseErrorMessage;
102 Module *Result = ParseBytecodeFile(FN.toString(),
103 Compressor::decompressToNewBuffer,
104 &ParseErrorMessage);
106 Module *Result = 0;
107
108 const std::string &FNS = FN.toString();
109 if (Bitcode) {
110 std::auto_ptr Buffer(
111 MemoryBuffer::getFileOrSTDIN(&FNS[0], FNS.size()));
112 if (Buffer.get())
113 Result = ParseBitcodeFile(Buffer.get(), &ParseErrorMessage);
114 else
115 ParseErrorMessage = "Error reading file '" + FNS + "'";
116
117 } else {
118 Result = ParseBytecodeFile(FNS, Compressor::decompressToNewBuffer,
119 &ParseErrorMessage);
120 }
105121 if (Result)
106122 return std::auto_ptr(Result);
107123 Error = "Bytecode file '" + FN.toString() + "' could not be loaded";
136152 return FullPath;
137153 if (FullPath.isBytecodeFile()) // .so file containing bytecode?
138154 return FullPath;
155 if (FullPath.isBitcodeFile()) // .so file containing bitcode?
156 return FullPath;
139157
140158 // Not found .. fall through
141159