Currently, the interaction between the triple, the CPU, and the supported features is a mess: the driver edits the triple to indicate the supported architecture version, and the LLVM backend uses this to figure out what instructions are legal. This makes it difficult to understand what's happening, and makes it impossible to LTO together two modules with different computed architectures.
Instead of relying on triple rewriting to get the correct target features, we should add the right target features explicitly.
Would it make sense to add this to llvm/Support/TargetParser? We already have AArch64::getArchFeatures there and it looks like it does something similar for AArch64.
llvm/Support/ARMTargetParser.def defines the different architectures + extensions and it seems like it should possible to extend it slightly to handle the architecture features.