diff --git a/Makefile b/Makefile index 66b3b131..30de5a82 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,7 @@ WW_OBJ = $(WW_SRC:cmd/ww/%.c=$(OBJ)/ww/%.o) WD_SRC = cmd/wwdump/main.c WD_OBJ = $(WD_SRC:cmd/wwdump/%.c=$(OBJ)/wwdump/%.o) -W6C_SRC = cmd/w6c/main.c cmd/w6c/cgen.c cmd/w6c/txt.c cmd/w6c/swt.c \ - cmd/w6c/peep.c cmd/w6c/reg.c cmd/w6c/wwi.c +W6C_SRC = cmd/w6c/main.c cmd/w6c/cgen.c cmd/w6c/txt.c cmd/w6c/wwi.c W6C_OBJ = $(W6C_SRC:cmd/w6c/%.c=$(OBJ)/w6c/%.o) W6A_SRC = cmd/w6a/main.c cmd/w6a/lex.c cmd/w6a/parse.c cmd/w6a/asm.c cmd/w6a/obj.c diff --git a/cmd/w6c/CLAUDE.md b/cmd/w6c/CLAUDE.md index fa712cd5..adfdfcaf 100644 --- a/cmd/w6c/CLAUDE.md +++ b/cmd/w6c/CLAUDE.md @@ -2,5 +2,5 @@ w6c — amd64 compiler. Reads `.ww`, writes Plan 9 amd64 assembly (`.s`). - Plan 9 C style: tabs, K&R, short names. Mirror `ref/plan9front/sys/src/cmd/8c/` and `ref/plan9front/sys/src/cmd/cc/`. Do not invent new data shapes — reuse `Prog`/`Adr`/`Node`/`Sym`/`Type` conventions. - Frontend (lex, parse, check) lives in `../wcc/` and links as `libwcc.a`. This directory owns codegen only. -- `gc.h` is the per-target header (Plan 9 cc convention). `cgen.c` walks the AST into `Prog` list; `txt.c` prints it. `peep.c` is peephole. `reg.c` is the register allocator. `swt.c` is switch lowering. +- `gc.h` is the per-target header (Plan 9 cc convention). `cgen.c` performs the current AST lowering into a `Prog` list, including switch lowering; `txt.c` emits the assembler text. There is no peephole or register-allocation pass yet. - The text output must be readable by `w6a` (the amd64 assembler under `../w6a/`). When in doubt about syntax, run `w6a` on the output. diff --git a/cmd/w6c/cgen.c b/cmd/w6c/cgen.c index 02752dfc..a4cb5259 100644 --- a/cmd/w6c/cgen.c +++ b/cmd/w6c/cgen.c @@ -17683,6 +17683,3 @@ cg_file(Cg *c, FILE *out, Node *file) emit_defs(c, out, file); emit_lets(c, out, file); } - -void peephole(Cg *c) { (void)c; } -void regalloc_init(Cg *c) { (void)c; } diff --git a/cmd/w6c/gc.h b/cmd/w6c/gc.h index 595d50fe..239ee783 100644 --- a/cmd/w6c/gc.h +++ b/cmd/w6c/gc.h @@ -73,8 +73,4 @@ void txt_emit(FILE*, Prog *head); /* wwi.c — non-zero return: check_exported_type rejected a dangling export. */ int wwi_emit(Checker *c, FILE *of, Node *file); -/* swt.c, peep.c, reg.c — placeholders for now */ -void peephole(Cg*); -void regalloc_init(Cg*); - #endif diff --git a/cmd/w6c/peep.c b/cmd/w6c/peep.c deleted file mode 100644 index 9b74c2cb..00000000 --- a/cmd/w6c/peep.c +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Currently a no-op; reserved for the kind of cleanup Plan 9 6c does - * (folding adjacent moves, removing redundant compares). Wire in - * `peephole(c)` from cgen.c after the main walk. - */ -#include "gc.h" - -void peep_run(Cg *c) { (void)c; } diff --git a/cmd/w6c/reg.c b/cmd/w6c/reg.c deleted file mode 100644 index 340c6b81..00000000 --- a/cmd/w6c/reg.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * The current cgen pins everything to AX with BX as a scratch - * top-of-stack — no real allocation. This file is the seam where a - * linear-scan or graph-colouring pass would land later; today it's - * empty. - */ -#include "gc.h" - -void reg_run(Cg *c) { (void)c; } diff --git a/cmd/w6c/swt.c b/cmd/w6c/swt.c deleted file mode 100644 index a4347072..00000000 --- a/cmd/w6c/swt.c +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Stub for now: cgen falls through to a no-op for N_SWITCH. When we - * add a real lowering, it will live here, mirroring Plan 9 6c's - * pswt.c. - */ -#include "gc.h" - -void swt_lower(Cg *c, Node *n) { (void)c; (void)n; } diff --git a/cmd/w6c/txt.c b/cmd/w6c/txt.c index 58d13e66..4a2673a0 100644 --- a/cmd/w6c/txt.c +++ b/cmd/w6c/txt.c @@ -1,6 +1,6 @@ /* * Format we emit (and that w6a expects): - * TEXT name + * TEXT name,$framesize * MOVQ $1, AX * MOVQ AX, name(SB) ; extern symbol * MOVQ off(BP), AX ; local