Closed
Description
Creating an extern C function like this:
#[repr(C)]
pub struct Point {
x: f32,
y: f32,
}
#[no_mangle]
pub extern "C" fn get_point() -> Point {
return Point{x: 10.0, y: 20.0}
}
and compiling using cargo build --target aarch64-apple-ios --release
, the assembly produced for get_point
is:
_get_point:
0000000000000000 movz x0, #16800, lsl #48
0000000000000004 movk x0, #16672, lsl #16
0000000000000008 ret
My ARM assembly is a little rusty, but I believe this is expecting the caller to pass in the address of a Point
in x0
, and then the function fills it in.
However, this C code, which should be equivalent:
struct point {
float x;
float y;
};
struct point get_point(void) {
return (struct point){10.0, 20.0};
}
compiles to the following assembly in Xcode 6.2 targeting arm64:
0x1000fec74: fmov s0, #1.000000e+01
0x1000fec78: fmov s1, #2.000000e+01
0x1000fec7c: ret
which is returning the two struct fields in the SIMD registers.
Is this an issue of how aarch64 is defined or configured, maybe?