Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return structs from functions #14

Open
DontBelieveMe opened this issue Jan 7, 2022 · 0 comments
Open

Return structs from functions #14

DontBelieveMe opened this issue Jan 7, 2022 · 0 comments
Assignees
Labels
codegen Machine/Assembly Code Generation enhancement New feature or request ir Relating to the IR

Comments

@DontBelieveMe
Copy link
Owner

Returning structs needs some special handling, see Parameter Passing - AAPCS32

https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#64result-return

In short:

  • If it's smaller than (or equal to) 4 bytes in size (native register size) then it is stored directly in the r0 register (sign or zero extended if nessesary)
  • If it's larger than 4 bytes then the value is stored in memory and the address of that value is passed to the called function as a parameter (in r0)
@DontBelieveMe DontBelieveMe self-assigned this Jan 7, 2022
@DontBelieveMe DontBelieveMe added enhancement New feature or request ir Relating to the IR codegen Machine/Assembly Code Generation labels Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Machine/Assembly Code Generation enhancement New feature or request ir Relating to the IR
Projects
None yet
Development

No branches or pull requests

1 participant