[PATCH] D126403: [RISCV] reorganize getFrameIndexReference to reduce code duplication [nfc]

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 11:45:15 PDT 2022


reames created this revision.
reames added reviewers: frasercrmck, craig.topper, kito-cheng, StephenFan.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, asb, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: alextsao1999, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

This change reorganizes the majority of frame index resolution into a two strep process.

- Step 1 - Select which base register we're going to use.
- Step 2 - Compute the offset from that base register.

The key point is that this allows us to share the step 2 logic for the SP case.  This reduces the code duplication, and (I think) makes the code much easier to follow.

I also went ahead and added assertions into phase 2 to catch errors where we select an illegal base pointer.  In general, we can't index from a base register to a stack location if that requires crossing a variable and unknown region.  In practice, we have two such cases: dynamic stack realign and var sized objects.  Note that crossing the scalable region is fine since while variable, it's a known variability which can be expressed in the offset.

After D125787 <https://reviews.llvm.org/D125787>, I believe this to be fully NFC.  Careful review to confirm that is appreciated.  :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126403

Files:
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126403.432059.patch
Type: text/x-patch
Size: 8594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220525/f508b514/attachment.bin>


More information about the llvm-commits mailing list