aboutsummaryrefslogtreecommitdiff
path: root/docs/design/struct-by-value.md
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /docs/design/struct-by-value.md
a
Diffstat (limited to 'docs/design/struct-by-value.md')
-rw-r--r--docs/design/struct-by-value.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/design/struct-by-value.md b/docs/design/struct-by-value.md
new file mode 100644
index 0000000..bbc8f26
--- /dev/null
+++ b/docs/design/struct-by-value.md
@@ -0,0 +1,9 @@
+# structs in native calls
+
+zc structs whose fields are one word each (`int`, `float` or pointers) can be passed by value to `extern` functions, and native functions can return structs. the interpreter, o3, llvm and jit paths support sysv x86-64 and linux arm64 aapcs64. apple arm64 is not verified.
+
+arguments are classified according to the host ABI. on sysv x86-64, structs up to 16 bytes use integer or sse registers when the whole value fits; otherwise they go on the stack. larger structs go on the stack. on aapcs64, homogeneous float structs of up to four words use v registers, integer structs of up to two words use x registers, and other arguments follow the platform ABI.
+
+returns are limited to seven words. the call stub allocates an owned zc object and passes its address through the call block; the native ABI determines how the result is filled. the llvm descriptor path does not handle grouped struct signatures, so these calls use the generic native-call path.
+
+see `tests/programs/structval.zc` and `tests/programs/structret.zc` for executable examples. platform-specific behavior beyond x86-64 sysv and linux arm64 aapcs64 remains unverified.