ReviewOS

home-lang/home-os

ADR-MC2: aarch64 kernel codegen strategy — extend the direct emitter (mirror of the x86-64 kernel path), LLVM only as a revisit trigger

#44
Open chris opened this 9 days ago ·
9 days ago

Epic: #113 · Milestone: MC0 — Product & decisions

Why

Phase 7b is gated on compiler milestone A6 (arm64 backend), which MASTER_PLAN lists as a single bullet with no breakdown. Measured today in ~/Code/Home/lang:

PathLinesarm64 refs
packages/codegen/src/home_kernel_codegen.zig (the --kernel path that boots HomeOS on x86)4,2040
packages/codegen/src/native_codegen.zig (x86-64 userspace)10,854—
packages/codegen/src/aarch64_native_codegen.zig (userspace, "Path B-lite")1,461toy subset: no pointers, methods, slices, struct args
packages/codegen/src/arm64.zig (assembler)518—
packages/codegen/src/llvm_codegen.zig / llvm_backend.zig622 / 715used by the JS/TS launcher only

Backend selection is by host arch (src/main.zig ~L3649), not by a target flag. There is no cross-compilation from a macOS host to aarch64-freestanding.

Options

  1. Extend the direct emitter: add an aarch64 lowering to the kernel codegen, ratcheted file-by-file exactly like mvk-compiles (proven approach; keeps the "one toolchain, no LLVM" story; ~4K lines of x86 lowering to mirror).
  2. Finish the LLVM backend for Home AST and let it cover all non-x86 targets (broader long-term, but the Home→LLVM lowering is "in progress", pulls a 100 MB dependency into the kernel build, and hides the codegen from the ratchet culture the project relies on).
  3. Hybrid: direct emitter for the kernel subset now, LLVM later for userspace optimisation.

Option 1. Rationale: the x86 kernel path reached 70/70 files by exactly this method; an aarch64 mirror can reuse the same IR/lowering structure and the same ratchet scripts; the media-center CPU budget depends on NEON, which the direct emitter can expose as intrinsics without an LLVM detour. Revisit trigger: if the aarch64 ratchet is below 35/70 Appendix-A files after the planned effort in #51, switch to option 2.

Tasks

  • docs/adr/ADR-MC2-aarch64-codegen.md with the table above, the option analysis, and the revisit trigger.
  • Mirror the ADR summary into home-lang/home#5 as a comment so compiler contributors see the plan.
  • Update MASTER_PLAN A6 to point at #51, #52, #53.

Size: S · Depends on: — · Blocks: #51

Sign in to comment on this issue.