fibers: rename ABI variant .pure -> .naked

"pure" universally means side-effect-free (GCC __attribute__((pure)),
FP purity, D's pure) — the opposite of a register-clobbering context
switch. The concept is "naked": no compiler-generated prologue/epilogue,
body is raw asm that emits its own ret. That is the established term
everywhere (LLVM's naked function attribute — which we literally emit —
plus Zig callconv(.naked), Rust #[naked], GCC/Clang __attribute__
((naked))). Rename the keyword + everything keyed off it so concept,
surface, field, and the emitted LLVM attribute all agree.

- ast.zig: ABI enum variant pure -> naked (+ doc).
- parser: accept abi(.naked); error text updated.
- IR Function.is_pure -> is_naked; type_resolver/decl/generic/pack/
  emit_llvm references updated; diagnostics say abi(.naked).
- examples 1800-1803 renamed *-pure-* -> *-naked-* (source + expected/
  snapshots; .ir/.exit/.stdout/.stderr are byte-identical — the emitted
  IR is unchanged, only the keyword spelling differs).
- docs (PLAN-FIBERS, CHECKPOINT-FIBERS, PLAN-POST-METATYPE, the design
  roadmap, the compiler-API checkpoint/design) updated; the naming
  rationale now records why .naked over .pure.

No semantic change — pure cosmetics. Suite green (725/0).
This commit is contained in:
agra
2026-06-20 17:01:09 +03:00
parent b631590574
commit a7fe165684
40 changed files with 175 additions and 171 deletions

View File

@@ -115,7 +115,7 @@ pub fn monomorphizeFunction(self: *Lowering, fd: *const ast.FnDecl, mangled_name
const func_id = self.builder.beginFunction(name_id, params.items, ret_ty);
_ = func_id;
self.builder.currentFunc().has_implicit_ctx = wants_ctx;
self.builder.currentFunc().is_pure = (fd.abi == .pure);
self.builder.currentFunc().is_naked = (fd.abi == .naked);
// Create entry block
const entry_name = self.module.types.internString("entry");
@@ -128,10 +128,10 @@ pub fn monomorphizeFunction(self: *Lowering, fd: *const ast.FnDecl, mangled_name
defer scope.deinit();
self.scope = &scope;
// `abi(.pure)` (naked): no frame — params arrive in registers, read by the
// `abi(.naked)` (naked): no frame — params arrive in registers, read by the
// asm body, never spilled to allocas (the LLVM verifier rejects a naked
// function that uses its arguments). Mirrors the decl-path guard.
if (fd.abi != .pure) {
if (fd.abi != .naked) {
var param_idx: u32 = if (wants_ctx) 1 else 0;
for (fd.params) |p| {
if (isTypeParamDecl(&p, fd.type_params)) continue;
@@ -155,10 +155,10 @@ pub fn monomorphizeFunction(self: *Lowering, fd: *const ast.FnDecl, mangled_name
self.ensureTerminator(ret_ty);
}
self.builder.finalize();
} else if (self.builder.currentFunc().is_pure) {
// `abi(.pure)`: asm-only body that rets itself — no sx value return.
} else if (self.builder.currentFunc().is_naked) {
// `abi(.naked)`: asm-only body that rets itself — no sx value return.
// Lower the statements + cap with `unreachable` (mirrors the decl path).
// emit_llvm bails on `is_pure` until B1.0b implements `naked` emission.
// emit_llvm bails on `is_naked` until B1.0b implements `naked` emission.
self.lowerBlock(fd.body);
if (!self.currentBlockHasTerminator()) self.builder.emitUnreachable();
self.builder.finalize();