I have not found a way to obtain a list of features available for the target machine. MCSubtargetInfo provides the getFeatureBits() method, but I have not found a way to translate the FeatureBitset to feature names (e.g. "sse2", "avx") or their description. MCSubtargetInfo does contain a reference to that information but does not expose that to the user.
This patch exposes the private ProcFeatures list to user code, similar to exposing the FeatureBits.
I intend to use this in our front-end (LDC) to check whether a feature is enabled or not:
auto *mcinfo = gTargetMachine->getMCSubtargetInfo();
auto featbits = mcinfo->getFeatureBits();
auto featTable = mcinfo->getProcFeatures();
for (auto &feat : featTable) {
if ((featbits & feat.Value) == feat.Value)
//check if feat.Key is equal to the feature we seek
}Thanks for reviewing.
Should the return type be const?