code-yeongyu / code-yeongyu/c11-compiler-zig-omo

[Sisyphus] phase-2 / zcc / Wave 9 — Register allocation + DWARF

Open
#26 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Scope
Implement register allocation and DWARF v5 debug info generation for both x86_64 and ARM64.

## Deliverables
- `phase2/zcc/src/regalloc.zig` — register allocator (graph-coloring or linear-scan) targeting x86_64 and ARM64 register files.
- `phase2/zcc/src/dwarf.zig` — DWARF v5 emitter: `.debug_info`, `.debug_line`, `.debug_frame`, `.debug_abbrev`.
- `phase2/zcc/src/dwarf_x86_64.zig` / `dwarf_arm64.zig` — arch-specific unwind info (CFI).

## Register Allocation
- Must handle both GPR and FP/SIMD register classes.
- Spilling to stack when out of registers.
- Preserve ABI callee-saved registers.

## DWARF Requirements
- `.debug_line`: line-number program mapping machine code addresses to source lines.
- `.debug_info`: compilation unit DIE, subprogram DIEs, type DIEs for basic C types.
- `.debug_frame` / `.eh_frame`: unwind tables for stack traces.

## Success Criteria
1. `gdb` (Linux) or `lldb` (macOS) can step through every line of every `phase1/c11-ref/*_test.c` file in the compiled binary.
2. `addr2line` (or macOS equivalent `atos`) round-trips: for every function, `addr2line` on its address returns the correct file:line.
3. Stack backtraces in `gdb`/`lldb` show correct function names and source lines.

## Dependencies on Prior Waves
- **Wave 0–8** — both codegens must emit machine IR before regalloc and DWARF can be applied.

## Suggested Role Assignment
- `regalloc-engineer` (register allocation)
- `dwarf-engineer` (DWARF generation) — can work in parallel once codegen interface is stable.

## Test Corpus Expectations
- `gdb` scripted step-through on `phase1/c11-ref/*_test.c` compiled with `-g`.
- `addr2line` / `atos` round-trip validation.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the machine-IR interface produced by Waves 0–8, then inspect phase2/zcc/src/regalloc.zig, dwarf.zig, dwarf_x86_64.zig, and dwarf_arm64.zig. Use the phase1/c11-ref/*_test.c corpus with -g, and validate completion through scripted gdb/lldb stepping, addr2line or atos round-trips, and correct stack backtraces.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, zig
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.