This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Regarding Linux aarch64 calling conventions (ABI)

In the documenttion I've seen, it appears that the first 8 registers x0-x7 are for parameter passing and don't need to be saved.

But this is always vaguely defined so I need to ask:

If function A uses all of x0-x7 and then calls function B, which uses x4-x7 as temporary variables, this will wipe out function A's values. Why would I not need to back up x4-x7, as the documentation suggests?

Thanks.

Parents
  • Hi Elm,

    The AAPCS does not suggest you don't need to save them. See github.com/.../aapcs64.rst

    The key sentence is:

    "The first eight registers, r0-r7, are used to pass argument values into a subroutine and to return result values from a function. They may also be used to hold intermediate values within a routine (but, in general, only between subroutine calls)."

    emphasis mine, So it's saying that you can only use them to hold temporary state between any two function calls. so as soon as you make a call there's no expectation that they be preserved.  So if you want to preserve them either use callee saves or spill/reload them. 

Reply
  • Hi Elm,

    The AAPCS does not suggest you don't need to save them. See github.com/.../aapcs64.rst

    The key sentence is:

    "The first eight registers, r0-r7, are used to pass argument values into a subroutine and to return result values from a function. They may also be used to hold intermediate values within a routine (but, in general, only between subroutine calls)."

    emphasis mine, So it's saying that you can only use them to hold temporary state between any two function calls. so as soon as you make a call there's no expectation that they be preserved.  So if you want to preserve them either use callee saves or spill/reload them. 

Children
No data