forked from OSchip/llvm-project
[llvm-mc] Add -M to replace -riscv-no-aliases and -riscv-arch-reg-names
In objdump, many targets support `-M no-aliases`. Instead of having a `-*-no-aliases` for each target when LLVM adds the support, it makes more sense to introduce objdump style `-M`. -riscv-arch-reg-names is removed. -riscv-no-aliases has too many uses and thus is retained for now. Reviewed By: luismarques Differential Revision: https://reviews.llvm.org/D103004
This commit is contained in:
parent
921d3f7af0
commit
73a1179535
|
@ -54,6 +54,9 @@ protected:
|
|||
/// True if we are printing marked up assembly.
|
||||
bool UseMarkup = false;
|
||||
|
||||
/// True if we prefer aliases (e.g. nop) to raw mnemonics.
|
||||
bool PrintAliases = true;
|
||||
|
||||
/// True if we are printing immediates as hex.
|
||||
bool PrintImmHex = false;
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ static cl::opt<bool>
|
|||
cl::desc("Disable the emission of assembler pseudo instructions"),
|
||||
cl::init(false), cl::Hidden);
|
||||
|
||||
static cl::opt<bool>
|
||||
ArchRegNames("riscv-arch-reg-names",
|
||||
cl::desc("Print architectural register names rather than the "
|
||||
"ABI names (such as x2 instead of sp)"),
|
||||
cl::init(false), cl::Hidden);
|
||||
// Print architectural register names rather than the ABI names (such as x2
|
||||
// instead of sp).
|
||||
// TODO: Make RISCVInstPrinter::getRegisterName non-static so that this can a
|
||||
// member.
|
||||
static bool ArchRegNames;
|
||||
|
||||
// The command-line flags above are used by llvm-mc and llc. They can be used by
|
||||
// `llvm-objdump`, but we override their values here to handle options passed to
|
||||
|
@ -52,7 +52,7 @@ static cl::opt<bool>
|
|||
// this way.
|
||||
bool RISCVInstPrinter::applyTargetSpecificCLOption(StringRef Opt) {
|
||||
if (Opt == "no-aliases") {
|
||||
NoAliases = true;
|
||||
PrintAliases = false;
|
||||
return true;
|
||||
}
|
||||
if (Opt == "numeric") {
|
||||
|
@ -69,11 +69,11 @@ void RISCVInstPrinter::printInst(const MCInst *MI, uint64_t Address,
|
|||
bool Res = false;
|
||||
const MCInst *NewMI = MI;
|
||||
MCInst UncompressedMI;
|
||||
if (!NoAliases)
|
||||
if (PrintAliases && !NoAliases)
|
||||
Res = uncompressInst(UncompressedMI, *MI, MRI, STI);
|
||||
if (Res)
|
||||
NewMI = const_cast<MCInst *>(&UncompressedMI);
|
||||
if (NoAliases || !printAliasInstr(NewMI, Address, STI, O))
|
||||
if (!PrintAliases || NoAliases || !printAliasInstr(NewMI, Address, STI, O))
|
||||
printInstruction(NewMI, Address, STI, O);
|
||||
printAnnotation(O, Annot);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# RUN: llvm-mc -triple riscv32 -mattr=+f,+d < %s -riscv-arch-reg-names \
|
||||
# RUN: llvm-mc -triple riscv32 -mattr=+f,+d -M numeric < %s \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-NUMERIC %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+f,+d < %s \
|
||||
# RUN: | llvm-objdump --mattr=+f,+d -d -M numeric - \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# RUN: llvm-mc -triple riscv32 -mattr=+f < %s -riscv-arch-reg-names \
|
||||
# RUN: llvm-mc -triple riscv32 -mattr=+f -M numeric < %s \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-NUMERIC %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+f < %s \
|
||||
# RUN: | llvm-objdump --mattr=+f -d -M numeric - \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# RUN: llvm-mc -triple riscv32 < %s -riscv-arch-reg-names \
|
||||
# RUN: llvm-mc -triple riscv32 -M numeric %s \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-NUMERIC %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
|
||||
# RUN: | llvm-objdump -d -M numeric - \
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases \
|
||||
# RUN: llvm-mc %s -triple=riscv32 -M no-aliases \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK-S-NOALIAS,CHECK-S-OBJ-NOALIAS %s
|
||||
# RUN: llvm-mc %s -triple=riscv32 \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK-S,CHECK-S-OBJ %s
|
||||
# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases\
|
||||
# RUN: llvm-mc %s -triple=riscv64 -M no-aliases \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK-S-NOALIAS,CHECK-S-OBJ-NOALIAS %s
|
||||
# RUN: llvm-mc %s -triple=riscv64 \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK-S,CHECK-S-OBJ %s
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# RUN: not llvm-mc -M invalid /dev/null 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: error: invalid disassembler option 'invalid'
|
|
@ -46,6 +46,9 @@ static mc::RegisterMCTargetOptionsFlags MOF;
|
|||
static cl::opt<std::string>
|
||||
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
|
||||
|
||||
static cl::list<std::string>
|
||||
DisassemblerOptions("M", cl::desc("Disassembler options"));
|
||||
|
||||
static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
|
||||
cl::value_desc("filename"),
|
||||
cl::init("-"));
|
||||
|
@ -496,6 +499,12 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
for (StringRef Opt : DisassemblerOptions)
|
||||
if (!IP->applyTargetSpecificCLOption(Opt)) {
|
||||
WithColor::error() << "invalid disassembler option '" << Opt << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Set the display preference for hex vs. decimal immediates.
|
||||
IP->setPrintImmHex(PrintImmHex);
|
||||
|
||||
|
|
Loading…
Reference in New Issue