[PATCH] D75280: [PowerPC][Future] Add initial support for PC Relative addressing for global values

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 17 06:52:31 PDT 2020


nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

My comments are quite minor so feel free to address them on the commit. LGTM.



================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:2545
 bool PPCTargetLowering::SelectAddressPCRel(SDValue N, SDValue &Base) const {
+  // This is a materialize PC Relative node. Always select this as PC Relative.
+  if (N.getOpcode() == PPCISD::MAT_PCREL_ADDR) {
----------------
The logic might be easier to follow if we do something like:
```
Base = N;
if (N.getOpcode() == PPCISD::MAT_PCREL_ADDR)
  return true;
if (ConstantPoolSDNode *CPN = dyn_cast<ConstantPoolSDNode>(N) &&
                              (CPN->getTargetFlags() & PPCII::MO_PCREL_FLAG))
  return true;
if (GlobalAddressSDNode *GAN = dyn_cast<GlobalAddressSDNode>(N) &&
                               (GAN->getTargetFlags() & PPCII::MO_PCREL_FLAG))
  return true;
return false;
```


================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:3011
   // The actual address of the GlobalValue is stored in the TOC.
   if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
+    if (!isAccessedAsGotIndirect(Op) && Subtarget.hasPCRelativeMemops()) {
----------------
Please remove this from the AIX block. There is no current plan to support PC-relative addressing on AIX.


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

https://reviews.llvm.org/D75280





More information about the llvm-commits mailing list