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:
@@ -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