LCOV - code coverage report
Current view: top level - lib/ExecutionEngine/Orc - JITTargetMachineBuilder.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 16 20 80.0 %
Date: 2018-10-20 13:21:21 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===----- JITTargetMachineBuilder.cpp - Build TargetMachines for JIT -----===//
       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             : #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
      11             : 
      12             : #include "llvm/Support/TargetRegistry.h"
      13             : 
      14             : namespace llvm {
      15             : namespace orc {
      16             : 
      17          15 : JITTargetMachineBuilder::JITTargetMachineBuilder(Triple TT)
      18          30 :     : TT(std::move(TT)) {
      19          15 :   Options.EmulatedTLS = true;
      20          15 :   Options.ExplicitEmulatedTLS = true;
      21          15 : }
      22             : 
      23          15 : Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
      24             :   // FIXME: getProcessTriple is bogus. It returns the host LLVM was compiled on,
      25             :   //        rather than a valid triple for the current process.
      26          30 :   return JITTargetMachineBuilder(Triple(sys::getProcessTriple()));
      27             : }
      28             : 
      29             : Expected<std::unique_ptr<TargetMachine>>
      30          29 : JITTargetMachineBuilder::createTargetMachine() {
      31             : 
      32             :   std::string ErrMsg;
      33          29 :   auto *TheTarget = TargetRegistry::lookupTarget(TT.getTriple(), ErrMsg);
      34          29 :   if (!TheTarget)
      35           0 :     return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
      36             : 
      37             :   auto *TM =
      38          58 :       TheTarget->createTargetMachine(TT.getTriple(), CPU, Features.getString(),
      39          29 :                                      Options, RM, CM, OptLevel, /*JIT*/ true);
      40          29 :   if (!TM)
      41           0 :     return make_error<StringError>("Could not allocate target machine",
      42           0 :                                    inconvertibleErrorCode());
      43             : 
      44             :   return std::unique_ptr<TargetMachine>(TM);
      45             : }
      46             : 
      47          14 : JITTargetMachineBuilder &JITTargetMachineBuilder::addFeatures(
      48             :     const std::vector<std::string> &FeatureVec) {
      49          14 :   for (const auto &F : FeatureVec)
      50           0 :     Features.AddFeature(F);
      51          14 :   return *this;
      52             : }
      53             : 
      54             : } // End namespace orc.
      55             : } // End namespace llvm.

Generated by: LCOV version 1.13