ww: rename toolchain to w-prefix + hare-style build/run/test driver
Plan 9-style w-prefix on the per-arch tools, disambiguating from the
real Plan 9 6c/6a/6l in ref/plan9front/:
cmd/wwc/ → cmd/wcc/ libwwc.a → libwcc.a
cmd/6{c,a,l} → cmd/w6{c,a,l} binary names too
test/wwc/ → test/wcc/ 6 test files w/ w6 prefix
selfhost/cmd mirror in lockstep
bootstrap/amd64/{w6c,w6a,w6l} snapshot binaries (gitignored)
WW_6{C,A,L} → WW_W6{C,A,L} env-var overrides
Plan 9 source-tree refs ("Plan 9 6c shape", ref/plan9front/, etc.)
preserved. Hare-style driver, both C and ww sides:
ww test [path] discover *_test.ww in a directory module, run
each; single-file mode for `ww test foo.ww`
Module-by-name `ww build foo` resolves to foo.ww or foo/foo.ww
via search path (cwd : -I dirs : $WW_LIB)
Default-to-cwd `ww build` / `ww test` build the cwd module
Run pass-through `ww run path arg1 arg2` reaches the program
lib/os: getcwd (79) and getdents64 (217) syscalls power `.` resolution
and directory enumeration on the ww side.
Makefile: wwstage tool deps now include lib/os/os.ww (+ lib/strconv
for wwdump_ww) so lib/* edits force their rebuild instead of leaving
stale binaries — surfaced when test 995 first failed against a stale
w6c_ww built before the lib/os additions.
Test 993 byte-identical parity gate (C-side ww vs ww-side ww_ww on a
build corpus) stays green; all 19 tests pass.
This commit is contained in:
107
cmd/w6a/a.h
Normal file
107
cmd/w6a/a.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* a.h — w6a-private header. Modelled on Plan 9 cmd/6a/a.h, trimmed
|
||||
* to the instruction subset that w6c emits.
|
||||
*
|
||||
* w6a is line-oriented and has no preprocessor: each non-blank, non-
|
||||
* label line is one instruction. We read the whole file into a list
|
||||
* of `Aprog`s, then encode and emit ELF64.
|
||||
*/
|
||||
#ifndef SIX_A_H
|
||||
#define SIX_A_H
|
||||
|
||||
#include "6.out.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef int8_t i8;
|
||||
typedef int16_t i16;
|
||||
typedef int32_t i32;
|
||||
typedef int64_t i64;
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
|
||||
typedef struct Aoperand Aoperand;
|
||||
typedef struct Aprog Aprog;
|
||||
typedef struct Asym Asym;
|
||||
typedef struct Areloc Areloc;
|
||||
typedef struct Asm Asm;
|
||||
|
||||
struct Aoperand {
|
||||
int type; /* D_NONE, D_AX..D_R15, D_CONST, D_INDIR, D_EXTERN, D_BRANCH */
|
||||
int reg; /* base register for D_INDIR */
|
||||
i64 offset; /* immediate or displacement */
|
||||
const char *sym;
|
||||
};
|
||||
|
||||
struct Aprog {
|
||||
int as; /* opcode (A_*) */
|
||||
Aoperand from;
|
||||
Aoperand to;
|
||||
int line;
|
||||
const char *label; /* label preceding this prog, if any */
|
||||
Aprog *link;
|
||||
/* for A_DATA: raw payload bytes interned by the parser */
|
||||
u8 *bytes;
|
||||
u64 nbytes;
|
||||
};
|
||||
|
||||
struct Asym {
|
||||
const char *name;
|
||||
int defined; /* 1 if we own its address */
|
||||
int is_text; /* if 1, address is in .text */
|
||||
int is_global; /* exported (TEXT) */
|
||||
u64 addr; /* offset within section if defined */
|
||||
int idx; /* ELF symtab index, filled at emit time */
|
||||
Asym *next;
|
||||
};
|
||||
|
||||
struct Areloc {
|
||||
u64 off; /* offset within .text where relocation lands */
|
||||
int kind; /* R_X86_64_PLT32 (4), R_X86_64_PC32 (2) */
|
||||
Asym *sym;
|
||||
i64 addend;
|
||||
Areloc *next;
|
||||
};
|
||||
|
||||
struct Asm {
|
||||
/* parser state */
|
||||
const char *file;
|
||||
const char *src;
|
||||
u64 srclen;
|
||||
u64 pos;
|
||||
int line;
|
||||
|
||||
/* program list */
|
||||
Aprog *head, *tail;
|
||||
|
||||
/* output text section */
|
||||
u8 *text;
|
||||
u64 textcap, textlen;
|
||||
|
||||
/* symbols */
|
||||
Asym *syms;
|
||||
Areloc *relocs;
|
||||
|
||||
int errs;
|
||||
};
|
||||
|
||||
/* lex.c / parse.c */
|
||||
void a_init(Asm*, const char *file, const char *src, u64 len);
|
||||
int a_parse(Asm*);
|
||||
|
||||
/* asm.c */
|
||||
int a_encode(Asm*);
|
||||
|
||||
/* obj.c */
|
||||
int a_emit_elf(Asm*, FILE *out);
|
||||
|
||||
/* helpers */
|
||||
Asym *a_intern(Asm*, const char *name);
|
||||
void a_emit_byte(Asm*, u8);
|
||||
void a_emit_u32(Asm*, u32);
|
||||
void a_addreloc(Asm*, u64 off, int kind, Asym *s, i64 add);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user