feat(asm): Phase 2 — -> @place write-through outputs
An asm result can be STORED through a place (a local / struct field) instead of returned; the place output does not join the result tuple. - parser.zig: `-> @place` parses `@place` as an ordinary address-of expression → an out_place operand (the in-function form; reuses the existing `@` prefix). - inst.zig: AsmOperand gains out_ty (the output slot's value type) so emit can build the combined return struct without re-deriving from Inst.ty. - lower/expr.zig: out_place operand = the lowered @place address, out_ty = the pointee. Read-write (`+`) and indirect-memory (`*`) constraints rejected loudly (not yet implemented) rather than miscompiled. - ops.zig emitInlineAsm: the LLVM return type is built from ALL outputs (out_value + out_place); after the call, out_place slots are stored through their address and out_value slots rebuild the sx result. Fast path when there are no place outputs (the struct return IS the result — pure-value asm IR unchanged). Verified: write-to-local (42), struct field, mixed value+place (v=10 b=20), `+` rejected. Locked with 1649-platform-asm-place-output (mixed, runs on aarch64). zig build test green (657 corpus, 446 unit).
This commit is contained in:
@@ -368,8 +368,15 @@ pub const InlineAsm = struct {
|
||||
name: StringId,
|
||||
/// Verbatim constraint, e.g. "={rax}", "=r", "+r", "{rdi}", "r".
|
||||
constraint: StringId,
|
||||
/// `input` → the value `Ref`; `out_value` → `.none` (the asm yields it).
|
||||
/// `input` → the value `Ref`; `out_value` → `.none` (the asm yields it);
|
||||
/// `out_place` → the place ADDRESS `Ref` (a pointer; the asm result is
|
||||
/// `store`d through it).
|
||||
operand: Ref,
|
||||
/// The value type carried by an OUTPUT slot — `out_value`: its result
|
||||
/// type; `out_place`: the pointee type stored through `operand`. `.void`
|
||||
/// for inputs (their type comes from the input `Ref`). Lets emit build
|
||||
/// the combined LLVM return struct without re-deriving from `Inst.ty`.
|
||||
out_ty: TypeId = .void,
|
||||
|
||||
pub const Role = enum { out_value, out_place, input };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user