selfhost: cgident read path for top-level lets
Mirror the C cgen's N_IDENT load fallback. Reads of a top-level scalar `let` now emit `MOVQ name(SB), AX` (RIP-relative) instead of silently dropping. Truly undefined names still fall through to the silent return, matching the pre-existing defensive behaviour; the C side's broader unconditional fallback is intentionally not mirrored here so typos surface as nothing-emitted rather than a link-time stub.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user