[llvm] r270874 - [Orc] Merge some common code for creating CompileCallbackManagers and
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 10:20:36 PDT 2016
Author: lhames
Date: Thu May 26 12:20:35 2016
New Revision: 270874
URL: http://llvm.org/viewvc/llvm-project?rev=270874&view=rev
Log:
[Orc] Merge some common code for creating CompileCallbackManagers and
IndirectStubsManagers.
Removed:
llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
llvm/trunk/lib/ExecutionEngine/Orc/CMakeLists.txt
llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp
llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
llvm/trunk/tools/lli/OrcLazyJIT.cpp
llvm/trunk/tools/lli/OrcLazyJIT.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h Thu May 26 12:20:35 2016
@@ -328,6 +328,20 @@ private:
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
/// address.
///
Modified: llvm/trunk/lib/ExecutionEngine/Orc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/CMakeLists.txt?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/CMakeLists.txt (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/CMakeLists.txt Thu May 26 12:20:35 2016
@@ -4,7 +4,6 @@ add_llvm_library(LLVMOrcJIT
NullResolver.cpp
OrcABISupport.cpp
OrcCBindings.cpp
- OrcCBindingsStack.cpp
OrcError.cpp
OrcMCJITReplacement.cpp
OrcRemoteTargetRPCAPI.cpp
Modified: llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp Thu May 26 12:20:35 2016
@@ -10,6 +10,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
+#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
@@ -21,6 +22,54 @@ namespace orc {
void JITCompileCallbackManager::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 *AddrIntVal =
ConstantInt::get(Type::getInt64Ty(FT.getContext()), Addr);
Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp Thu May 26 12:20:35 2016
@@ -17,9 +17,9 @@ LLVMOrcJITStackRef LLVMOrcCreateInstance
Triple T(TM2->getTargetTriple());
- auto CompileCallbackMgr = OrcCBindingsStack::createCompileCallbackMgr(T);
+ auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
auto IndirectStubsMgrBuilder =
- OrcCBindingsStack::createIndirectStubsMgrBuilder(T);
+ orc::createLocalIndirectStubsManagerBuilder(T);
OrcCBindingsStack *JITStack = new OrcCBindingsStack(
*TM2, std::move(CompileCallbackMgr), IndirectStubsMgrBuilder);
Removed: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp?rev=270873&view=auto
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp (removed)
@@ -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>>();
- };
- }
- }
-}
Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h Thu May 26 12:20:35 2016
@@ -79,9 +79,6 @@ public:
typedef unsigned ModuleHandleT;
- static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T);
- static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);
-
OrcCBindingsStack(TargetMachine &TM,
std::unique_ptr<CompileCallbackMgr> CCMgr,
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
Modified: llvm/trunk/tools/lli/OrcLazyJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/tools/lli/OrcLazyJIT.cpp (original)
+++ llvm/trunk/tools/lli/OrcLazyJIT.cpp Thu May 26 12:20:35 2016
@@ -46,54 +46,6 @@ namespace {
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() {
switch (OrcDumpKind) {
@@ -165,8 +117,8 @@ int llvm::runOrcLazyJIT(std::unique_ptr<
EngineBuilder EB;
EB.setOptLevel(getOptLevel());
auto TM = std::unique_ptr<TargetMachine>(EB.selectTarget());
- auto CompileCallbackMgr =
- OrcLazyJIT::createCompileCallbackMgr(Triple(TM->getTargetTriple()));
+ Triple T(TM->getTargetTriple());
+ auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
// If we couldn't build the factory function then there must not be a callback
// manager for this target. Bail out.
@@ -176,8 +128,7 @@ int llvm::runOrcLazyJIT(std::unique_ptr<
return 1;
}
- auto IndirectStubsMgrBuilder =
- OrcLazyJIT::createIndirectStubsMgrBuilder(Triple(TM->getTargetTriple()));
+ auto IndirectStubsMgrBuilder = orc::createLocalIndirectStubsManagerBuilder(T);
// If we couldn't build a stubs-manager-builder for this target then bail out.
if (!IndirectStubsMgrBuilder) {
Modified: llvm/trunk/tools/lli/OrcLazyJIT.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=270874&r1=270873&r2=270874&view=diff
==============================================================================
--- llvm/trunk/tools/lli/OrcLazyJIT.h (original)
+++ llvm/trunk/tools/lli/OrcLazyJIT.h Thu May 26 12:20:35 2016
@@ -62,9 +62,6 @@ public:
DtorRunner.runViaLayer(CODLayer);
}
- static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T);
- static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);
-
ModuleHandleT addModule(std::unique_ptr<Module> M) {
// Attach a data-layout if one isn't already present.
if (M->getDataLayout().isDefault())
More information about the llvm-commits
mailing list