[Lldb-commits] [PATCH] D155107: Add support for llvm::MCInstPrinter::setPrintBranchImmAsAddress

Ted Woodward via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 18 15:31:37 PDT 2023


ted added a comment.

In D155107#4511967 <https://reviews.llvm.org/D155107#4511967>, @clayborg wrote:

> Looks like other disassemblers already show full addresses for the branches and calls (at least arm64 does from my output above), so not sure why RISCV would require this setting, but x86_64 and arm64 wouldn't because it is already working that way??

llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp has this code, specifically using PrintBranchImmAsAddress to gate this behavior:

  void RISCVInstPrinter::printBranchOperand(const MCInst *MI, uint64_t Address,
                                            unsigned OpNo,
                                            const MCSubtargetInfo &STI,
                                            raw_ostream &O) {
    const MCOperand &MO = MI->getOperand(OpNo);
    if (!MO.isImm())
      return printOperand(MI, OpNo, STI, O);
  
    if (PrintBranchImmAsAddress) {
      uint64_t Target = Address + MO.getImm();
      if (!STI.hasFeature(RISCV::Feature64Bit))
        Target &= 0xffffffff;
      O << formatHex(Target);
    } else {
      O << MO.getImm();
    }
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155107/new/

https://reviews.llvm.org/D155107



More information about the lldb-commits mailing list