[llvm] 5c05b4a - [Orc] Add setters for target options and features to JITTargetMachineBuilder.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 01:57:02 PST 2019
Author: Lang Hames
Date: 2019-12-02T01:52:51-08:00
New Revision: 5c05b4a279f51d7eaa91f008bc5dc2155d98061a
URL: https://github.com/llvm/llvm-project/commit/5c05b4a279f51d7eaa91f008bc5dc2155d98061a
DIFF: https://github.com/llvm/llvm-project/commit/5c05b4a279f51d7eaa91f008bc5dc2155d98061a.diff
LOG: [Orc] Add setters for target options and features to JITTargetMachineBuilder.
Also remove redundant feature initialization steps from the detectHost method.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
index bcbd72e68f15..c8c4ecdaff16 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
@@ -91,6 +91,12 @@ class JITTargetMachineBuilder {
return *this;
}
+ /// Set subtarget features.
+ JITTargetMachineBuilder &setFeatures(StringRef FeatureString) {
+ Features = SubtargetFeatures(FeatureString);
+ return *this;
+ }
+
/// Add subtarget features.
JITTargetMachineBuilder &
addFeatures(const std::vector<std::string> &FeatureVec);
@@ -101,6 +107,17 @@ class JITTargetMachineBuilder {
/// Access subtarget features.
const SubtargetFeatures &getFeatures() const { return Features; }
+ /// Set TargetOptions.
+ ///
+ /// Note: This operation will overwrite any previously configured options,
+ /// including EmulatedTLS and ExplicitEmulatedTLS which
+ /// the JITTargetMachineBuilder sets by default. Clients are responsible
+ /// for re-enabling these overwritten options.
+ JITTargetMachineBuilder &setOptions(TargetOptions Options) {
+ this->Options = std::move(Options);
+ return *this;
+ }
+
/// Access TargetOptions.
TargetOptions &getOptions() { return Options; }
diff --git a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
index 1d3e6db913e2..114e81e41771 100644
--- a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
@@ -28,14 +28,12 @@ Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
// Retrieve host CPU name and sub-target features and add them to builder.
// Relocation model, code model and codegen opt level are kept to default
// values.
- llvm::SubtargetFeatures SubtargetFeatures;
llvm::StringMap<bool> FeatureMap;
llvm::sys::getHostCPUFeatures(FeatureMap);
for (auto &Feature : FeatureMap)
- SubtargetFeatures.AddFeature(Feature.first(), Feature.second);
+ TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second);
TMBuilder.setCPU(llvm::sys::getHostCPUName());
- TMBuilder.addFeatures(SubtargetFeatures.getFeatures());
return TMBuilder;
}
More information about the llvm-commits
mailing list