toolchain: banner purge + WHY-only comment sweep (rule 8)
selfhost/, cmd/, internal/ join the tree-wide sweep: every section banner dies (91 selfhost + the cmd C-style dividers -> 0); narration and stale contracts deleted (pre-#22 bundler notes, retired single-PT_LOAD and no-archive claims, superseded ABI tables); every ref/harec/qbe cite, task cite, encoding/ELF contract, and rule-10 twin pointer kept; lost lifetime/rationale lines restored where the sweep over-cut (elf_globals ownership, kwtab linear-scan). Comment- only proven: all five wwstage tool binaries byte-identical across the sweep; test-commit, test-byteid (161+1399, 0 pinned-divergent), and test-bootstrap (fixed point + 991-995 byte-id) all exit 0. The read-through banked 66 latent-bug leads (checkpoint).
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
// selfhost/cmd/wcc/cgenexpr.ww — split out of cgen.ww.
|
||||
//
|
||||
// cgexpr is a thin dispatcher over n.kind; each non-trivial branch
|
||||
// lives in a per-kind helper (cgstrlit, cgident, cgindex, cgmatch,
|
||||
// cgdot, cgun, cgbin, cgcall, cgassign). Trivial literal loads
|
||||
// (nkind.N_INTLIT, nkind.N_RUNELIT, nkind.N_TRUE/FALSE/NIL, nkind.N_CAST) stay inline.
|
||||
//
|
||||
// The remainder of cgen lives in cgen.ww (foundation: types, emit
|
||||
// primitives, the collect* tables, FFI/module maps) and cgenstmt.ww
|
||||
// (cgstmt).
|
||||
@@ -683,9 +678,6 @@ fn cgtryunw(c: *cgen, n: *syntax.node) void = {
|
||||
};
|
||||
|
||||
fn cgtypetest(c: *cgen, n: *syntax.node) void = {
|
||||
// `e is T` — load the lhs's tag, compare against T's variant
|
||||
// index, set AX = (tag == idx). Result type is bool.
|
||||
//
|
||||
// Slot resolution is inlined (rather than factored into a helper
|
||||
// with output parameters): wwstage cgen has a trap with i32
|
||||
// stored via *i32 in this context — direct assignment of the
|
||||
@@ -1077,9 +1069,6 @@ fn cgcast(c: *cgen, n: *syntax.node) void = {
|
||||
else { if (lk == syntax.nkind.N_TENUM) { leaf_tn = leaf_tn.lhs; }
|
||||
else { if (lk == syntax.nkind.N_TNAME) {
|
||||
let lnm: str = leaf_tn.str;
|
||||
// This is an alias chase loop
|
||||
// — primsize is the leaf-primitive break test the loop
|
||||
// wraps (aliaslookup advances the cursor on a miss).
|
||||
if (primsize(lnm) > 0) { break; };
|
||||
let lal: *syntax.node = aliaslookup(c, lnm);
|
||||
if (lal == nil) { leaf_tn = nil; }
|
||||
@@ -2062,9 +2051,6 @@ fn cgplaceaddr(c: *cgen, n: *syntax.node, dstreg: str) bool = {
|
||||
};
|
||||
|
||||
fn cgindex(c: *cgen, n: *syntax.node) void = {
|
||||
// Element-size-aware load: u8 → MOVZBQ, i32 → MOVSXD, u32 → MOVL,
|
||||
// str → (ptr, len) into (AX, BX), everything else → MOVQ. Fast
|
||||
// path when the base is a bare ident (mem.ww shape).
|
||||
let base: *syntax.node = n.lhs;
|
||||
let idx: *syntax.node = n.rhs;
|
||||
// Direct non-ident index bases that match none of the typed arms
|
||||
@@ -2512,7 +2498,6 @@ fn cgindex(c: *cgen, n: *syntax.node) void = {
|
||||
emitline("\t(BX), AX\n");
|
||||
return;
|
||||
};
|
||||
// Generic fallback when base isn't a plain ident.
|
||||
// #135: N_DOT base on `[N]T` field needs the field's ADDRESS,
|
||||
// not its value. cgexpr would auto-deref + load the 8-byte value
|
||||
// as if it were a pointer. dotbaseaddr emits the address inline.
|
||||
@@ -2866,7 +2851,6 @@ fn cgslice(c: *cgen, n: *syntax.node) void = {
|
||||
let es60: *syntax.tinfo = tichase(bu60.sub);
|
||||
if (es60 != nil) { esz = es60.size: i32; };
|
||||
};
|
||||
// base address
|
||||
if (baselocal != nil) {
|
||||
let tn: *syntax.node = baselocal.tnode;
|
||||
let isarray: bool = false;
|
||||
@@ -2936,11 +2920,9 @@ fn cgslice(c: *cgen, n: *syntax.node) void = {
|
||||
};
|
||||
};};};};
|
||||
emitline("\tPUSHQ\tAX\n");
|
||||
// lo (default 0)
|
||||
if (lo != nil) { cgexpr(c, lo); }
|
||||
else { emitline("\tMOVQ\t$0, AX\n"); };
|
||||
emitline("\tPUSHQ\tAX\n");
|
||||
// hi (default base length)
|
||||
if (hi != nil) {
|
||||
cgexpr(c, hi);
|
||||
} else { if (baselocal != nil) {
|
||||
@@ -3140,8 +3122,6 @@ fn matcharmwant(c: *cgen, scrutt: *syntax.node, pat: *syntax.node) i32 = {
|
||||
};
|
||||
|
||||
fn cgmatch(c: *cgen, n: *syntax.node) void = {
|
||||
// match (e) { case let v: T => stmt; ... }
|
||||
//
|
||||
// Read the tagged-union slot and dispatch by tag. Slot
|
||||
// layout: [+0]=tag, [+8]=value0, [+16]=value1. Bindings
|
||||
// (`case let v: T =>`) get a fresh local slot loaded from
|
||||
@@ -3415,7 +3395,6 @@ fn cgmatch(c: *cgen, n: *syntax.node) void = {
|
||||
};
|
||||
};
|
||||
};
|
||||
// Bind `let v: T` from the slot, if requested.
|
||||
let bn: str = cs.str;
|
||||
if (bn.len > 0) {
|
||||
if (pat != nil) {
|
||||
@@ -3468,7 +3447,6 @@ fn cgmatch(c: *cgen, n: *syntax.node) void = {
|
||||
};
|
||||
};
|
||||
};
|
||||
// Body. Match arms are statements; we cgstmt them.
|
||||
if (cs.body != nil) { cgstmt(c, cs.body); };
|
||||
// Restore the locals head — pop everything the arm pushed
|
||||
// so post-match code resolves names to their original (outer)
|
||||
@@ -5299,10 +5277,6 @@ fn cgdot(c: *cgen, n: *syntax.node) void = {
|
||||
};
|
||||
|
||||
fn cgun(c: *cgen, n: *syntax.node) void = {
|
||||
// Match C cgen ordering: evaluate operand first (load into AX),
|
||||
// then apply the unary op. AMP / STAR override AX with the
|
||||
// address / deref. The wasted load before AMP keeps our asm
|
||||
// byte-identical to the C version.
|
||||
let fk: i32 = 0;
|
||||
if (n.lhs != nil) {
|
||||
let lt: *syntax.tinfo = n.lhs.type_: *syntax.tinfo;
|
||||
|
||||
Reference in New Issue
Block a user