atomics A.0.5: full ordering surface (comptime $o: Ordering)

Migrate Atomic methods from seq_cst-only to the explicit ordering surface now
that comptime value params work on generic-struct methods (workers 3c4305f /
d7a6857 / d95ba0a):

- atomic.sx: load/store take a comptime $o: Ordering (explicit, Rust-style; no
  default, matching design 4.6). a.load(.acquire) -> 'load atomic .. acquire'.
- call.zig: atomicOrderingFromNode resolves a comptime-bound ordering identifier
  via comptimeIntNamed (+ atomicOrderingFromTag); documents the sx-Ordering <->
  IR-AtomicOrdering declaration-order invariant. The per-op validity guard fires
  through the method path (a.load(.release) is a compile error).
- 1700 migrated to explicit orderings (output unchanged 7/42/43).

Suite green (715/0).
This commit is contained in:
agra
2026-06-20 10:04:39 +03:00
parent d95ba0a937
commit acf31839ea
4 changed files with 72 additions and 31 deletions

View File

@@ -1,17 +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`.
// Atomic($T) load/store with explicit memory orderings, single-thread.
// Stream A (atomics) A.0 + A.0.5 — the ordering is a comptime `$o: Ordering`
// param (explicit, Rust-style): a.load(.acquire) emits `load atomic … acquire`.
// An invalid combination (a.load(.release)) is a compile error (see 1131).
#import "modules/std.sx";
#import "modules/std/atomic.sx";
main :: () {
a := Atomic(i64).init(7);
print("init: {}\n", a.load());
print("init: {}\n", a.load(.seq_cst));
a.store(42);
print("after store: {}\n", a.load());
a.store(42, .release);
print("after store: {}\n", a.load(.acquire));
a.store(a.load() + 1);
print("incremented: {}\n", a.load());
a.store(a.load(.relaxed) + 1, .seq_cst);
print("incremented: {}\n", a.load(.seq_cst));
}