mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
add bitcode support
llvm-svn: 36855
This commit is contained in:
parent
bfe6f01d65
commit
c0fa93d591
@ -16,7 +16,6 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/ModuleProvider.h"
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/ADT/SetOperations.h"
|
#include "llvm/ADT/SetOperations.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
|
||||||
#include "llvm/Bytecode/Archive.h"
|
#include "llvm/Bytecode/Archive.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -83,6 +83,7 @@ bool Linker::LinkInLibrary(const std::string& Lib, bool& is_native) {
|
|||||||
return warning("Supposed library '" + Lib + "' isn't a library.");
|
return warning("Supposed library '" + Lib + "' isn't a library.");
|
||||||
|
|
||||||
case sys::Bytecode_FileType:
|
case sys::Bytecode_FileType:
|
||||||
|
case sys::Bitcode_FileType:
|
||||||
case sys::CompressedBytecode_FileType:
|
case sys::CompressedBytecode_FileType:
|
||||||
// LLVM ".so" file.
|
// LLVM ".so" file.
|
||||||
if (LinkInFile(Pathname, is_native))
|
if (LinkInFile(Pathname, is_native))
|
||||||
@ -175,6 +176,7 @@ bool Linker::LinkInFile(const sys::Path &File, bool &is_native) {
|
|||||||
return error("Cannot link archive '" + File.toString() + "'");
|
return error("Cannot link archive '" + File.toString() + "'");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case sys::Bitcode_FileType:
|
||||||
case sys::Bytecode_FileType:
|
case sys::Bytecode_FileType:
|
||||||
case sys::CompressedBytecode_FileType: {
|
case sys::CompressedBytecode_FileType: {
|
||||||
verbose("Linking bytecode file '" + File.toString() + "'");
|
verbose("Linking bytecode file '" + File.toString() + "'");
|
||||||
|
@ -14,11 +14,15 @@
|
|||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
#include "llvm/Bytecode/Reader.h"
|
||||||
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/Support/Compressor.h"
|
#include "llvm/Support/Compressor.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
static const bool Bitcode = false;
|
||||||
|
|
||||||
Linker::Linker(const std::string& progname, const std::string& modname, unsigned flags)
|
Linker::Linker(const std::string& progname, const std::string& modname, unsigned flags)
|
||||||
: Composite(0)
|
: Composite(0)
|
||||||
, LibPaths()
|
, LibPaths()
|
||||||
@ -100,9 +104,21 @@ Linker::releaseModule() {
|
|||||||
std::auto_ptr<Module>
|
std::auto_ptr<Module>
|
||||||
Linker::LoadObject(const sys::Path &FN) {
|
Linker::LoadObject(const sys::Path &FN) {
|
||||||
std::string ParseErrorMessage;
|
std::string ParseErrorMessage;
|
||||||
Module *Result = ParseBytecodeFile(FN.toString(),
|
Module *Result = 0;
|
||||||
Compressor::decompressToNewBuffer,
|
|
||||||
&ParseErrorMessage);
|
const std::string &FNS = FN.toString();
|
||||||
|
if (Bitcode) {
|
||||||
|
std::auto_ptr<MemoryBuffer> Buffer(
|
||||||
|
MemoryBuffer::getFileOrSTDIN(&FNS[0], FNS.size()));
|
||||||
|
if (Buffer.get())
|
||||||
|
Result = ParseBitcodeFile(Buffer.get(), &ParseErrorMessage);
|
||||||
|
else
|
||||||
|
ParseErrorMessage = "Error reading file '" + FNS + "'";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Result = ParseBytecodeFile(FNS, Compressor::decompressToNewBuffer,
|
||||||
|
&ParseErrorMessage);
|
||||||
|
}
|
||||||
if (Result)
|
if (Result)
|
||||||
return std::auto_ptr<Module>(Result);
|
return std::auto_ptr<Module>(Result);
|
||||||
Error = "Bytecode file '" + FN.toString() + "' could not be loaded";
|
Error = "Bytecode file '" + FN.toString() + "' could not be loaded";
|
||||||
@ -137,6 +153,8 @@ static inline sys::Path IsLibrary(const std::string& Name,
|
|||||||
return FullPath;
|
return FullPath;
|
||||||
if (FullPath.isBytecodeFile()) // .so file containing bytecode?
|
if (FullPath.isBytecodeFile()) // .so file containing bytecode?
|
||||||
return FullPath;
|
return FullPath;
|
||||||
|
if (FullPath.isBitcodeFile()) // .so file containing bitcode?
|
||||||
|
return FullPath;
|
||||||
|
|
||||||
// Not found .. fall through
|
// Not found .. fall through
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user