-
Notifications
You must be signed in to change notification settings - Fork 0
Compiler Self Hosting
james-yusuke edited this page Jul 16, 2026
·
1 revision
YCPLは完全セルフホストの固定点へ到達しています。
ycc-bootstrap (C++ seed/reference)
-> ycc-stage1
-> ycc-stage2
-> ycc-stage3
-> ycc
-
ProgramAstとAstArenaが唯一のcanonical AST。 - file IDはproject-relative pathの安定順。
- cross-file参照はfile/node IDとresolved symbol ID。
- AST、project file、symbol、import、localは
Vec<T>で保持。 -
compiler/ycplに直接のstd/memimportやmem.*callはない。 - parser、resolver/type checker、LLVM backendは同じ実ASTを利用。
- named typeとstructを宣言する。
- functionとexternを宣言する。
- function bodyをresolved ASTからlowerする。
- LLVM verifierでmoduleを検査する。
primitive、pointer、slice、Vec、array、struct、enum、alias、MapのABIと、 call、UFCS、short-circuit、bounds check、loop、switch、defer/scope unwind、 cast、variadic、managed ownership transitionを扱います。
source内容やfixture名によるIR選択、embedded stage IR、巨大なcompiler-smoke IRは 使いません。
stage2とstage3はそれぞれcompiler自身のIRを生成します。両IRを同じLLVM 22の
llvm-as -> llvm-disへ通し、ModuleIDとsource filenameだけを安定化して
完全一致を比較します。target triple、data layout、symbol、instructionは
比較対象から除外しません。
完全セルフホストは、すべてをYCPLで再実装したという意味ではありません。 次は外部基盤として維持します。
- LLVM 22
llcclang- managed C runtime
- C/POSIX host API
C++ compilerはseed/referenceとして残りますが、標準yccの通常処理から呼ばれません。