LCOV - code coverage report
Current view: top level - include/llvm/ExecutionEngine/Orc - ObjectTransformLayer.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 11 81.8 %
Date: 2018-05-20 00:06:23 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- ObjectTransformLayer.h - Run all objects through functor -*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // Run all objects passed in through a user supplied functor.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
      15             : #define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
      16             : 
      17             : #include "llvm/ExecutionEngine/JITSymbol.h"
      18             : #include "llvm/ExecutionEngine/Orc/Core.h"
      19             : #include <algorithm>
      20             : #include <memory>
      21             : #include <string>
      22             : 
      23             : namespace llvm {
      24             : namespace orc {
      25             : 
      26             : /// Object mutating layer.
      27             : ///
      28             : ///   This layer accepts sets of ObjectFiles (via addObject). It
      29             : /// immediately applies the user supplied functor to each object, then adds
      30             : /// the set of transformed objects to the layer below.
      31             : template <typename BaseLayerT, typename TransformFtor>
      32           1 : class ObjectTransformLayer {
      33             : public:
      34             :   /// Construct an ObjectTransformLayer with the given BaseLayer
      35           0 :   ObjectTransformLayer(BaseLayerT &BaseLayer,
      36             :                        TransformFtor Transform = TransformFtor())
      37           1 :       : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
      38             : 
      39             :   /// Apply the transform functor to each object in the object set, then
      40             :   ///        add the resulting set of objects to the base layer, along with the
      41             :   ///        memory manager and symbol resolver.
      42             :   ///
      43             :   /// @return A handle for the added objects.
      44           2 :   template <typename ObjectPtr> Error addObject(VModuleKey K, ObjectPtr Obj) {
      45           8 :     return BaseLayer.addObject(std::move(K), Transform(std::move(Obj)));
      46             :   }
      47             : 
      48             :   /// Remove the object set associated with the VModuleKey K.
      49           1 :   Error removeObject(VModuleKey K) { return BaseLayer.removeObject(K); }
      50             : 
      51             :   /// Search for the given named symbol.
      52             :   /// @param Name The name of the symbol to search for.
      53             :   /// @param ExportedSymbolsOnly If true, search only for exported symbols.
      54             :   /// @return A handle for the given named symbol, if it exists.
      55             :   JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
      56           1 :     return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
      57             :   }
      58             : 
      59             :   /// Get the address of the given symbol in the context of the set of
      60             :   ///        objects represented by the VModuleKey K. This call is forwarded to
      61             :   ///        the base layer's implementation.
      62             :   /// @param K The VModuleKey associated with the object set to search in.
      63             :   /// @param Name The name of the symbol to search for.
      64             :   /// @param ExportedSymbolsOnly If true, search only for exported symbols.
      65             :   /// @return A handle for the given named symbol, if it is found in the
      66             :   ///         given object set.
      67           0 :   JITSymbol findSymbolIn(VModuleKey K, const std::string &Name,
      68             :                          bool ExportedSymbolsOnly) {
      69           1 :     return BaseLayer.findSymbolIn(K, Name, ExportedSymbolsOnly);
      70             :   }
      71             : 
      72             :   /// Immediately emit and finalize the object set represented by the
      73             :   ///        given VModuleKey K.
      74           1 :   Error emitAndFinalize(VModuleKey K) { return BaseLayer.emitAndFinalize(K); }
      75             : 
      76             :   /// Map section addresses for the objects associated with the
      77             :   /// VModuleKey K.
      78             :   void mapSectionAddress(VModuleKey K, const void *LocalAddress,
      79             :                          JITTargetAddress TargetAddr) {
      80           1 :     BaseLayer.mapSectionAddress(K, LocalAddress, TargetAddr);
      81             :   }
      82             : 
      83             :   /// Access the transform functor directly.
      84             :   TransformFtor &getTransform() { return Transform; }
      85             : 
      86             :   /// Access the mumate functor directly.
      87             :   const TransformFtor &getTransform() const { return Transform; }
      88             : 
      89             : private:
      90             :   BaseLayerT &BaseLayer;
      91             :   TransformFtor Transform;
      92             : };
      93             : 
      94             : } // end namespace orc
      95             : } // end namespace llvm
      96             : 
      97             : #endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H

Generated by: LCOV version 1.13