atomics A.3a: swap + fence ops + recognizer, emit bails (lock)
swap (atomicrmw xchg) and a standalone fence wired end-to-end except LLVM emission (both bail loudly; A.3b makes them real). - RmwKind += xchg; atomic_swap intrinsic + swap method reuse the atomic_rmw op. - new atomic_fence op (+ AtomicFence) — ordering-only, void; fence($o)/atomic_fence intrinsic; recognizer rejects .relaxed (LLVM has no monotonic fence). - comptime_vm: xchg = store operand/return old; fence = no-op (single-thread). - examples 1703 (swap) + 1704 (fence) locked to bails; 1187 (relaxed-fence reject). - 1186 converted to a direct-intrinsic call → stable user-file diagnostic span (the lib-forward-site span shifted when atomic.sx grew — fragile-snapshot fix). Also fixes a latent A.2 comptime-CAS bug found while here: the success/null has_value write was 'writeWord(addr, SIZE=0, val=1)' — a 0-byte no-op, correct ONLY because allocBytes zero-inits (REJECTED-PATTERNS 'coincidentally correct'). Now writes the flag explicitly (size=1, val=0). Suite green (721/0).
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
error: atomic compare-exchange failure ordering ('.seq_cst') cannot be stronger than the success ordering ('.relaxed')
|
||||
--> /Users/agra/projects/sx/library/modules/std/atomic.sx:79:188
|
||||
--> examples/1186-diagnostics-atomic-cas-ordering.sx:11:50
|
||||
|
|
||||
79 | compare_exchange :: (self: *Atomic(T), expected: T, desired: T, $success: Ordering, $failure: Ordering) -> ?T { return atomic_cmpxchg(T, @self.value, expected, desired, success, failure); }
|
||||
| ^^^^^^^
|
||||
11 | _ := atomic_cmpxchg(i64, @n, 0, 1, .relaxed, .seq_cst);
|
||||
| ^^^^^^^^
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: fence ordering cannot be .relaxed (use .acquire / .release / .acq_rel / .seq_cst)
|
||||
--> examples/1187-diagnostics-atomic-fence-relaxed.sx:7:18
|
||||
|
|
||||
7 | atomic_fence(.relaxed);
|
||||
| ^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/expected/1703-atomics-swap.exit
Normal file
1
examples/expected/1703-atomics-swap.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
1
examples/expected/1703-atomics-swap.stderr
Normal file
1
examples/expected/1703-atomics-swap.stderr
Normal file
@@ -0,0 +1 @@
|
||||
error: atomic swap (xchg) LLVM emission not yet implemented (Stream A, A.3b)
|
||||
1
examples/expected/1703-atomics-swap.stdout
Normal file
1
examples/expected/1703-atomics-swap.stdout
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/expected/1704-atomics-fence.exit
Normal file
1
examples/expected/1704-atomics-fence.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
3
examples/expected/1704-atomics-fence.stderr
Normal file
3
examples/expected/1704-atomics-fence.stderr
Normal file
@@ -0,0 +1,3 @@
|
||||
error: atomic fence LLVM emission not yet implemented (Stream A, A.3b)
|
||||
error: atomic fence LLVM emission not yet implemented (Stream A, A.3b)
|
||||
error: atomic fence LLVM emission not yet implemented (Stream A, A.3b)
|
||||
1
examples/expected/1704-atomics-fence.stdout
Normal file
1
examples/expected/1704-atomics-fence.stdout
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user