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`.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user