atomics A.0a: lib + IR ops + recognizer, emit bails (lock commit)
Stream A (atomics) foundation. Net-new atomic load/store codegen path, wired end-to-end except LLVM emission, which deliberately bails loudly so the example locks to a clean diagnostic (A.0b turns it green — cadence: no commit both adds a test and makes it pass). - library/modules/std/atomic.sx: Ordering enum, Atomic($T) transparent wrapper (init/load/store, seq_cst-only for now), atomic_load/atomic_store #builtin intrinsics. Opt-in import, NOT in the universal std facade (Ordering in the prelude grows every program's type table + churns 37 .ir snapshots). - IR: atomic_load/atomic_store ops + AtomicOrdering (all 5) + structs (inst.zig); print arms; comptime_vm arms reuse load/store (single-thread correct); recognizer tryLowerAtomicIntrinsic (const-ordering + scalar-size guards, both loud); emit dispatch -> emitAtomicLoad/Store bail via comptime_failed. - examples/1700-atomics-load-store.sx locked to the bail diagnostic. Full ordering surface (a.load(.acquire)) blocked on comptime-constant ordering propagation (comptime enum value params) — A.0.5, migrated not legacy.
This commit is contained in:
17
examples/1700-atomics-load-store.sx
Normal file
17
examples/1700-atomics-load-store.sx
Normal file
@@ -0,0 +1,17 @@
|
||||
// Atomic($T) load/store (seq_cst), single-thread.
|
||||
// Stream A (atomics) A.0 — the first net-new atomic codegen example.
|
||||
// Explicit orderings (a.load(.acquire)) arrive in A.0.5; see PLAN-ATOMICS.md.
|
||||
// Atomics is an opt-in import (not in the universal prelude) — like `trace`.
|
||||
#import "modules/std.sx";
|
||||
#import "modules/std/atomic.sx";
|
||||
|
||||
main :: () {
|
||||
a := Atomic(i64).init(7);
|
||||
print("init: {}\n", a.load());
|
||||
|
||||
a.store(42);
|
||||
print("after store: {}\n", a.load());
|
||||
|
||||
a.store(a.load() + 1);
|
||||
print("incremented: {}\n", a.load());
|
||||
}
|
||||
1
examples/expected/1700-atomics-load-store.exit
Normal file
1
examples/expected/1700-atomics-load-store.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
2
examples/expected/1700-atomics-load-store.stderr
Normal file
2
examples/expected/1700-atomics-load-store.stderr
Normal file
@@ -0,0 +1,2 @@
|
||||
error: atomic load LLVM emission not yet implemented (Stream A, A.0b)
|
||||
error: atomic store LLVM emission not yet implemented (Stream A, A.0b)
|
||||
1
examples/expected/1700-atomics-load-store.stdout
Normal file
1
examples/expected/1700-atomics-load-store.stdout
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user