Do Aarch64 char parameters and returns have the top undefined?

If a char parameter is passed to a routine in Aarch64 is the top of the word undefined? and is the same true for if a char value is returned? I think the answer is yes but it would be good to be certain. This means if the char is used in some arithmetic the UXTB, or SXTB for signed, modifiers as described at A64 Shift and Extend Operations: Operand Modifiers must be used in an instruction using a register containing a char passed into or returned from a routine.

I presume the same is true for short as well so a signed short might for instance come in with the top two bytes containing zero

Parents
  • According to AAPCS64, the unused bits have "unspecified value". This is actually a good thing overall, since it removes the need for the caller to explicitly clear those bits before calling a function which doesn't care anyway (because it can use something like UXTB or SXTB). This applies to char, short, int, float, or anything else that doesn't use the full 8 bytes of an X or D register or procedure-call stack slot.

    Finally, note that this is different from the 32-bit AAPCS behaviour, where small values have to be zero- or sign-extended.

Reply
  • According to AAPCS64, the unused bits have "unspecified value". This is actually a good thing overall, since it removes the need for the caller to explicitly clear those bits before calling a function which doesn't care anyway (because it can use something like UXTB or SXTB). This applies to char, short, int, float, or anything else that doesn't use the full 8 bytes of an X or D register or procedure-call stack slot.

    Finally, note that this is different from the 32-bit AAPCS behaviour, where small values have to be zero- or sign-extended.

Children
More questions in this forum