Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
コンパイラ基盤を支える言語たち
Search
Arata
April 17, 2026
67
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コンパイラ基盤を支える言語たち
Arata
April 17, 2026
More Decks by Arata
See All by Arata
デコンパイラ研究調査
arata_nvm
1
9
LLVMのDSL”TableGen”向け言語サーバーの開発
arata_nvm
0
22
5分でわかるPage-Fault Weird Machine
arata_nvm
2
320
eBPFを用いたAndroid向けデバッガ「eDBG」のx86_64 Linuxへの移植
arata_nvm
0
21
Pythonのcopy-and-patch JITの実装を読む
arata_nvm
0
140
eBPFを使った動的解析手法
arata_nvm
1
790
カーネルハック実験の振り返り
arata_nvm
1
59
Improving LLVM Backend Development with a New TableGen Language Server
arata_nvm
0
54
コードエディターのシンタックスハイライトの話
arata_nvm
0
240
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
The SEO identity crisis: Don't let AI make you average
varn
0
490
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
How to Talk to Developers About Accessibility
jct
2
240
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
950
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
340
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Writing Fast Ruby
sferik
630
63k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
Transcript
コンパイラ基盤を支える言語たち 2026/04/17 コンパイラのコンパの部分 #02 Arata 1
導入:コンパイラの中で使われているDSL(ドメイン特化言語) コンパイラには DSLで宣言的に記述できると嬉しい 処理がある 命令セット(ISA)の定義 e.g. このCPUは RAX という64bitのレジスタを持つ 命令選択
e.g. 加算は ADD r32, r32 (CPU命令)で実装できる 最適化ルール e.g. x + 0 は x に最適化できる 2
導入:どのように嬉しいか 宣言的に記述できる 再利用できる 静的に検査できる 3
好きなDSL3選 4
1. Go SSA rewrite rules 2015年ごろ開発開始 命令選択や最適化ルールの記述に使われる このルールに基づいてGoのコードが生成される Goのシンプルさとうまくマッチしている コードの例(
LEA a, [c]; ADD a, d => LEA a, [c+d] ) (ADD(Q|L)const [c] (LEA(Q|L) [d] {s} x)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L) [c+d] {s} x) 5
2. Cranelift ISLE 2021年ごろ開発開始 命令選択や最適化ルールの記述に使われる このルールに基づいてRustのコードが生成される ルールの検証に気持ちがある 型検査が実装されている ルール同士の重複があるとエラーになる 書き換え前後で意味が変わらないかSMTソルバーで検査できる
コードの例( ADD x, y => LEA a, [x+y] ) (rule iadd_base_case_32_or_64_lea -5 (lower (has_type (ty_32_or_64 ty) (iadd _ x y))) (x64_lea ty (to_amode_add (mem_flags_trusted) x y (zero_offset)))) 6
3. LLVM TableGen 2002年ごろ開発開始 命令セットの定義や命令選択の記述など、幅広く使われる (基本的に)C++のコードが生成される 制御構文があり一番言語っぽい バックエンド次第でなんでもできる SQLクエリ生成、JSON生成など コードの例(
ADD x, -1 => DEC x ) def : Pat<(add GR32:$src, -1), (!cast<Instruction>(DEC32r#suffix) GR32:$src)>; 7
紹介しきれなかったDSL 命令セットの定義 / 命令選択 GCC Machine Description OpenJDK HotSpot ADL
最適化ルール / 書き換えルール Cranelift Peepmatic MLIR PDLL 命令セットの定義 Ghidra SLEIGH QEMU DecodeTree 8
紹介しきれなかったDSL(続き) VM V8 Torque GraalVM Truffle DSL GraalVM Bytecode DSL
Erlang/OTP BEAM LuaJIT DynASM 9
好きなDSLがあればぜひ教えてください! 10
参考文献 LLVM TableGen https://llvm.org/docs/TableGen/ProgRef.html https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86.td https://github.com/llvm/llvm- project/commit/a6240f6b1a34f9238cbe8bc8c9b6376257236b0a https://github.com/mshockwave/SQLGen Cranelift ISLE
https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/isle/docs/lang uage-reference.md https://cfallin.org/blog/2023/01/20/cranelift-isle/ 11
参考文献 Cranelift Peepmatic https://github.com/bytecodealliance/wasmtime/tree/dba74024aa412f28487137 5db292c1bf9079d769/cranelift/peepmatic MLIR PDLL https://mlir.llvm.org/docs/PDLL/ https://www.jeremykun.com/2024/08/04/mlir-pdll/ GCC
Machine Description https://github.com/gcc-mirror/gcc/blob/master/gcc/config/ia64/ia64.md https://gcc.gnu.org/onlinedocs/gccint/Machine-Desc.html https://www.cse.iitb.ac.in/grc/intdocs/gcc-writing-md.html 12
参考文献 Ghidra SLEIGH - https://ghidra.re/ghidra_docs/languages/html/sleigh.html https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Processor s/x86/data/languages/ia.sinc Golans SSA
rewrite rules https://github.com/golang/go/blob/e870de9936a7efa42ac1915ff4ffb16017dbc 819/src/cmd/compile/internal/ssa/_gen/AMD64.rules https://www.quasilyte.dev/blog/post/go_ssa_rules/ OpenJDK HotSpot ADL https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/x86.ad https://hsmemo.github.io/articles/noVxQtU9lk.html https://www.dcs.gla.ac.uk/~jsinger/pdfs/sicsa_openjdk/OpenJDKArchitecture.pd 13