feat(asm): Phase B.0 — validate asm shape in the compile path
Restructures the .asm_expr lowering arm into lowerAsmExpr, which validates the
asm shape with specific named diagnostics BEFORE the not-yet-implemented codegen
bail, so the user sees the real problem first. Two checklist items enforced:
- template must be a compile-time-known string ("..." or #string), not a
runtime expression;
- an asm with no value outputs must be `volatile` (else its effects could be
deleted) — mirrors Zig's rule.
Valid shapes still bail with the "codegen not yet implemented" message. Result-
type derivation + the operand auto-naming rule stay deferred to Phase C, where a
real IR op makes the result type observable/testable.
Locked with 1641-platform-asm-missing-volatile (the volatile error) and
1642-platform-asm-nop-volatile (no-output + volatile accepted → codegen bail).
zig build test green (650 corpus, 445 unit).
This commit is contained in:
6
examples/1641-platform-asm-missing-volatile.sx
Normal file
6
examples/1641-platform-asm-missing-volatile.sx
Normal file
@@ -0,0 +1,6 @@
|
||||
// ASM stream Phase B — an asm with no value outputs yields no result, so its
|
||||
// effects could be deleted unless it is marked `volatile`. This omits
|
||||
// `volatile` ⇒ a compile error. Pins that diagnostic (mirrors Zig's rule).
|
||||
// Called from `main` so lowering reaches the asm body.
|
||||
nope :: () { asm { "nop" }; }
|
||||
main :: () { nope(); }
|
||||
5
examples/1642-platform-asm-nop-volatile.sx
Normal file
5
examples/1642-platform-asm-nop-volatile.sx
Normal file
@@ -0,0 +1,5 @@
|
||||
// ASM stream Phase B — the no-output form IS accepted when `volatile` is
|
||||
// present: validation passes, and lowering then bails on the not-yet-
|
||||
// implemented codegen (Phases C–E). Confirms the volatile rule's positive side.
|
||||
nop :: () { asm volatile { "nop" }; }
|
||||
main :: () { nop(); }
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: asm expression with no outputs must be marked `volatile`
|
||||
--> examples/1641-platform-asm-missing-volatile.sx:5:14
|
||||
|
|
||||
5 | nope :: () { asm { "nop" }; }
|
||||
| ^^^^^^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/expected/1642-platform-asm-nop-volatile.exit
Normal file
1
examples/expected/1642-platform-asm-nop-volatile.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
5
examples/expected/1642-platform-asm-nop-volatile.stderr
Normal file
5
examples/expected/1642-platform-asm-nop-volatile.stderr
Normal file
@@ -0,0 +1,5 @@
|
||||
error: inline assembly codegen is not yet implemented (ASM stream: lowering + emit land in Phases C–E)
|
||||
--> examples/1642-platform-asm-nop-volatile.sx:4:13
|
||||
|
|
||||
4 | nop :: () { asm volatile { "nop" }; }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
1
examples/expected/1642-platform-asm-nop-volatile.stdout
Normal file
1
examples/expected/1642-platform-asm-nop-volatile.stdout
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user