[Orc] Move Orc code into a namespace (llvm::orc), update Kaleidoscope code.
authorLang Hames <lhames@gmail.com>
Sat, 21 Feb 2015 20:44:36 +0000 (20:44 +0000)
committerLang Hames <lhames@gmail.com>
Sat, 21 Feb 2015 20:44:36 +0000 (20:44 +0000)
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230143 91177308-0d34-0410-b5e6-96231b3b80d8

19 files changed:
examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
examples/Kaleidoscope/Orc/initial/toy.cpp
examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
include/llvm/ExecutionEngine/Orc/CloneSubModule.h
include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
include/llvm/ExecutionEngine/Orc/CompileUtils.h
include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
include/llvm/ExecutionEngine/Orc/JITSymbol.h
include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
include/llvm/ExecutionEngine/Orc/LookasideRTDyldMM.h
include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h
include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h
lib/ExecutionEngine/Orc/CloneSubModule.cpp
lib/ExecutionEngine/Orc/IndirectionUtils.cpp
lib/ExecutionEngine/Orc/OrcMCJITReplacement.cpp
lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
lib/ExecutionEngine/Orc/OrcTargetSupport.cpp

index b1aca7803da577dfc6496a1e79ac33dccb0c6c9f..475d4eba62276ae45652146f0cf0cbedb5fd038f 100644 (file)
@@ -20,7 +20,9 @@
 #include <sstream>
 #include <string>
 #include <vector>
 #include <sstream>
 #include <string>
 #include <vector>
+
 using namespace llvm;
 using namespace llvm;
+using namespace llvm::orc;
 
 //===----------------------------------------------------------------------===//
 // Lexer
 
 //===----------------------------------------------------------------------===//
 // Lexer
index ae0d4ad33da3a4059b899f2db11adfae7a3bded2..c01aff2f99bdf5cb07ba6bddb64a845f1d2b96b7 100644 (file)
@@ -20,7 +20,9 @@
 #include <sstream>
 #include <string>
 #include <vector>
 #include <sstream>
 #include <string>
 #include <vector>
+
 using namespace llvm;
 using namespace llvm;
+using namespace llvm::orc;
 
 //===----------------------------------------------------------------------===//
 // Lexer
 
 //===----------------------------------------------------------------------===//
 // Lexer
index 168ebdd87ae61a435c4c8a40852e717e858efb3a..ee42d79e58544110dd08d33bf8a8314d6f9b15ce 100644 (file)
@@ -19,7 +19,9 @@
 #include <sstream>
 #include <string>
 #include <vector>
 #include <sstream>
 #include <string>
 #include <vector>
+
 using namespace llvm;
 using namespace llvm;
+using namespace llvm::orc;
 
 //===----------------------------------------------------------------------===//
 // Lexer
 
 //===----------------------------------------------------------------------===//
 // Lexer
index af02e939452f79880a194a690c371fb86251edf8..162b0e589996ec78135b55ed16d0388f4631e831 100644 (file)
@@ -19,7 +19,9 @@
 #include <sstream>
 #include <string>
 #include <vector>
 #include <sstream>
 #include <string>
 #include <vector>
+
 using namespace llvm;
 using namespace llvm;
+using namespace llvm::orc;
 
 //===----------------------------------------------------------------------===//
 // Lexer
 
 //===----------------------------------------------------------------------===//
 // Lexer
index 208a4f7692bb7bc8a975565e298e758dada291ed..1bd3955e879fde55af35e9e5a1b8132c74dd3da2 100644 (file)
@@ -25,21 +25,36 @@ class Function;
 class GlobalVariable;
 class Module;
 
 class GlobalVariable;
 class Module;
 
+namespace orc {
+
+/// @brief Functor type for describing how CloneSubModule should mutate a
+///        GlobalVariable.
 typedef std::function<void(GlobalVariable &, const GlobalVariable &,
                            ValueToValueMapTy &)> HandleGlobalVariableFtor;
 
 typedef std::function<void(GlobalVariable &, const GlobalVariable &,
                            ValueToValueMapTy &)> HandleGlobalVariableFtor;
 
+/// @brief Functor type for describing how CloneSubModule should mutate a
+///        Function.
 typedef std::function<void(Function &, const Function &, ValueToValueMapTy &)>
     HandleFunctionFtor;
 
 typedef std::function<void(Function &, const Function &, ValueToValueMapTy &)>
     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,
                        ValueToValueMapTy &VMap);
 
 void copyGVInitializer(GlobalVariable &New, const GlobalVariable &Orig,
                        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,
                       ValueToValueMapTy &VMap);
 
 void copyFunctionBody(Function &New, const Function &Orig,
                       ValueToValueMapTy &VMap);
 
+/// @brief Clone a subset of the module Src into Dst.
 void CloneSubModule(Module &Dst, const Module &Src,
                     HandleGlobalVariableFtor HandleGlobalVariable,
                     HandleFunctionFtor HandleFunction, bool KeepInlineAsm);
 void CloneSubModule(Module &Dst, const Module &Src,
                     HandleGlobalVariableFtor HandleGlobalVariable,
                     HandleFunctionFtor HandleFunction, bool KeepInlineAsm);
-}
+
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H
index 7fb25db0322a5a986a2b0f3c45243d22d6957d4d..0e218e2e7f47fb102b138416fc912b486eda146e 100644 (file)
@@ -22,6 +22,7 @@
 #include <list>
 
 namespace llvm {
 #include <list>
 
 namespace llvm {
+namespace orc {
 
 /// @brief Compile-on-demand layer.
 ///
 
 /// @brief Compile-on-demand layer.
 ///
@@ -347,6 +348,8 @@ private:
   CompileCallbackMgrT CompileCallbackMgr;
   ModuleSetInfoListT ModuleSetInfos;
 };
   CompileCallbackMgrT CompileCallbackMgr;
   ModuleSetInfoListT ModuleSetInfos;
 };
-}
+
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
index a054ca659d3311cca73ef2c772cb2eed8cd1e997..49a1fbadb295f1428cc269b319dfc68ab7e91362 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/Target/TargetMachine.h"
 
 namespace llvm {
 #include "llvm/Target/TargetMachine.h"
 
 namespace llvm {
+namespace orc {
 
 /// @brief Simple compile functor: Takes a single IR module and returns an
 ///        ObjectFile.
 
 /// @brief Simple compile functor: Takes a single IR module and returns an
 ///        ObjectFile.
@@ -54,6 +55,8 @@ public:
 private:
   TargetMachine &TM;
 };
 private:
   TargetMachine &TM;
 };
-}
+
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
index 19f55e9551c2d0f4c86c66bed9a64371aed1abee..6a4762217399ee237539aea22cc00eb1c1a78af0 100644 (file)
@@ -21,6 +21,7 @@
 #include <memory>
 
 namespace llvm {
 #include <memory>
 
 namespace llvm {
+namespace orc {
 
 /// @brief Eager IR compiling layer.
 ///
 
 /// @brief Eager IR compiling layer.
 ///
@@ -138,6 +139,8 @@ private:
   CompileFtor Compile;
   ObjectCache *ObjCache;
 };
   CompileFtor Compile;
   ObjectCache *ObjCache;
 };
-}
+
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
index 50e9a4352dd7f50089626b2b945da5d4ad2cd0fe..e9d3d34085db6692c54625cae3a56952f0c82ac5 100644 (file)
@@ -22,6 +22,7 @@
 #include <sstream>
 
 namespace llvm {
 #include <sstream>
 
 namespace llvm {
+namespace orc {
 
 /// @brief Base class for JITLayer independent aspects of
 ///        JITCompileCallbackManager.
 
 /// @brief Base class for JITLayer independent aspects of
 ///        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
index c0b627e60b9beb6ed0d68f31265845329b819a2f..07a7dbb9a1f6ec077c4871a7762b4f6722dd12cf 100644 (file)
@@ -19,6 +19,7 @@
 #include <functional>
 
 namespace llvm {
 #include <functional>
 
 namespace llvm {
+namespace orc {
 
 /// @brief Represents an address in the target process's address space.
 typedef uint64_t TargetAddress;
 
 /// @brief Represents an address in the target process's address space.
 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
index 9579cd35cad8228a12245f0b7b8c392512de6e20..d1214af1e30e81d765fb7a59d430f5831159ed20 100644 (file)
@@ -22,6 +22,7 @@
 #include <list>
 
 namespace llvm {
 #include <list>
 
 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),
                                                                 std::move(MM));
 }
   return llvm::make_unique<EmissionDeferredSetImpl<ModuleSetT>>(std::move(Ms),
                                                                 std::move(MM));
 }
-}
+
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H
index dd49c94dccaf064cf7ff1d3c8d48b60594828216..4456404565654f6b8af850f685834fd8dc83dfe8 100644 (file)
@@ -20,6 +20,7 @@
 #include <vector>
 
 namespace llvm {
 #include <vector>
 
 namespace llvm {
+namespace orc {
 
 /// @brief Defines an adapter for RuntimeDyldMM that allows lookups for external
 ///        symbols to go via a functor, before falling back to the lookup logic
 
 /// @brief Defines an adapter for RuntimeDyldMM that allows lookups for external
 ///        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<DylibLookupFtor>(DylibLookup));
 }
       std::forward<ExternalLookupFtor>(ExternalLookup),
       std::forward<DylibLookupFtor>(DylibLookup));
 }
-}
+
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_LOOKASIDERTDYLDMM_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_LOOKASIDERTDYLDMM_H
index ad7c9ebdd9b772aa25e51d668a8630e6a4cbda65..36af0feabda99c8282c3fc8adcc8c20518a371c0 100644 (file)
@@ -22,6 +22,7 @@
 #include <memory>
 
 namespace llvm {
 #include <memory>
 
 namespace llvm {
+namespace orc {
 
 class ObjectLinkingLayerBase {
 protected:
 
 class ObjectLinkingLayerBase {
 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
index 29e49c33333c271f4106d31a389e50f2b5d770fa..c6f866a0469a5271f4e76c91262666cb9cab7003 100644 (file)
@@ -17,6 +17,7 @@
 #include "IndirectionUtils.h"
 
 namespace llvm {
 #include "IndirectionUtils.h"
 
 namespace llvm {
+namespace orc {
 
 class OrcX86_64 {
 public:
 
 class OrcX86_64 {
 public:
@@ -49,6 +50,7 @@ public:
 
 };
 
 
 };
 
-}
+} // End namespace orc.
+} // End namespace llvm.
 
 #endif // LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H
 
 #endif // LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H
index 64a33c80f203100849a86c28b5ae992e0fbebb74..a3196ad2f789b311745d578b8667ba2be4d1d225 100644 (file)
@@ -4,15 +4,16 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 
 #include "llvm/IR/Module.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) {
   if (Orig.hasInitializer())
     New.setInitializer(MapValue(Orig.getInitializer(), VMap));
 }
 
                              ValueToValueMapTy &VMap) {
   if (Orig.hasInitializer())
     New.setInitializer(MapValue(Orig.getInitializer(), VMap));
 }
 
-void llvm::copyFunctionBody(Function &New, const Function &Orig,
+void copyFunctionBody(Function &New, const Function &Orig,
                             ValueToValueMapTy &VMap) {
   if (!Orig.isDeclaration()) {
     Function::arg_iterator DestI = New.arg_begin();
                             ValueToValueMapTy &VMap) {
   if (!Orig.isDeclaration()) {
     Function::arg_iterator DestI = New.arg_begin();
@@ -27,9 +28,9 @@ void llvm::copyFunctionBody(Function &New, const Function &Orig,
   }
 }
 
   }
 }
 
-void llvm::CloneSubModule(llvm::Module &Dst, const Module &Src,
-                     HandleGlobalVariableFtor HandleGlobalVariable,
-                     HandleFunctionFtor HandleFunction, bool CloneInlineAsm) {
+void CloneSubModule(llvm::Module &Dst, const Module &Src,
+                    HandleGlobalVariableFtor HandleGlobalVariable,
+                    HandleFunctionFtor HandleFunction, bool CloneInlineAsm) {
 
   ValueToValueMapTy VMap;
 
 
   ValueToValueMapTy VMap;
 
@@ -102,3 +103,6 @@ void llvm::CloneSubModule(llvm::Module &Dst, const Module &Src,
   }
 
 }
   }
 
 }
+
+} // End namespace orc.
+} // End namespace llvm.
index 57616a5484077c0ef651073a3c39c5dbd758d739..11deb4acbeb4a9fdd5e91655daccb34091c3ff84 100644 (file)
@@ -8,6 +8,7 @@
 using namespace llvm;
 
 namespace llvm {
 using namespace llvm;
 
 namespace llvm {
+namespace orc {
 
 GlobalVariable* createImplPointer(Function &F, const Twine &Name,
                                   Constant *Initializer) {
 
 GlobalVariable* createImplPointer(Function &F, const Twine &Name,
                                   Constant *Initializer) {
@@ -106,4 +107,5 @@ FullyPartitionedModule fullyPartition(Module &M) {
   return MP;
 }
 
   return MP;
 }
 
-}
+} // End namespace orc.
+} // End namespace llvm.
index 75d1b1f7431ce01b74d662c69176a575c19f42b0..48fd31e51a6dd9d27fe984bae6990333add5b0fe 100644 (file)
@@ -13,7 +13,7 @@
 namespace {
 
 static struct RegisterJIT {
 namespace {
 
 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() {}
 
 namespace llvm {
 extern "C" void LLVMLinkInOrcMCJITReplacement() {}
 
 namespace llvm {
+namespace orc {
 
 GenericValue
 OrcMCJITReplacement::runFunction(Function *F,
 
 GenericValue
 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.
index f09d13e87bd307b02e2bec8b0c25be79b2416786..1b7b16187c8589e31626c37e2760e2fc7fb78a3c 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Object/Archive.h"
 
 namespace llvm {
 #include "llvm/Object/Archive.h"
 
 namespace llvm {
+namespace orc {
 
 class OrcMCJITReplacement : public ExecutionEngine {
 
 
 class OrcMCJITReplacement : public ExecutionEngine {
 
@@ -104,11 +105,12 @@ class OrcMCJITReplacement : public ExecutionEngine {
   };
 
 private:
   };
 
 private:
+
   static ExecutionEngine *
   createOrcMCJITReplacement(std::string *ErrorMsg,
                             std::unique_ptr<RTDyldMemoryManager> OrcJMM,
   static ExecutionEngine *
   createOrcMCJITReplacement(std::string *ErrorMsg,
                             std::unique_ptr<RTDyldMemoryManager> OrcJMM,
-                            std::unique_ptr<llvm::TargetMachine> TM) {
-    return new llvm::OrcMCJITReplacement(std::move(OrcJMM), std::move(TM));
+                            std::unique_ptr<TargetMachine> 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
index e71fc65ce24b6e44743bdbbff1d6365b50cae201..b5dda8e4ee59de61e522bee8d2981b262d536576 100644 (file)
@@ -2,7 +2,7 @@
 #include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
 #include <array>
 
 #include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
 #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.