about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-28 17:55:13 +0200
committerGitHub <noreply@github.com>2018-03-28 17:55:13 +0200
commit294f041f13cf78fb03c3da3b7e07aae8c03b19c8 (patch)
tree0fc8fc11329c439b869ff1e89e39a1040883736b /src/rustllvm/PassWrapper.cpp
parent6ca14660affb3a8eace557f8dfb27a520be38fd8 (diff)
parenta93a4d259ae3670d748859f430aba94f065ea6df (diff)
downloadrust-294f041f13cf78fb03c3da3b7e07aae8c03b19c8.tar.gz
rust-294f041f13cf78fb03c3da3b7e07aae8c03b19c8.zip
Rollup merge of #49428 - cuviper:llvm6-target_feature, r=alexcrichton
Enable target_feature on any LLVM 6+

In `LLVMRustHasFeature()`, rather than using `MCInfo->getFeatureTable()`
that is specific to Rust's LLVM fork, we can use this in LLVM 6:

    /// Check whether the subtarget features are enabled/disabled as per
    /// the provided string, ignoring all other features.
    bool checkFeatures(StringRef FS) const;

Now rustc using external LLVM can also have `target_feature`.

r? @alexcrichton
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
-rw-r--r--src/rustllvm/PassWrapper.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index 3d5cce81278..382ef2cc407 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -205,17 +205,13 @@ GEN_SUBTARGETS
 
 extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
                                    const char *Feature) {
-#if LLVM_RUSTLLVM
+#if LLVM_VERSION_GE(6, 0)
   TargetMachine *Target = unwrap(TM);
   const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
-  const FeatureBitset &Bits = MCInfo->getFeatureBits();
-  const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
-
-  for (auto &FeatureEntry : FeatTable)
-    if (!strcmp(FeatureEntry.Key, Feature))
-      return (Bits & FeatureEntry.Value) == FeatureEntry.Value;
-#endif
+  return MCInfo->checkFeatures(std::string("+") + Feature);
+#else
   return false;
+#endif
 }
 
 enum class LLVMRustCodeModel {