<div dir="ltr"><div><div>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).<br><br>What is the best way to query LLVM about the features that are available on a given target?<br>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.<br><br>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.<br>This approach is implemented as part of <a href="https://github.com/rust-lang/rust/pull/31709">https://github.com/rust-lang/rust/pull/31709</a><br>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.<br><br>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.<br></div>Did I miss something obvious?<br><br></div><div>Thank you<br></div><div>Andrea<br></div></div>