diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index 30bac62c..76b4daa2 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -6128,6 +6128,17 @@ fn cgident(c: *cgen, n: *node) void = { emitline("(SB), AX\n"); return; }; + // Top-level mutable `let` — RIP-relative load from its DATAW + // slot. Mirrors C cgen's catch-all `MOVQ masym(s), AX`. Names + // that aren't lets either (typos, never-defined) flow through + // here too in C; the divergence today is bounded to scalar lets, + // which is what `isletvar` gates on. + if (isletvar(c, nm)) { + emitline("\tMOVQ\t"); + emitsymname(c, nm); + emitline("(SB), AX\n"); + return; + }; return; }; diff --git a/selfhost/cmd/wcc/cgenexpr.ww b/selfhost/cmd/wcc/cgenexpr.ww index 62ece917..b1e03a9b 100644 --- a/selfhost/cmd/wcc/cgenexpr.ww +++ b/selfhost/cmd/wcc/cgenexpr.ww @@ -400,6 +400,17 @@ fn cgident(c: *cgen, n: *node) void = { emitline("(SB), AX\n"); return; }; + // Top-level mutable `let` — RIP-relative load from its DATAW + // slot. Mirrors C cgen's catch-all `MOVQ masym(s), AX`. Names + // that aren't lets either (typos, never-defined) flow through + // here too in C; the divergence today is bounded to scalar lets, + // which is what `isletvar` gates on. + if (isletvar(c, nm)) { + emitline("\tMOVQ\t"); + emitsymname(c, nm); + emitline("(SB), AX\n"); + return; + }; return; }; diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index f823a591..218b5589 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -6128,6 +6128,17 @@ fn cgident(c: *cgen, n: *node) void = { emitline("(SB), AX\n"); return; }; + // Top-level mutable `let` — RIP-relative load from its DATAW + // slot. Mirrors C cgen's catch-all `MOVQ masym(s), AX`. Names + // that aren't lets either (typos, never-defined) flow through + // here too in C; the divergence today is bounded to scalar lets, + // which is what `isletvar` gates on. + if (isletvar(c, nm)) { + emitline("\tMOVQ\t"); + emitsymname(c, nm); + emitline("(SB), AX\n"); + return; + }; return; };