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

Use x8 register for result struct address on aarch64 #124

Open
tyfkda opened this issue Sep 14, 2023 · 0 comments
Open

Use x8 register for result struct address on aarch64 #124

tyfkda opened this issue Sep 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@tyfkda
Copy link
Owner

tyfkda commented Sep 14, 2023

Unlike x64, aarch64 uses %x8 to pass the function result struct address:

typedef struct {
    long long x, y, z;
} FooStruct;

FooStruct return_struct(long long x, long long y, long long z) {
    FooStruct s = {.x = x, .y = y, .z = z};
    return s;
}
$ gcc -S -O2 -fno-asynchronous-unwind-tables ,foo/foo.c
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_return_struct                  ; -- Begin function return_struct
	.p2align	2
_return_struct:                         ; @return_struct
	.cfi_startproc
; %bb.0:
	stp	x0, x1, [x8]
	str	x2, [x8, #16]
	ret
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols
@tyfkda tyfkda added the enhancement New feature or request label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant