Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TableGenと和解せよ / make peace with TableGen
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Arata
August 23, 2023
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TableGenと和解せよ / make peace with TableGen
Arata
August 23, 2023
More Decks by Arata
See All by Arata
Black Hat USA 2026の面白かった発表を紹介
arata_nvm
1
22
Operating Systems: Three Easy Pieces, Chapter 49 / Sun's Network File System (NFS)
arata_nvm
0
23
デコンパイラ研究調査
arata_nvm
1
44
コンパイラ基盤を支える言語たち
arata_nvm
1
130
LLVMのDSL”TableGen”向け言語サーバーの開発
arata_nvm
0
46
5分でわかるPage-Fault Weird Machine
arata_nvm
2
450
eBPFを用いたAndroid向けデバッガ「eDBG」のx86_64 Linuxへの移植
arata_nvm
0
29
Pythonのcopy-and-patch JITの実装を読む
arata_nvm
0
200
eBPFを使った動的解析手法
arata_nvm
1
840
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
520
Optimising Largest Contentful Paint
csswizardry
37
4k
Statistics for Hackers
jakevdp
799
230k
For a Future-Friendly Web
brad_frost
183
10k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Building Adaptive Systems
keathley
44
3.2k
Un-Boring Meetings
codingconduct
0
440
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Transcript
TableGenと和解せよ 2023/08/21 Ando Shin / @Arata
TableGenとは • コンパイラ基盤LLVMの内部で使用されているDSL • レジスタや命令など、ターゲットマシン固有の情報を 記述するために用いられることが多い • 一般にはC++のコードに変換される 2
https://github.com/llvm/llvm-project/blob/1c822e1e8278ebefdb7701249bdfe51f1ed03d7d/llvm/lib/Target/X86/X86RegisterInfo.td#L163-L184 例: TableGenでX86のレジスタを記述 3
TableGen嫌われがち問題 4
• エディタの支援を受けられない • 情報がまとまっていない • C++と組み合わせてのビルドに手間がかかる なぜTableGenは嫌われているのか 5
• エディタの支援を受けられない • 情報がまとまっていない • C++と組み合わせてのビルドに手間がかかる なぜTableGenは嫌われているのか 6
2022年5月から言語サーバーが実装され始める 今日までに実装された機能: • シンタックスハイライト • エラー表示 • 定義へ移動 • 参照へ移動
• ホバー表示 エディタ支援の現状 7
2022年5月から言語サーバーが実装され始める 今日までに実装された機能: • シンタックスハイライト • エラー表示 • 定義へ移動 • 参照へ移動
• ホバー表示 コードの入力補完が実装されていない エディタ支援の現状 8
入力補完を実装した 9
• 言語サーバーの応答性が悪い • 一部のコードで支援機能を提供できない • 内部実装が言語サーバー向きではない 現状の言語サーバーの問題点 10
エラー表示・補完候補が更新されるまで時間がかかる様子 問題点1: 言語サーバーの応答性が悪い 11
考えられる原因: • 言語サーバーがシングルスレッドで動いている • パースと同時に評価を行っている ◦ コードが変更されるたびにすべてのシンボルの解決処理が走る 問題点1: 言語サーバーの応答性が悪い 12
• これはコード側に原因がある • includeが適切に行われないためシンボルを解決できない 問題点2: 一部のコードで支援機能を提供できない 13 A.td B.td ※Registerはllvm/Target/Target.tdで定義
コードの構造を保持するための方法にASTとCSTがある • AST: Abstract Syntax Tree (rustcで使われる) • CST: Concrete
Syntax Tree (rust-analyzerで使われる) TableGenではASTが使われているため、以下の問題がある • トークンの場所やコメントなどの情報が失われてしまう • 構文エラーがあった場所でパースが止まってしまう 問題点3: 内部実装が言語サーバー向きではない 14
RustでTableGenの新たな言語サーバーを実装しています 目指すところ: • キャッシュを使った処理の高速化 • エラーからの回復機能を持つパーサーの実装 • 一般的な支援機能の実装 • (TableGenのパーサーを提供して誰かがTableGen2.0を
作ってくれることを期待) 今していること 15