LCOV - code coverage report
Current view: top level - include/llvm/ExecutionEngine/Orc - IRTransformLayer.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 8 8 100.0 %
Date: 2018-05-20 00:06:23 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- IRTransformLayer.h - Run all IR through a 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 IR passed in through a user supplied functor.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
      15             : #define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
      16             : 
      17             : #include "llvm/ExecutionEngine/JITSymbol.h"
      18             : #include "llvm/ExecutionEngine/Orc/Core.h"
      19             : #include <memory>
      20             : #include <string>
      21             : 
      22             : namespace llvm {
      23             : class Module;
      24             : namespace orc {
      25             : 
      26             : /// IR mutating layer.
      27             : ///
      28             : ///   This layer applies a user supplied transform to each module that is added,
      29             : /// then adds the transformed module to the layer below.
      30             : template <typename BaseLayerT, typename TransformFtor>
      31           7 : class IRTransformLayer {
      32             : public:
      33             : 
      34             :   /// Construct an IRTransformLayer with the given BaseLayer
      35           7 :   IRTransformLayer(BaseLayerT &BaseLayer,
      36             :                    TransformFtor Transform = TransformFtor())
      37           7 :     : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
      38             : 
      39             :   /// Apply the transform functor to the module, then add the module to
      40             :   ///        the layer below, along with the memory manager and symbol resolver.
      41             :   ///
      42             :   /// @return A handle for the added modules.
      43          19 :   Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
      44          38 :     return BaseLayer.addModule(std::move(K), Transform(std::move(M)));
      45             :   }
      46             : 
      47             :   /// Remove the module associated with the VModuleKey K.
      48          19 :   Error removeModule(VModuleKey K) { return BaseLayer.removeModule(K); }
      49             : 
      50             :   /// Search for the given named symbol.
      51             :   /// @param Name The name of the symbol to search for.
      52             :   /// @param ExportedSymbolsOnly If true, search only for exported symbols.
      53             :   /// @return A handle for the given named symbol, if it exists.
      54             :   JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
      55           6 :     return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
      56             :   }
      57             : 
      58             :   /// Get the address of the given symbol in the context of the module
      59             :   ///        represented by the VModuleKey K. This call is forwarded to the base
      60             :   ///        layer's implementation.
      61             :   /// @param K The VModuleKey for the module to search in.
      62             :   /// @param Name The name of the symbol to search for.
      63             :   /// @param ExportedSymbolsOnly If true, search only for exported symbols.
      64             :   /// @return A handle for the given named symbol, if it is found in the
      65             :   ///         given module.
      66             :   JITSymbol findSymbolIn(VModuleKey K, const std::string &Name,
      67             :                          bool ExportedSymbolsOnly) {
      68          38 :     return BaseLayer.findSymbolIn(K, Name, ExportedSymbolsOnly);
      69             :   }
      70             : 
      71             :   /// Immediately emit and finalize the module represented by the given
      72             :   ///        VModuleKey.
      73             :   /// @param K The VModuleKey for the module to emit/finalize.
      74             :   Error emitAndFinalize(VModuleKey K) { return BaseLayer.emitAndFinalize(K); }
      75             : 
      76             :   /// Access the transform functor directly.
      77             :   TransformFtor& getTransform() { return Transform; }
      78             : 
      79             :   /// Access the mumate functor directly.
      80             :   const TransformFtor& getTransform() const { return Transform; }
      81             : 
      82             : private:
      83             :   BaseLayerT &BaseLayer;
      84             :   TransformFtor Transform;
      85             : };
      86             : 
      87             : } // end namespace orc
      88             : } // end namespace llvm
      89             : 
      90             : #endif // LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H

Generated by: LCOV version 1.13