blob: df23547a9de3ab0345ac57f2de2ba9d9c3e85dbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
//===----- JITTargetMachineBuilder.cpp - Build TargetMachines for JIT -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/Support/TargetRegistry.h"
namespace llvm {
namespace orc {
JITTargetMachineBuilder::JITTargetMachineBuilder(Triple TT)
: TT(std::move(TT)) {
Options.EmulatedTLS = true;
Options.ExplicitEmulatedTLS = true;
}
Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
// FIXME: getProcessTriple is bogus. It returns the host LLVM was compiled on,
// rather than a valid triple for the current process.
return JITTargetMachineBuilder(Triple(sys::getProcessTriple()));
}
Expected<std::unique_ptr<TargetMachine>>
JITTargetMachineBuilder::createTargetMachine() {
std::string ErrMsg;
auto *TheTarget = TargetRegistry::lookupTarget(TT.getTriple(), ErrMsg);
if (!TheTarget)
return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
auto *TM =
TheTarget->createTargetMachine(TT.getTriple(), CPU, Features.getString(),
Options, RM, CM, OptLevel, /*JIT*/ true);
if (!TM)
return make_error<StringError>("Could not allocate target machine",
inconvertibleErrorCode());
return std::unique_ptr<TargetMachine>(TM);
}
JITTargetMachineBuilder &JITTargetMachineBuilder::addFeatures(
const std::vector<std::string> &FeatureVec) {
for (const auto &F : FeatureVec)
Features.AddFeature(F);
return *this;
}
} // End namespace orc.
} // End namespace llvm.
|