diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp --- a/llvm/tools/llvm-mc/llvm-mc.cpp +++ b/llvm/tools/llvm-mc/llvm-mc.cpp @@ -337,6 +337,26 @@ // construct the Triple object. Triple TheTriple(TripleName); + // Package up features to be passed to target/subtarget + std::string FeaturesStr; + if (MAttrs.size()) { + SubtargetFeatures Features; + for (unsigned i = 0; i != MAttrs.size(); ++i) + Features.AddFeature(MAttrs[i]); + FeaturesStr = Features.getString(); + } + + // List available options for -mcpu=help or -mattr=help and then exit. + bool isHelp = std::string(MCPU) == "help" || + (MAttrs.size() && std::string(MAttrs[0]) == "help"); + if (isHelp) { + // We do this down here since the CPU/Feature help is underneath + // the target machine creation. + TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr); + + return 0; + } + ErrorOr> BufferPtr = MemoryBuffer::getFileOrSTDIN(InputFilename); if (std::error_code EC = BufferPtr.getError()) { @@ -438,15 +458,6 @@ if (GenDwarfForAssembly) Ctx.setGenDwarfRootFile(InputFilename, Buffer->getBuffer()); - // Package up features to be passed to target/subtarget - std::string FeaturesStr; - if (MAttrs.size()) { - SubtargetFeatures Features; - for (unsigned i = 0; i != MAttrs.size(); ++i) - Features.AddFeature(MAttrs[i]); - FeaturesStr = Features.getString(); - } - sys::fs::OpenFlags Flags = (FileType == OFT_AssemblyFile) ? sys::fs::OF_Text : sys::fs::OF_None; std::unique_ptr Out = GetOutputStream(OutputFilename, Flags);