docs(asm): note x86 %[fn:P] call modifier + checkpoint x86 coverage
This commit is contained in:
@@ -87,6 +87,21 @@ Two reasons to prefer this over passing a function *pointer* in a plain
|
||||
- **Portable** — the backend emits the correctly-mangled name, so you
|
||||
don't hardcode the macOS leading underscore.
|
||||
|
||||
On **x86_64**, a direct `call` to a symbol operand needs the `P`
|
||||
("call-target") operand modifier — `%[name:P]` (the GCC `%P0` idiom):
|
||||
|
||||
```sx
|
||||
return asm volatile {
|
||||
"call %[fn:P]", // x86_64 — note the :P modifier
|
||||
[ret] "={rax}" -> i64,
|
||||
"{rdi}" = n,
|
||||
[fn] "s" = cb,
|
||||
clobbers(.rcx, .rdx, .rsi, .r8, .r9, .r10, .r11, .memory),
|
||||
};
|
||||
```
|
||||
|
||||
aarch64 `bl %[fn]` needs no modifier.
|
||||
|
||||
The callee needs a stable, externally-linked symbol — i.e. `export`
|
||||
(which also gives it the C ABI). A plain or `callconv(.c)`-only function
|
||||
is `internal` and gets dead-code-eliminated, so the symbol won't link.
|
||||
|
||||
Reference in New Issue
Block a user