Compiling bar(x: i64) { x + 1 }
yields the following assembly code on ARM64 with tail call convention. It looks like first argument is passed via register x2
and return value is also x2
. So I am curious what is x0
and x1
used for in this case?
0000000000000000 <_bar>:
0: d503235f pacibz
4: a9bf7bfd stp x29, x30, [sp, #-16]!
8: 910003fd mov x29, sp
c: 91000442 add x2, x2, #1
10: a8c17bfd ldp x29, x30, [sp], #16
14: d50323df autibz
18: d65f03c0 ret
this comment answers your question, I think!
Thank you! What is return area pointer? Also, why does indirect call need a devoted register like so? Can't the callee address be stored in a scratch register like x16?
The "return area pointer" is used in some ABIs when a value larger than can fit in a register is returned
Re: scratch, I'm not sure exactly, but it might have to do with the fact that x16 is already reserved for lowering address/offset-generation sequences, and so is required at a "lower level" (to implement spills/reloads that may fill in registers for the tail call)
@fitzgen (he/him) could probably say more about the implementation as he drove the effort
Thanks! For my purpose I am just trying to implement exception handler to resume operation after handling an exception. So it sounds like I do not care about values in these registers when restoring execution states.
Last updated: Dec 23 2024 at 12:05 UTC