Compilers — Build a Small Language from Start to Finish
작은 언어 '미니' 를 렉서·파서·의미 분석·트리 인터프리터·바이트코드 VM·최적화·x86-64 코드 생성·레지스터 할당과 GC 까지 직접 만들고, 모듈마다 만든 것이 다음 모듈의 입력이 됩니다. 채점기는 적어 낸 답이 아니라 여러분의 구현을 무작위 프로그램으로 돌려 기준 구현과 대조하고, 코드 생성은 실제로 구워 실행합니다. 끝에서는 gcc·clang 의 -O0/-O2 어셈블리와 LLVM IR 을 같은 눈으로 읽어, 실무 컴파일러가 무엇을 하는지 숫자로 확인합니다.
고급 · 레슨 30 · 실습 10
커리큘럼
What a Compiler Does — Translate First, or Run Right Away
The Lexer — Characters to Tokens, Positions All the Way
The Parser — Recursive Descent, Pratt, and Error Recovery
Semantic Analysis — Scopes, Name Resolution, and Types Where Known
A Tree-Walking Interpreter — Environments and Closures
Bytecode and a Stack VM — Constant Pool, Slots, Jump Patching
Intermediate Representation and Optimization — Constant Folding, CFGs, Dominators and SSA
x86-64 Code Generation — Calling Convention and Stack Frames
Register Allocation and Garbage Collection — Linear Scan and Mark-Sweep
Reading Real Compilers — Counting gcc and clang Output
참고 문서
- GCC — Options That Control Optimization
- GNU as (Using as) — AT&T 문법
- System V AMD64 ABI (x86-64 psABI)
- LLVM Language Reference Manual
- Python — dis (바이트코드 디스어셈블러)
- Pratt — Top Down Operator Precedence (1973)
- Cytron et al. — Efficiently Computing SSA Form (1991)
- Poletto & Sarkar — Linear Scan Register Allocation (1999)