HomePhabricator

[PowerPC][LLD] Extend R2 save stub to support offsets of more than 26 bits

Authored by stefanp on Sep 22 2020, 4:44 PM.

Description

[PowerPC][LLD] Extend R2 save stub to support offsets of more than 26 bits

The R2 save stub will now support offsets up to 64 bits.

There are three cases that will be used.

  1. The offset fits in 26 bits.
b <26 bit offset>
  1. The offset does not fit in 26 bits but fits in 34 bits.
paddi r12, 0, <34 bit offset>, 1
mtctr r12
bctr
  1. The offset does not fit in 34 bits. Since this is an R2 save stub we can use

the TOC in R2. We are not loading the offset but the actual address we want to
branch to.

addis r12, r2, <address in TOC lo>
ld r12 <address in TOC hi>(r12)
mtctr r12
bctr

In case 1) the stub is only 8 bytes while in cases 2) and 3) the stub will be
20 bytes.

Reviewed By: MaskRay, sfertile, NeHuang

Differential Revision: https://reviews.llvm.org/D87916