[Orc] Move Orc code into a namespace (llvm::orc), update Kaleidoscope code.

NFC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230143 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames
2015-02-21 20:44:36 +00:00
parent 59d81dbafb
commit 8d353ae157
19 changed files with 85 additions and 24 deletions

View File

@@ -20,7 +20,9 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::orc;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Lexer // Lexer

View File

@@ -20,7 +20,9 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::orc;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Lexer // Lexer

View File

@@ -19,7 +19,9 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::orc;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Lexer // Lexer

View File

@@ -19,7 +19,9 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::orc;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Lexer // Lexer

View File

@@ -25,21 +25,36 @@ class Function;
class GlobalVariable; class GlobalVariable;
class Module; class Module;
namespace orc {
/// @brief Functor type for describing how CloneSubModule should mutate a
/// GlobalVariable.
typedef std::function<void(GlobalVariable &, const GlobalVariable &, typedef std::function<void(GlobalVariable &, const GlobalVariable &,
ValueToValueMapTy &)> HandleGlobalVariableFtor; ValueToValueMapTy &)> HandleGlobalVariableFtor;
/// @brief Functor type for describing how CloneSubModule should mutate a
/// Function.
typedef std::function<void(Function &, const Function &, ValueToValueMapTy &)> typedef std::function<void(Function &, const Function &, ValueToValueMapTy &)>
HandleFunctionFtor; HandleFunctionFtor;
/// @brief Copies the initializer from Orig to New.
///
/// Type is suitable for implicit conversion to a HandleGlobalVariableFtor.
void copyGVInitializer(GlobalVariable &New, const GlobalVariable &Orig, void copyGVInitializer(GlobalVariable &New, const GlobalVariable &Orig,
ValueToValueMapTy &VMap); ValueToValueMapTy &VMap);
/// @brief Copies the body of Orig to New.
///
/// Type is suitable for implicit conversion to a HandleFunctionFtor.
void copyFunctionBody(Function &New, const Function &Orig, void copyFunctionBody(Function &New, const Function &Orig,
ValueToValueMapTy &VMap); ValueToValueMapTy &VMap);
/// @brief Clone a subset of the module Src into Dst.
void CloneSubModule(Module &Dst, const Module &Src, void CloneSubModule(Module &Dst, const Module &Src,
HandleGlobalVariableFtor HandleGlobalVariable, HandleGlobalVariableFtor HandleGlobalVariable,
HandleFunctionFtor HandleFunction, bool KeepInlineAsm); HandleFunctionFtor HandleFunction, bool KeepInlineAsm);
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H #endif // LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H

View File

@@ -22,6 +22,7 @@
#include <list> #include <list>
namespace llvm { namespace llvm {
namespace orc {
/// @brief Compile-on-demand layer. /// @brief Compile-on-demand layer.
/// ///
@@ -347,6 +348,8 @@ private:
CompileCallbackMgrT CompileCallbackMgr; CompileCallbackMgrT CompileCallbackMgr;
ModuleSetInfoListT ModuleSetInfos; ModuleSetInfoListT ModuleSetInfos;
}; };
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H

View File

@@ -21,6 +21,7 @@
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
namespace llvm { namespace llvm {
namespace orc {
/// @brief Simple compile functor: Takes a single IR module and returns an /// @brief Simple compile functor: Takes a single IR module and returns an
/// ObjectFile. /// ObjectFile.
@@ -54,6 +55,8 @@ public:
private: private:
TargetMachine &TM; TargetMachine &TM;
}; };
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H

View File

@@ -21,6 +21,7 @@
#include <memory> #include <memory>
namespace llvm { namespace llvm {
namespace orc {
/// @brief Eager IR compiling layer. /// @brief Eager IR compiling layer.
/// ///
@@ -138,6 +139,8 @@ private:
CompileFtor Compile; CompileFtor Compile;
ObjectCache *ObjCache; ObjectCache *ObjCache;
}; };
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H

View File

@@ -22,6 +22,7 @@
#include <sstream> #include <sstream>
namespace llvm { namespace llvm {
namespace orc {
/// @brief Base class for JITLayer independent aspects of /// @brief Base class for JITLayer independent aspects of
/// JITCompileCallbackManager. /// JITCompileCallbackManager.
@@ -239,6 +240,7 @@ public:
FullyPartitionedModule fullyPartition(Module &M); FullyPartitionedModule fullyPartition(Module &M);
} } // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H #endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H

View File

@@ -19,6 +19,7 @@
#include <functional> #include <functional>
namespace llvm { namespace llvm {
namespace orc {
/// @brief Represents an address in the target process's address space. /// @brief Represents an address in the target process's address space.
typedef uint64_t TargetAddress; typedef uint64_t TargetAddress;
@@ -67,6 +68,7 @@ private:
GetAddressFtor GetAddress; GetAddressFtor GetAddress;
}; };
} } // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H #endif // LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H

View File

@@ -22,6 +22,7 @@
#include <list> #include <list>
namespace llvm { namespace llvm {
namespace orc {
/// @brief Lazy-emitting IR layer. /// @brief Lazy-emitting IR layer.
/// ///
@@ -273,6 +274,8 @@ LazyEmittingLayer<BaseLayerT>::EmissionDeferredSet::create(
return llvm::make_unique<EmissionDeferredSetImpl<ModuleSetT>>(std::move(Ms), return llvm::make_unique<EmissionDeferredSetImpl<ModuleSetT>>(std::move(Ms),
std::move(MM)); std::move(MM));
} }
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H

View File

@@ -20,6 +20,7 @@
#include <vector> #include <vector>
namespace llvm { namespace llvm {
namespace orc {
/// @brief Defines an adapter for RuntimeDyldMM that allows lookups for external /// @brief Defines an adapter for RuntimeDyldMM that allows lookups for external
/// symbols to go via a functor, before falling back to the lookup logic /// symbols to go via a functor, before falling back to the lookup logic
@@ -84,6 +85,8 @@ createLookasideRTDyldMM(ExternalLookupFtor &&ExternalLookup,
std::forward<ExternalLookupFtor>(ExternalLookup), std::forward<ExternalLookupFtor>(ExternalLookup),
std::forward<DylibLookupFtor>(DylibLookup)); std::forward<DylibLookupFtor>(DylibLookup));
} }
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_LOOKASIDERTDYLDMM_H #endif // LLVM_EXECUTIONENGINE_ORC_LOOKASIDERTDYLDMM_H

View File

@@ -22,6 +22,7 @@
#include <memory> #include <memory>
namespace llvm { namespace llvm {
namespace orc {
class ObjectLinkingLayerBase { class ObjectLinkingLayerBase {
protected: protected:
@@ -260,6 +261,7 @@ private:
CreateRTDyldMMFtor CreateMemoryManager; CreateRTDyldMMFtor CreateMemoryManager;
}; };
} // end namespace llvm } // End namespace orc.
} // End namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H

View File

@@ -17,6 +17,7 @@
#include "IndirectionUtils.h" #include "IndirectionUtils.h"
namespace llvm { namespace llvm {
namespace orc {
class OrcX86_64 { class OrcX86_64 {
public: public:
@@ -49,6 +50,7 @@ public:
}; };
} } // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H #endif // LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H

View File

@@ -4,15 +4,16 @@
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Cloning.h"
using namespace llvm; namespace llvm {
namespace orc {
void llvm::copyGVInitializer(GlobalVariable &New, const GlobalVariable &Orig, void copyGVInitializer(GlobalVariable &New, const GlobalVariable &Orig,
ValueToValueMapTy &VMap) { ValueToValueMapTy &VMap) {
if (Orig.hasInitializer()) if (Orig.hasInitializer())
New.setInitializer(MapValue(Orig.getInitializer(), VMap)); New.setInitializer(MapValue(Orig.getInitializer(), VMap));
} }
void llvm::copyFunctionBody(Function &New, const Function &Orig, void copyFunctionBody(Function &New, const Function &Orig,
ValueToValueMapTy &VMap) { ValueToValueMapTy &VMap) {
if (!Orig.isDeclaration()) { if (!Orig.isDeclaration()) {
Function::arg_iterator DestI = New.arg_begin(); Function::arg_iterator DestI = New.arg_begin();
@@ -27,7 +28,7 @@ void llvm::copyFunctionBody(Function &New, const Function &Orig,
} }
} }
void llvm::CloneSubModule(llvm::Module &Dst, const Module &Src, void CloneSubModule(llvm::Module &Dst, const Module &Src,
HandleGlobalVariableFtor HandleGlobalVariable, HandleGlobalVariableFtor HandleGlobalVariable,
HandleFunctionFtor HandleFunction, bool CloneInlineAsm) { HandleFunctionFtor HandleFunction, bool CloneInlineAsm) {
@@ -102,3 +103,6 @@ void llvm::CloneSubModule(llvm::Module &Dst, const Module &Src,
} }
} }
} // End namespace orc.
} // End namespace llvm.

View File

@@ -8,6 +8,7 @@
using namespace llvm; using namespace llvm;
namespace llvm { namespace llvm {
namespace orc {
GlobalVariable* createImplPointer(Function &F, const Twine &Name, GlobalVariable* createImplPointer(Function &F, const Twine &Name,
Constant *Initializer) { Constant *Initializer) {
@@ -106,4 +107,5 @@ FullyPartitionedModule fullyPartition(Module &M) {
return MP; return MP;
} }
} } // End namespace orc.
} // End namespace llvm.

View File

@@ -13,7 +13,7 @@
namespace { namespace {
static struct RegisterJIT { static struct RegisterJIT {
RegisterJIT() { llvm::OrcMCJITReplacement::Register(); } RegisterJIT() { llvm::orc::OrcMCJITReplacement::Register(); }
} JITRegistrator; } JITRegistrator;
} }
@@ -21,6 +21,7 @@ static struct RegisterJIT {
extern "C" void LLVMLinkInOrcMCJITReplacement() {} extern "C" void LLVMLinkInOrcMCJITReplacement() {}
namespace llvm { namespace llvm {
namespace orc {
GenericValue GenericValue
OrcMCJITReplacement::runFunction(Function *F, OrcMCJITReplacement::runFunction(Function *F,
@@ -122,4 +123,6 @@ OrcMCJITReplacement::runFunction(Function *F,
llvm_unreachable("Full-featured argument passing not supported yet!"); llvm_unreachable("Full-featured argument passing not supported yet!");
} }
}
} // End namespace orc.
} // End namespace llvm.

View File

@@ -22,6 +22,7 @@
#include "llvm/Object/Archive.h" #include "llvm/Object/Archive.h"
namespace llvm { namespace llvm {
namespace orc {
class OrcMCJITReplacement : public ExecutionEngine { class OrcMCJITReplacement : public ExecutionEngine {
@@ -104,11 +105,12 @@ class OrcMCJITReplacement : public ExecutionEngine {
}; };
private: private:
static ExecutionEngine * static ExecutionEngine *
createOrcMCJITReplacement(std::string *ErrorMsg, createOrcMCJITReplacement(std::string *ErrorMsg,
std::unique_ptr<RTDyldMemoryManager> OrcJMM, std::unique_ptr<RTDyldMemoryManager> OrcJMM,
std::unique_ptr<llvm::TargetMachine> TM) { std::unique_ptr<TargetMachine> TM) {
return new llvm::OrcMCJITReplacement(std::move(OrcJMM), std::move(TM)); return new OrcMCJITReplacement(std::move(OrcJMM), std::move(TM));
} }
public: public:
@@ -323,6 +325,8 @@ private:
std::vector<object::OwningBinary<object::Archive>> Archives; std::vector<object::OwningBinary<object::Archive>> Archives;
}; };
}
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_LIB_EXECUTIONENGINE_ORC_MCJITREPLACEMENT_H #endif // LLVM_LIB_EXECUTIONENGINE_ORC_MCJITREPLACEMENT_H

View File

@@ -2,7 +2,7 @@
#include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h" #include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
#include <array> #include <array>
using namespace llvm; using namespace llvm::orc;
namespace { namespace {
@@ -47,6 +47,7 @@ uint64_t executeCompileCallback(JITCompileCallbackManagerBase<TargetT> *JCBM,
} }
namespace llvm { namespace llvm {
namespace orc {
const char* OrcX86_64::ResolverBlockName = "orc_resolver_block"; const char* OrcX86_64::ResolverBlockName = "orc_resolver_block";
@@ -123,4 +124,5 @@ OrcX86_64::insertCompileCallbackTrampolines(Module &M,
return GetLabelName; return GetLabelName;
} }
} } // End namespace orc.
} // End namespace llvm.