Implements indirect-memory (`=*m`) `-> @place` outputs — the last
substantive asm feature. Unlike a write-through `=` output (which
returns a value that is then stored), an indirect output passes the
place ADDRESS to the asm and the asm writes through it; there is no
return slot.
emitInlineAsm:
- indirect outputs are excluded from the LLVM return type;
- their pointer is passed as an opaque `ptr` call arg, placed FIRST
(the arg-consuming constraint order is: output-section indirect
pointers, then inputs, then read-write tied seeds);
- each indirect arg gets an `elementtype(T)` call-site attribute
(required in the opaque-pointer era), T = the pointee type;
- the store-back loop skips indirect outputs (already written).
New asmIsIndirect helper. Lowering stops rejecting `*` (constraint kept
verbatim; `=*m` reaches the constraint string as-is). asmOperandIndex
is unchanged — indirect outputs still count as operands, so `%[name]`
${N} numbering holds.
Verified by running on aarch64: store-through-pointer (str x9, %[out]
→ 42, IR `=*m,~{x9}` with `ptr elementtype(i64)`) and a mixed case
(indirect + value output + input → `=*m,=r,r`, indirect ptr arg first,
${0}/${1}/${2} correct). 1652 flipped from the rejection lock to a
runnable aarch64 example (ir-only elsewhere). zig build test green
(661 corpus, 446 unit).
19 lines
452 B
Plaintext
19 lines
452 B
Plaintext
|
|
; Function Attrs: nounwind
|
|
define internal i64 @poke() #0 {
|
|
entry:
|
|
%alloca = alloca i64, align 8
|
|
store i64 0, ptr %alloca, align 8
|
|
call void asm sideeffect " mov x9, #42\0A str x9, ${0}\0A", "=*m,~{x9}"(ptr elementtype(i64) %alloca)
|
|
%load = load i64, ptr %alloca, align 8
|
|
ret i64 %load
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @main() #0 {
|
|
entry:
|
|
%call = call i64 @poke()
|
|
%ca.tr = trunc i64 %call to i32
|
|
ret i32 %ca.tr
|
|
}
|