[PATCH] D60428: [Aarch64AsmPrinter] support %c output template for global addresses

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 06:37:47 PDT 2019


peter.smith added a comment.

In D60428#1460079 <https://reviews.llvm.org/D60428#1460079>, @nickdesaulniers wrote:

> > I have a mild preference for following most of the other backends so that we don't split the handling of 'c' across the generic and the target specific
>
> Thinking more about this last night; it's going to be a pain/stupid to keep reimplementing this for other arches.  The Linux kernel is using `%c` with global addresses for arm32 and ppc (and many others).  I think I should:
>
> 1. Create `AsmPrinter::printSymbolOperand()`, a virtual method of the generic class, that simply forwards its arguments to the virtual method `printAsmOperand()`.
> 2. Update `X86AsmPrinter::printSymbolOperand()` to be a member function rather than `static` local function, overriding the base `AsmPrinter::printSymbolOperand()`.
> 3. Handle `%c` in the generic `AsmPrinter::PrintAsmOperand()`, deferring to the now virtual method `printSymbolOperand()` for `MachineOperand::MO_GlobalAddress`, thus supporting `%c` w/ `MachineOperand::MO_GlobalAddress` for all architectures.
>
>   How does that sound?


That sounds reasonable to me. I think some backends such as Power and Hexagon have explicit handling for 'c' that does nothing:

  case 'c': // Don't print "$" before a global var name or constant.
    break; // PPC never has a prefix.

Will be worth checking all the backends for custom handling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60428





More information about the llvm-commits mailing list