diff options
| author | Fangrui Song <i@maskray.me> | 2025-04-08 19:34:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-08 19:34:03 -0700 |
| commit | 02b377d8f7252b1acf6ea4fad55a101b6bc3fcf7 (patch) | |
| tree | 821df4e0107a952fbf784395fc1331a1683b4646 /llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp | |
| parent | 333f2c334174ee2c3b70f6db01970b339459bfa6 (diff) | |
[llc] Add -M for InstPrinter options
For many targets, llvm-objdump and llvm-mc
(https://reviews.llvm.org/D103004) support -M no-aliases (e.g.
`RISCVInstPrinter::applyTargetSpecificCLOption`).
This patch implements -M for llc.
While here, rename "DisassemblerOptions" in llvm-mc to the more
appropriate "InstPrinterOptions". For llvm-mc --assemble, there is no
disassembler involved.
Pull Request: https://github.com/llvm/llvm-project/pull/121078
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp index 5757ca1b3adf..37611479088b 100644 --- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp +++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCRegisterInfo.h" @@ -132,8 +133,10 @@ bool CodeGenTargetMachineImpl::addAsmPrinter(PassManagerBase &PM, MCContext &Context) { Expected<std::unique_ptr<MCStreamer>> MCStreamerOrErr = createMCStreamer(Out, DwoOut, FileType, Context); - if (auto Err = MCStreamerOrErr.takeError()) + if (!MCStreamerOrErr) { + Context.reportError(SMLoc(), toString(MCStreamerOrErr.takeError())); return true; + } // Create the AsmPrinter, which takes ownership of AsmStreamer if successful. FunctionPass *Printer = @@ -163,6 +166,9 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out, getTargetTriple(), Options.MCOptions.OutputAsmVariant.value_or(MAI.getAssemblerDialect()), MAI, MII, MRI); + for (StringRef Opt : Options.MCOptions.InstPrinterOptions) + if (!InstPrinter->applyTargetSpecificCLOption(Opt)) + return createStringError("invalid InstPrinter option '" + Opt + "'"); // Create a code emitter if asked to show the encoding. std::unique_ptr<MCCodeEmitter> MCE; |
