This is the union of patch 1 and patch 2 described by the LLVM-dev RFC "MC support for variant scheduling classes".
This patch introduces method resolveVariantSchedClass() in MCSubtargetInfo.
A follow-up llvm-mca patch (D46698) will be able to use that method to solve variant scheduling classes.