mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[Orc] Merge some common code for creating CompileCallbackManagers and
IndirectStubsManagers. llvm-svn: 270874
This commit is contained in:
parent
f14e0f0a96
commit
3b3dc310e9
@ -328,6 +328,20 @@ private:
|
|||||||
StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
|
StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief Create a local compile callback manager.
|
||||||
|
///
|
||||||
|
/// The given target triple will determine the ABI, and the given
|
||||||
|
/// ErrorHandlerAddress will be used by the resulting compile callback
|
||||||
|
/// manager if a compile callback fails.
|
||||||
|
std::unique_ptr<JITCompileCallbackManager>
|
||||||
|
createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress);
|
||||||
|
|
||||||
|
/// @brief Create a local indriect stubs manager builder.
|
||||||
|
///
|
||||||
|
/// The given target triple will determine the ABI.
|
||||||
|
std::function<std::unique_ptr<IndirectStubsManager>()>
|
||||||
|
createLocalIndirectStubsManagerBuilder(Triple T);
|
||||||
|
|
||||||
/// @brief Build a function pointer of FunctionType with the given constant
|
/// @brief Build a function pointer of FunctionType with the given constant
|
||||||
/// address.
|
/// address.
|
||||||
///
|
///
|
||||||
|
@ -4,7 +4,6 @@ add_llvm_library(LLVMOrcJIT
|
|||||||
NullResolver.cpp
|
NullResolver.cpp
|
||||||
OrcABISupport.cpp
|
OrcABISupport.cpp
|
||||||
OrcCBindings.cpp
|
OrcCBindings.cpp
|
||||||
OrcCBindingsStack.cpp
|
|
||||||
OrcError.cpp
|
OrcError.cpp
|
||||||
OrcMCJITReplacement.cpp
|
OrcMCJITReplacement.cpp
|
||||||
OrcRemoteTargetRPCAPI.cpp
|
OrcRemoteTargetRPCAPI.cpp
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/Triple.h"
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
|
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
|
||||||
|
#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
|
||||||
#include "llvm/IR/CallSite.h"
|
#include "llvm/IR/CallSite.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
#include "llvm/Transforms/Utils/Cloning.h"
|
#include "llvm/Transforms/Utils/Cloning.h"
|
||||||
@ -21,6 +22,54 @@ namespace orc {
|
|||||||
void JITCompileCallbackManager::anchor() {}
|
void JITCompileCallbackManager::anchor() {}
|
||||||
void IndirectStubsManager::anchor() {}
|
void IndirectStubsManager::anchor() {}
|
||||||
|
|
||||||
|
std::unique_ptr<JITCompileCallbackManager>
|
||||||
|
createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress) {
|
||||||
|
switch (T.getArch()) {
|
||||||
|
default: return nullptr;
|
||||||
|
|
||||||
|
case Triple::x86: {
|
||||||
|
typedef orc::LocalJITCompileCallbackManager<orc::OrcI386> CCMgrT;
|
||||||
|
return llvm::make_unique<CCMgrT>(ErrorHandlerAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
case Triple::x86_64: {
|
||||||
|
if ( T.getOS() == Triple::OSType::Win32 ) {
|
||||||
|
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_Win32> CCMgrT;
|
||||||
|
return llvm::make_unique<CCMgrT>(ErrorHandlerAddress);
|
||||||
|
} else {
|
||||||
|
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_SysV> CCMgrT;
|
||||||
|
return llvm::make_unique<CCMgrT>(ErrorHandlerAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::function<std::unique_ptr<IndirectStubsManager>()>
|
||||||
|
createLocalIndirectStubsManagerBuilder(Triple T) {
|
||||||
|
switch (T.getArch()) {
|
||||||
|
default: return nullptr;
|
||||||
|
|
||||||
|
case Triple::x86:
|
||||||
|
return [](){
|
||||||
|
return llvm::make_unique<
|
||||||
|
orc::LocalIndirectStubsManager<orc::OrcI386>>();
|
||||||
|
};
|
||||||
|
|
||||||
|
case Triple::x86_64:
|
||||||
|
if (T.getOS() == Triple::OSType::Win32) {
|
||||||
|
return [](){
|
||||||
|
return llvm::make_unique<
|
||||||
|
orc::LocalIndirectStubsManager<orc::OrcX86_64_Win32>>();
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return [](){
|
||||||
|
return llvm::make_unique<
|
||||||
|
orc::LocalIndirectStubsManager<orc::OrcX86_64_SysV>>();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Constant* createIRTypedAddress(FunctionType &FT, TargetAddress Addr) {
|
Constant* createIRTypedAddress(FunctionType &FT, TargetAddress Addr) {
|
||||||
Constant *AddrIntVal =
|
Constant *AddrIntVal =
|
||||||
ConstantInt::get(Type::getInt64Ty(FT.getContext()), Addr);
|
ConstantInt::get(Type::getInt64Ty(FT.getContext()), Addr);
|
||||||
|
@ -17,9 +17,9 @@ LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM) {
|
|||||||
|
|
||||||
Triple T(TM2->getTargetTriple());
|
Triple T(TM2->getTargetTriple());
|
||||||
|
|
||||||
auto CompileCallbackMgr = OrcCBindingsStack::createCompileCallbackMgr(T);
|
auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
|
||||||
auto IndirectStubsMgrBuilder =
|
auto IndirectStubsMgrBuilder =
|
||||||
OrcCBindingsStack::createIndirectStubsMgrBuilder(T);
|
orc::createLocalIndirectStubsManagerBuilder(T);
|
||||||
|
|
||||||
OrcCBindingsStack *JITStack = new OrcCBindingsStack(
|
OrcCBindingsStack *JITStack = new OrcCBindingsStack(
|
||||||
*TM2, std::move(CompileCallbackMgr), IndirectStubsMgrBuilder);
|
*TM2, std::move(CompileCallbackMgr), IndirectStubsMgrBuilder);
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
//===-------- OrcCBindingsStack.cpp - Orc JIT stack for C bindings --------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is distributed under the University of Illinois Open Source
|
|
||||||
// License. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include "OrcCBindingsStack.h"
|
|
||||||
|
|
||||||
#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
|
|
||||||
#include "llvm/Support/Debug.h"
|
|
||||||
#include "llvm/Support/DynamicLibrary.h"
|
|
||||||
#include <cstdio>
|
|
||||||
#include <system_error>
|
|
||||||
|
|
||||||
using namespace llvm;
|
|
||||||
|
|
||||||
std::unique_ptr<OrcCBindingsStack::CompileCallbackMgr>
|
|
||||||
OrcCBindingsStack::createCompileCallbackMgr(Triple T) {
|
|
||||||
switch (T.getArch()) {
|
|
||||||
default:
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
case Triple::x86: {
|
|
||||||
typedef orc::LocalJITCompileCallbackManager<orc::OrcI386> CCMgrT;
|
|
||||||
return llvm::make_unique<CCMgrT>(0);
|
|
||||||
};
|
|
||||||
|
|
||||||
case Triple::x86_64: {
|
|
||||||
if ( T.getOS() == Triple::OSType::Win32 ) {
|
|
||||||
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_Win32> CCMgrT;
|
|
||||||
return llvm::make_unique<CCMgrT>(0);
|
|
||||||
} else {
|
|
||||||
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_SysV> CCMgrT;
|
|
||||||
return llvm::make_unique<CCMgrT>(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OrcCBindingsStack::IndirectStubsManagerBuilder
|
|
||||||
OrcCBindingsStack::createIndirectStubsMgrBuilder(Triple T) {
|
|
||||||
switch (T.getArch()) {
|
|
||||||
default:
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
case Triple::x86:
|
|
||||||
return []() {
|
|
||||||
return llvm::make_unique<orc::LocalIndirectStubsManager<orc::OrcI386>>();
|
|
||||||
};
|
|
||||||
|
|
||||||
case Triple::x86_64:
|
|
||||||
if (T.getOS() == Triple::OSType::Win32) {
|
|
||||||
return [](){
|
|
||||||
return llvm::make_unique<
|
|
||||||
orc::LocalIndirectStubsManager<orc::OrcX86_64_Win32>>();
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return [](){
|
|
||||||
return llvm::make_unique<
|
|
||||||
orc::LocalIndirectStubsManager<orc::OrcX86_64_SysV>>();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -79,9 +79,6 @@ public:
|
|||||||
|
|
||||||
typedef unsigned ModuleHandleT;
|
typedef unsigned ModuleHandleT;
|
||||||
|
|
||||||
static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T);
|
|
||||||
static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);
|
|
||||||
|
|
||||||
OrcCBindingsStack(TargetMachine &TM,
|
OrcCBindingsStack(TargetMachine &TM,
|
||||||
std::unique_ptr<CompileCallbackMgr> CCMgr,
|
std::unique_ptr<CompileCallbackMgr> CCMgr,
|
||||||
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
|
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
|
||||||
|
@ -46,54 +46,6 @@ namespace {
|
|||||||
cl::init(true), cl::Hidden);
|
cl::init(true), cl::Hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<OrcLazyJIT::CompileCallbackMgr>
|
|
||||||
OrcLazyJIT::createCompileCallbackMgr(Triple T) {
|
|
||||||
switch (T.getArch()) {
|
|
||||||
default: return nullptr;
|
|
||||||
|
|
||||||
case Triple::x86: {
|
|
||||||
typedef orc::LocalJITCompileCallbackManager<orc::OrcI386> CCMgrT;
|
|
||||||
return llvm::make_unique<CCMgrT>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
case Triple::x86_64: {
|
|
||||||
if ( T.getOS() == Triple::OSType::Win32 ) {
|
|
||||||
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_Win32> CCMgrT;
|
|
||||||
return llvm::make_unique<CCMgrT>(0);
|
|
||||||
} else {
|
|
||||||
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_SysV> CCMgrT;
|
|
||||||
return llvm::make_unique<CCMgrT>(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OrcLazyJIT::IndirectStubsManagerBuilder
|
|
||||||
OrcLazyJIT::createIndirectStubsMgrBuilder(Triple T) {
|
|
||||||
switch (T.getArch()) {
|
|
||||||
default: return nullptr;
|
|
||||||
|
|
||||||
case Triple::x86:
|
|
||||||
return [](){
|
|
||||||
return llvm::make_unique<
|
|
||||||
orc::LocalIndirectStubsManager<orc::OrcI386>>();
|
|
||||||
};
|
|
||||||
|
|
||||||
case Triple::x86_64:
|
|
||||||
if (T.getOS() == Triple::OSType::Win32) {
|
|
||||||
return [](){
|
|
||||||
return llvm::make_unique<
|
|
||||||
orc::LocalIndirectStubsManager<orc::OrcX86_64_Win32>>();
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return [](){
|
|
||||||
return llvm::make_unique<
|
|
||||||
orc::LocalIndirectStubsManager<orc::OrcX86_64_SysV>>();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() {
|
OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() {
|
||||||
|
|
||||||
switch (OrcDumpKind) {
|
switch (OrcDumpKind) {
|
||||||
@ -165,8 +117,8 @@ int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
|
|||||||
EngineBuilder EB;
|
EngineBuilder EB;
|
||||||
EB.setOptLevel(getOptLevel());
|
EB.setOptLevel(getOptLevel());
|
||||||
auto TM = std::unique_ptr<TargetMachine>(EB.selectTarget());
|
auto TM = std::unique_ptr<TargetMachine>(EB.selectTarget());
|
||||||
auto CompileCallbackMgr =
|
Triple T(TM->getTargetTriple());
|
||||||
OrcLazyJIT::createCompileCallbackMgr(Triple(TM->getTargetTriple()));
|
auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
|
||||||
|
|
||||||
// If we couldn't build the factory function then there must not be a callback
|
// If we couldn't build the factory function then there must not be a callback
|
||||||
// manager for this target. Bail out.
|
// manager for this target. Bail out.
|
||||||
@ -176,8 +128,7 @@ int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto IndirectStubsMgrBuilder =
|
auto IndirectStubsMgrBuilder = orc::createLocalIndirectStubsManagerBuilder(T);
|
||||||
OrcLazyJIT::createIndirectStubsMgrBuilder(Triple(TM->getTargetTriple()));
|
|
||||||
|
|
||||||
// If we couldn't build a stubs-manager-builder for this target then bail out.
|
// If we couldn't build a stubs-manager-builder for this target then bail out.
|
||||||
if (!IndirectStubsMgrBuilder) {
|
if (!IndirectStubsMgrBuilder) {
|
||||||
|
@ -62,9 +62,6 @@ public:
|
|||||||
DtorRunner.runViaLayer(CODLayer);
|
DtorRunner.runViaLayer(CODLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T);
|
|
||||||
static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);
|
|
||||||
|
|
||||||
ModuleHandleT addModule(std::unique_ptr<Module> M) {
|
ModuleHandleT addModule(std::unique_ptr<Module> M) {
|
||||||
// Attach a data-layout if one isn't already present.
|
// Attach a data-layout if one isn't already present.
|
||||||
if (M->getDataLayout().isDefault())
|
if (M->getDataLayout().isDefault())
|
||||||
|
Loading…
Reference in New Issue
Block a user