From: Lang Hames Date: Tue, 22 May 2018 20:50:36 +0000 (+0000) Subject: [ORC] Add some comments to Layer.h. X-Git-Tag: android-x86-7.1-r4~706 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0b44b42eaf2398d1a3a31feb80f765730ac4d352;p=android-x86%2Fexternal-llvm.git [ORC] Add some comments to Layer.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333028 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ExecutionEngine/Orc/Layer.h b/include/llvm/ExecutionEngine/Orc/Layer.h index fc8c5ade1b1..18dd4573119 100644 --- a/include/llvm/ExecutionEngine/Orc/Layer.h +++ b/include/llvm/ExecutionEngine/Orc/Layer.h @@ -20,25 +20,32 @@ namespace llvm { namespace orc { +/// Mangles symbol names then uniques them in the context of an +/// ExecutionSession. +// +// FIXME: This may be more at home in Core.h. class MangleAndInterner { public: MangleAndInterner(ExecutionSession &ES, const DataLayout &DL); SymbolStringPtr operator()(StringRef Name); - private: ExecutionSession &ES; const DataLayout &DL; }; -/// Layer interface. +/// Interface for layers that accept LLVM IR. class IRLayer { public: IRLayer(ExecutionSession &ES); virtual ~IRLayer(); + /// Returns the ExecutionSession for this layer. ExecutionSession &getExecutionSession() { return ES; } + /// Adds a MaterializationUnit representing the given IR to the given VSO. virtual Error add(VSO &V, VModuleKey K, std::unique_ptr M); + + /// Emit should materialize the given IR. virtual void emit(MaterializationResponsibility R, VModuleKey K, std::unique_ptr M) = 0; @@ -46,6 +53,10 @@ private: ExecutionSession &ES; }; +/// IRMaterializationUnit is a convenient base class for MaterializationUnits +/// wrapping LLVM IR. Represents materialization responsibility for all symbols +/// in the given module. If symbols are overridden by other definitions, then +/// their linkage is changed to available-externally. class IRMaterializationUnit : public MaterializationUnit { public: IRMaterializationUnit(ExecutionSession &ES, std::unique_ptr M); @@ -59,6 +70,8 @@ private: std::map Discardable; }; +/// MaterializationUnit that materializes modules by calling the 'emit' method +/// on the given IRLayer. class BasicIRLayerMaterializationUnit : public IRMaterializationUnit { public: BasicIRLayerMaterializationUnit(IRLayer &L, VModuleKey K, @@ -71,14 +84,19 @@ private: VModuleKey K; }; +/// Interface for Layers that accept object files. class ObjectLayer { public: ObjectLayer(ExecutionSession &ES); virtual ~ObjectLayer(); + /// Returns the execution session for this layer. ExecutionSession &getExecutionSession() { return ES; } + /// Adds a MaterializationUnit representing the given IR to the given VSO. virtual Error add(VSO &V, VModuleKey K, std::unique_ptr O); + + /// Emit should materialize the given IR. virtual void emit(MaterializationResponsibility R, VModuleKey K, std::unique_ptr O) = 0; @@ -86,11 +104,15 @@ private: ExecutionSession &ES; }; -/// The MemoryBuffer should represent a valid object file. -/// If there is any chance that the file is invalid it should be validated -/// prior to constructing a BasicObjectLayerMaterializationUnit. +/// Materializes the given object file (represented by a MemoryBuffer +/// instance) by calling 'emit' on the given ObjectLayer. class BasicObjectLayerMaterializationUnit : public MaterializationUnit { public: + + + /// The MemoryBuffer should represent a valid object file. + /// If there is any chance that the file is invalid it should be validated + /// prior to constructing a BasicObjectLayerMaterializationUnit. BasicObjectLayerMaterializationUnit(ObjectLayer &L, VModuleKey K, std::unique_ptr O);