I have read the last Power ISA manual from IBM (https://openpowerfoundation.org/?resource_lib=power-isa-version-3-0) and says [in page 35; 2.4 Branch Instructions]:
Obtaining the address of the next instruction:Use the following form of Branch and Link.
bcl 20, 31, $+4
where this standard comes from? It appears in all manual of powerpc instruction set, but there is some reason for write that?
In fact, the GNU compiler use that instruction.
Because on Power the instruction pointer isn't a general register we use this trick to get it into the LR.
$+4 is the next instruction which we jump to.
20 - corresponds in binary to 10100 which in Figure 40 means branch always.
31 is a condition register - which is ignored because of branch always.
So with this instruction we end up at the next instruction, and as a side effect we have LR containing the instruction address (of the instruction after the branch).
LR is effectively a return address (p.37 the if LK then LR <- CIA + 4 text) of the "subroutine" we just called (and don't need to return from. In Power this is used as a quick form compared to the stack).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With