The Rust compiler needs to expose some compile-time flags that describe what features are available on the target (so far this is mostly for SIMD extensions).
What is the best way to query LLVM about the features that are available on a given target?
I would love if it was possible to extract them from MCSubtargetInfo, but even though the features are exposed through getFeatureBits(), it is nontrivial to associate this bitset with the actual features.
So far I only managed to find a hackish way to do it: since the FeatureKV tables are public, I scan through them to find out what feature is associated with each enabled bit in the feature bitset.
This approach is implemented as part of https://github.com/rust-lang/rust/pull/31709
It looks brittle, because the FeatureKV tables are public, but it is not obvious whether they are meant to be accessed from outside of LLVM, and more complicated than it should be.
I believe it would become very easy and more robust if the ProcFeatures field of MCSubtargetInfo was exposed in some way, but I did not find any way to access it.
Did I miss something obvious?