We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Unlike x64 or RISCV64, aarch64 uses %x8 (instead of first argument register) to pass the function result struct address:
%x8
sub.h:
typedef struct { long long x, y, z; } FooStruct; extern FooStruct return_struct(long long x, long long y, long long z);
sub.c:
#include "sub.h" FooStruct return_struct(long long x, long long y, long long z) { FooStruct s = {.x = x, .y = y, .z = z}; return s; }
$ gcc -S -o- -O2 -fno-asynchronous-unwind-tables sub.c .section __TEXT,__text,regular,pure_instructions .build_version macos, 14, 0 sdk_version 15, 2 .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
main.c:
$ gcc -S -o- -O2 -fno-asynchronous-unwind-tables main.c .section __TEXT,__text,regular,pure_instructions .build_version macos, 14, 0 sdk_version 15, 2 .globl _main ; -- Begin function main .p2align 2 _main: ; @main .cfi_startproc ; %bb.0: sub sp, sp, #48 stp x29, x30, [sp, #32] ; 16-byte Folded Spill add x29, sp, #32 .cfi_def_cfa w29, 16 .cfi_offset w30, -8 .cfi_offset w29, -16 add x8, sp, #8 ;########## FooStruct s mov w0, #1 ; =0x1 mov w1, #2 ; =0x2 mov w2, #3 ; =0x3 bl _return_struct ldr w8, [sp, #8] ldr w9, [sp, #16] ldr w10, [sp, #24] add w8, w9, w8 add w0, w8, w10 ldp x29, x30, [sp, #32] ; 16-byte Folded Reload add sp, sp, #48 ret .cfi_endproc ; -- End function .subsections_via_symbols
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Unlike x64 or RISCV64, aarch64 uses
%x8
(instead of first argument register) to pass the function result struct address:sub.h:
sub.c:
main.c:
The text was updated successfully, but these errors were encountered: