Skip to content

[llvm-objdump] Add -mllvm #75892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/docs/CommandGuide/llvm-objdump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ OPTIONS
Enable/disable target-specific attributes. Specify ``--mattr=help`` to display
the available attributes.

.. option:: -mllvm <arg>

Specify an argument to forward to LLVM's CommandLine library.

.. option:: --no-leading-addr, --no-addresses

When disassembling, do not print leading addresses for instructions or inline
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/tools/llvm-objdump/mllvm.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# REQUIRES: x86-registered-target
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
# RUN: llvm-objdump --no-print-imm-hex -d -mllvm --x86-asm-syntax=intel %t | FileCheck %s
# RUN: llvm-objdump --no-print-imm-hex -d -mllvm=--x86-asm-syntax=intel %t | FileCheck %s

# CHECK: lea rax, [rsi + 4*rdi + 5]

leaq 5(%rsi,%rdi,4), %rax
3 changes: 3 additions & 0 deletions llvm/tools/llvm-objdump/ObjdumpOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def mattr_EQ : Joined<["--"], "mattr=">,
MetaVarName<"a1,+a2,-a3,...">,
HelpText<"Target specific attributes (--mattr=help for details)">;

def mllvm : Separate<["-"], "mllvm">, HelpText<"Specify an argument to forward to LLVM's CommandLine library">, MetaVarName<"<arg>">;
def : Joined<["-"], "mllvm=">, Alias<mllvm>;

def no_show_raw_insn : Flag<["--"], "no-show-raw-insn">,
HelpText<"When disassembling instructions, "
"do not print the instruction bytes.">;
Expand Down
11 changes: 7 additions & 4 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3320,10 +3320,13 @@ static void parseObjdumpOptions(const llvm::opt::InputArgList &InputArgs) {
DisassemblerOptions.push_back(V.str());
}
}
if (AsmSyntax) {
const char *Argv[] = {"llvm-objdump", AsmSyntax};
llvm::cl::ParseCommandLineOptions(2, Argv);
}
SmallVector<const char *> Args = {"llvm-objdump"};
for (const opt::Arg *A : InputArgs.filtered(OBJDUMP_mllvm))
Args.push_back(A->getValue());
if (AsmSyntax)
Args.push_back(AsmSyntax);
if (Args.size() > 1)
llvm::cl::ParseCommandLineOptions(Args.size(), Args.data());

// Look up any provided build IDs, then append them to the input filenames.
for (const opt::Arg *A : InputArgs.filtered(OBJDUMP_build_id)) {
Expand Down