Epic: #113 · Milestone: MC1 — Toolchain: aarch64
Why
home build <file> --kernel lowers through packages/codegen/src/home_kernel_codegen.zig (4,204 lines) which emits x86-64 assembly only (351 register references, zero arm64). aarch64_native_codegen.zig (1,461 lines) is a userspace path that supports ≤8 i64 params, structs, let/if/while, literals, direct calls, fixed i64 arrays, match on literals — and returns error.NotImplemented for pointers, methods, struct args/returns, slices. Nothing in HomeOS compiles for ARM today. This is the whole critical path of the media center; per #44 we extend the direct emitter.
The ladder (each rung is a kernel that boots in qemu-system-aarch64 -M virt and prints on the PL011)
Order matters; each rung depends on the previous, exactly like Phase 0.5:
putcvia inlinestrto the UART — integer literals, local calls, simple-form inline asm (AAPCS64 prologue/epilogue,x29/x30, 16-byte stack alignment)- string literals in
.rodata+adrp/addaddressing - arrays and indexing (
ldr/strwith scaled offsets) - structs, field access, struct-by-pointer args
while/forover data;switch- function pointers, indirect calls (
blr) - imports across files; global
varin.bss/.data const/comptimeevaluation parity with x86 path- volatile MMIO loads/stores + barriers (#53)
- 64-bit shifts/bit ops,
@truncate/@bitCast, packed structs - exceptions: vector-table alignment (
.align 11),eret,msr/mrsinline asm forms used byarch/arm64/exceptions.home - NEON intrinsics subset for blits/decoders (
ld1/st1,add/sub/mulon.16b/.8h/.4s) — needed by MC4/MC6, may land last
Tasks
- In
home-lang/home:packages/codegen/src/home_kernel_codegen_aarch64.zig(or an arch-abstracted lowering inside the existing file) + tests underpackages/codegen/tests/; reusearm64.zigas the assembler. - Register allocation and calling convention per AAPCS64; caller-saved
x0–x17, callee-savedx19–x28;x18reserved. - Each rung = a file
kernel/src/arm64_poc/step-NN.home+ expected serial output, run by #55. - Extend
scripts/mvk-compiles.shwith--arch=aarch64reporting per-file failures naming the unlowered construct (diagnostics are a deliverable).
Acceptance
mvk-compiles-aarch64 ratchet reaches 70/70 Appendix-A files (same set as x86) and the rung-12 kernel boots in QEMU virt. Revisit trigger from the ADR: < 35/70 after the planned effort → reconsider LLVM.
Size: XL (the largest single item in the plan) · Depends on: #44 · Blocks: #57, #60, everything in MC2+