LLVM  8.0.1
JITTargetMachineBuilder.cpp
Go to the documentation of this file.
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 
11 
13 
14 namespace llvm {
15 namespace orc {
16 
18  : TT(std::move(TT)) {
19  Options.EmulatedTLS = true;
20  Options.ExplicitEmulatedTLS = true;
21 }
22 
24  // FIXME: getProcessTriple is bogus. It returns the host LLVM was compiled on,
25  // rather than a valid triple for the current process.
27 }
28 
31 
32  std::string ErrMsg;
33  auto *TheTarget = TargetRegistry::lookupTarget(TT.getTriple(), ErrMsg);
34  if (!TheTarget)
35  return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
36 
37  auto *TM =
38  TheTarget->createTargetMachine(TT.getTriple(), CPU, Features.getString(),
39  Options, RM, CM, OptLevel, /*JIT*/ true);
40  if (!TM)
41  return make_error<StringError>("Could not allocate target machine",
43 
44  return std::unique_ptr<TargetMachine>(TM);
45 }
46 
48  const std::vector<std::string> &FeatureVec) {
49  for (const auto &F : FeatureVec)
50  Features.AddFeature(F);
51  return *this;
52 }
53 
54 } // End namespace orc.
55 } // End namespace llvm.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
std::string getString() const
Returns features as a string.
F(f)
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Definition: BitVector.h:938
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
static Expected< JITTargetMachineBuilder > detectHost()
Create a JITTargetMachineBuilder for the host system.
unsigned ExplicitEmulatedTLS
Whether -emulated-tls or -no-emulated-tls is set.
JITTargetMachineBuilder(Triple TT)
Create a JITTargetMachineBuilder based on the given triple.
JITTargetMachineBuilder & addFeatures(const std::vector< std::string > &FeatureVec)
Add subtarget features.
std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
Definition: Host.cpp:1430
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library...
const std::string & getTriple() const
Definition: Triple.h:361
Expected< std::unique_ptr< TargetMachine > > createTargetMachine()
Create a TargetMachine.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:78
A utility class for building TargetMachines for JITs.