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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Arata
April 17, 2026
110
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
Black Hat USA 2026の面白かった発表を紹介
arata_nvm
1
14
Operating Systems: Three Easy Pieces, Chapter 49 / Sun's Network File System (NFS)
arata_nvm
0
15
デコンパイラ研究調査
arata_nvm
1
34
LLVMのDSL”TableGen”向け言語サーバーの開発
arata_nvm
0
37
5分でわかるPage-Fault Weird Machine
arata_nvm
2
430
eBPFを用いたAndroid向けデバッガ「eDBG」のx86_64 Linuxへの移植
arata_nvm
0
26
Pythonのcopy-and-patch JITの実装を読む
arata_nvm
0
160
eBPFを使った動的解析手法
arata_nvm
1
820
カーネルハック実験の振り返り
arata_nvm
1
69
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
750
Abbi's Birthday
coloredviolet
3
9.6k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
220
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Skip the Path - Find Your Career Trail
mkilby
1
200
Automating Front-end Workflow
addyosmani
1369
210k
First, design no harm
axbom
PRO
2
1.3k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
The Cult of Friendly URLs
andyhume
79
7k
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