[PATCH] D76591: [PPCInstPrinter] Change printBranchOperand(calltarget) to print the target address in hexadecimal form

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 03:44:13 PDT 2020


nemanjai added a comment.

This seems perfectly fine with me - and more consistent with GNU binutils.
However, I think the AIX guys should also have a look as I am not sure what the system assembler's capabilities are on AIX. I'll add a couple of AIX reviewers.



================
Comment at: llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp:421
     return printOperand(MI, OpNo, O);
-
-  // Branches can take an immediate operand. This is used by the branch
-  // selection pass to print, for example `.+8` (for ELF) or `$+8` (for AIX) to
-  // express an eight byte displacement from the program counter.
-  if (!TT.isOSAIX())
-    O << ".";
-  else
-    O << "$";
-
   int32_t Imm = SignExtend32<32>((unsigned)MI->getOperand(OpNo).getImm() << 2);
+  if (RelativeForm) {
----------------
jhenderson wrote:
> Not being a PPC expert, what is the `<< 2` all about?
The branches on PPC must branch to word-aligned (4-byte word) addresses. So the branch address is the encoded value shifted two bits to the left (plus PC for the PC-relative ones).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76591





More information about the llvm-commits mailing list