ffi 1.7: small struct returns through #objc_call (≤16 B + HFAs)
103/103 regression tests pass (+ffi-objc-call-05-struct-returns).
Three return shapes all round-trip cleanly with the existing Phase
1.6 `objc_msg_send` lowering — no codegen change needed because
emit_llvm.zig hands the IR struct type straight to LLVMBuildCall2
and the AArch64 / SysV AMD64 backends already know how to lower:
NSPoint — 16 B HFA (2×f64) → v0, v1 (AAPCS64) / xmm0, xmm1 (SysV)
NSRange — 16 B 2×u64 → x0, x1 register pair via [2 x i64]
NSRect — 32 B HFA (4×f64) → v0..v3 (AAPCS64) / xmm0..xmm3 (SysV)
Verified against the Obj-C runtime's `[nil structMethod]`-returns-
zero contract — no real-object setup needed, but the wider ABI
path runs exactly as it would for live receivers (the registers
the runtime stub uses come back through the same lowering).
>16 B non-HFA aggregates (e.g. {3×s64}) trip a sret cliff and
land in Phase 1.8. Verified locally that they return garbage in
the trailing field today — register pair / quad won't carry the
extra storage, and emit_llvm's `objc_msg_send` arm doesn't apply
the sret transform yet.
This commit is contained in:
1
tests/expected/ffi-objc-call-05-struct-returns.exit
Normal file
1
tests/expected/ffi-objc-call-05-struct-returns.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
3
tests/expected/ffi-objc-call-05-struct-returns.txt
Normal file
3
tests/expected/ffi-objc-call-05-struct-returns.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
point = (0.000000, 0.000000)
|
||||
range = (0, 0)
|
||||
rect = (0.000000, 0.000000, 0.000000, 0.000000)
|
||||
Reference in New Issue
Block a user