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,13 +1,5 @@
|
||||
// selfhost/cmd/w6a/asm.ww — port of cmd/w6a/asm.c.
|
||||
//
|
||||
// Encode the parsed aprog list into amd64 machine bytes, appending to
|
||||
// asm_.text. Relocations for CALL/branch targets that resolve to
|
||||
// externals are queued in asm_.relocs.
|
||||
//
|
||||
// Encoding subset matches what w6c emits — see cmd/w6a/asm.c for the
|
||||
// authoritative list. Helpers (rcode/rhi/modrm/emitrex etc.) are
|
||||
// fully ported; encode itself is still a stub pending the full
|
||||
// switch over A_*.
|
||||
// Port of cmd/w6a/asm.c. Encoding subset matches what w6c emits — see
|
||||
// cmd/w6a/asm.c for the authoritative list.
|
||||
|
||||
package w6a;
|
||||
|
||||
@@ -16,8 +8,6 @@ import rt;
|
||||
import opcodes;
|
||||
import strings;
|
||||
|
||||
// ---- text buffer growth ------------------------------------------------
|
||||
|
||||
export fn emitbyte(a: *asm_, b: u8) void = {
|
||||
if (a.textlen + 1u64 > a.textcap) {
|
||||
let nc: u64 = a.textcap;
|
||||
@@ -45,16 +35,14 @@ export fn addreloc(a: *asm_, off: u64, kind: i32, s: *asym, add: i64) void = {
|
||||
a.relocs = r;
|
||||
};
|
||||
|
||||
// Record a relocation that lives in the .data section. Used by
|
||||
// DATAR to patch a 64-bit slot with a symbol's runtime VA. obj.ww
|
||||
// separates these into .rela.data when emitting the .o.
|
||||
// DATAR patches a 64-bit .data slot with a symbol's runtime VA;
|
||||
// obj.ww separates section=1 relocs into .rela.data when emitting
|
||||
// the .o.
|
||||
export fn addrelocdata(a: *asm_, off: u64, kind: i32, s: *asym, add: i64) void = {
|
||||
let r: *areloc = alloc(areloc { off = off, section = 1, kind = kind, asy = s, addend = add, rnext = a.relocs })!;
|
||||
a.relocs = r;
|
||||
};
|
||||
|
||||
// Append one byte to the writable .data buffer. Mirrors emitbyte
|
||||
// but targets a.data instead of a.text.
|
||||
export fn emitdatabyte(a: *asm_, b: u8) void = {
|
||||
if (a.datalen + 1u64 > a.datacap) {
|
||||
let nc: u64 = a.datacap;
|
||||
@@ -70,8 +58,6 @@ export fn emitdatabyte(a: *asm_, b: u8) void = {
|
||||
a.datalen += 1u64;
|
||||
};
|
||||
|
||||
// ---- register codes ----------------------------------------------------
|
||||
|
||||
// Low 3 bits of register encoding.
|
||||
fn rcode(r: i32) i32 = {
|
||||
if (r == D_AX) { return 0; }; if (r == D_CX) { return 1; };
|
||||
@@ -105,7 +91,6 @@ fn isxmm(r: i32) bool = {
|
||||
return false;
|
||||
};
|
||||
|
||||
// ModR/M byte builder.
|
||||
fn modrmbyte(mod: i32, reg: i32, rm: i32) u8 = {
|
||||
return (((mod & 3) << 6) | ((reg & 7) << 3) | (rm & 7)): u8;
|
||||
};
|
||||
@@ -210,8 +195,6 @@ fn sserrw(a: *asm_, prefix: u8, op2: u8, regop: i32, rmop: i32) void = {
|
||||
emitbyte(a, modrmbyte(3, rcode(regop), rcode(rmop)));
|
||||
};
|
||||
|
||||
// ---- label resolution / fixups ----------------------------------------
|
||||
|
||||
fn resolvelabel(a: *asm_, name: str) u64 = {
|
||||
let s: *asym = a.syms;
|
||||
for (s != nil) {
|
||||
@@ -230,8 +213,6 @@ fn labeldefined(a: *asm_, name: str) bool = {
|
||||
return false;
|
||||
};
|
||||
|
||||
// ---- fixup helper -----------------------------------------------------
|
||||
|
||||
fn addfixup(a: *asm_, off: u64, label: str) void = {
|
||||
let f: *afixup = alloc(afixup { off = off, label = label, fnext = a.fixups })!;
|
||||
a.fixups = f;
|
||||
@@ -242,15 +223,9 @@ fn isgpr(t: i32) bool = {
|
||||
return false;
|
||||
};
|
||||
|
||||
// `intern` lives in parse.ww — flat-scope concat lets us call it
|
||||
// directly without an @symbol declaration here.
|
||||
|
||||
// ---- encode ----------------------------------------------------------
|
||||
|
||||
export fn encode(a: *asm_) i32 = {
|
||||
let p: *aprog = a.head;
|
||||
for (p != nil) {
|
||||
// Define any pending label at the current PC.
|
||||
if (p.label.len > 0) {
|
||||
let s: *asym = intern(a, p.label);
|
||||
s.defined = 1;
|
||||
@@ -281,10 +256,9 @@ export fn encode(a: *asm_) i32 = {
|
||||
p = p.link; continue;
|
||||
};
|
||||
if (op == A_DATAW) {
|
||||
// Writable variant: bytes go into .data instead of
|
||||
// .text. obj.ww emits the extra section conditionally
|
||||
// on datalen > 0 so .o output stays byte-identical
|
||||
// for inputs that don't use DATAW.
|
||||
// obj.ww emits the .data section conditionally on
|
||||
// datalen > 0 so .o output stays byte-identical for
|
||||
// inputs that don't use DATAW.
|
||||
let s: *asym = intern(a, p.to.asym);
|
||||
s.defined = 1;
|
||||
s.isdata = 1;
|
||||
|
||||
Reference in New Issue
Block a user