lowerAsmExpr stops bailing and builds the inline_asm op: resolves each operand's
effective name (§II.5 — explicit [name] else the {reg} pin), interns
template/constraints/clobbers, lowers input Refs, derives the result TypeId
(0→void, 1→T). Adds the last deferred validation (every %[name] must name an
operand). Multi-output (N>1) bails with a named "Phase E" diagnostic.
emitInlineAsm (backend/llvm/ops.zig) ports Zig's airAssembly: assembles the LLVM
constraint string (outputs → inputs → ~{clobber}, ',' → '|'), rewrites the
template (%[name]→${N}, %%→%, $→$$, %=→${:uid}), then LLVMGetInlineAsm +
LLVMBuildCall2 (AT&T dialect). Dispatch wired in emit_llvm.zig (replacing the C.0
@panic tripwire).
inferType gains an .asm_expr arm (expr_typer.zig) so a bare `x := asm {…-> T}`
binding types correctly — without it the binding inferred .unresolved and
silently produced 0.
llvm_shim.c: LLVMInitializeNativeAsmParser() — the JIT must assemble inline asm
at run time.
Verified end-to-end on the aarch64 host: `mov`/`add` with register-class inputs
and a value output run (exit 42/99), `nop volatile` runs (exit 0). IR is
textbook: `call i64 asm "add ${0},${1},${2}", "=r,r,r"(…)`.
Locked with 1645 (aarch64 add, runs; ir-only on non-aarch64) + 1646 (:= binding).
Updated 1640 (now Phase-E bail) + 1642 (now runs).
zig build test green (654 corpus, 446 unit).
18 lines
581 B
Plaintext
18 lines
581 B
Plaintext
error: multi-output (tuple-returning) inline assembly is not yet implemented (ASM stream Phase E)
|
|
--> examples/1640-platform-asm-parse.sx:9:12
|
|
|
|
|
9 | return asm {
|
|
| ^^^^^
|
|
10 | "divq %[d]",
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
11 | [quot] "={rax}" -> u64,
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
12 | [rem] "={rdx}" -> u64,
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
13 | "{rax}" = n, "{rdx}" = 0, [d] "r" = d,
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
14 | clobbers(.cc),
|
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
15 | };
|
|
| ^^^^^
|