Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
Uploaded by
hydai
PDF, PPTX
2,745 views
COSCUP2016 - LLVM框架、由淺入淺
AI-enhanced description
文档介绍了LLVM框架及其编译流程,包括前端、后端和优化阶段的设计架构。提到不同编程语言的编译实现以及RAISE和SSA等重要概念。还包含LLVM相关资料和开发资源的链接。
Engineering
◦
Read more
10
Save
Share
Embed
Embed presentation
Download
Download as PDF, PPTX
1
/ 62
2
/ 62
3
/ 62
4
/ 62
5
/ 62
6
/ 62
7
/ 62
8
/ 62
9
/ 62
10
/ 62
11
/ 62
12
/ 62
13
/ 62
14
/ 62
15
/ 62
16
/ 62
17
/ 62
18
/ 62
19
/ 62
20
/ 62
21
/ 62
22
/ 62
23
/ 62
24
/ 62
25
/ 62
26
/ 62
27
/ 62
28
/ 62
29
/ 62
30
/ 62
31
/ 62
32
/ 62
33
/ 62
34
/ 62
35
/ 62
36
/ 62
37
/ 62
38
/ 62
39
/ 62
40
/ 62
41
/ 62
42
/ 62
43
/ 62
44
/ 62
45
/ 62
46
/ 62
47
/ 62
48
/ 62
49
/ 62
50
/ 62
51
/ 62
52
/ 62
53
/ 62
54
/ 62
55
/ 62
56
/ 62
57
/ 62
58
/ 62
59
/ 62
60
/ 62
61
/ 62
62
/ 62
More Related Content
PDF
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
by
National Cheng Kung University
PPTX
LLVM Instruction Selection
by
Shiva Chen
PDF
Interpreter, Compiler, JIT from scratch
by
National Cheng Kung University
PDF
from Binary to Binary: How Qemu Works
by
Zhen Wei
PDF
LLVM Register Allocation (2nd Version)
by
Wang Hsiangkai
PDF
Qemu JIT Code Generator and System Emulation
by
National Cheng Kung University
PPTX
LLVM Backend Porting
by
Shiva Chen
PDF
用十分鐘 向jserv學習作業系統設計
by
鍾誠 陳鍾誠
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
by
National Cheng Kung University
LLVM Instruction Selection
by
Shiva Chen
Interpreter, Compiler, JIT from scratch
by
National Cheng Kung University
from Binary to Binary: How Qemu Works
by
Zhen Wei
LLVM Register Allocation (2nd Version)
by
Wang Hsiangkai
Qemu JIT Code Generator and System Emulation
by
National Cheng Kung University
LLVM Backend Porting
by
Shiva Chen
用十分鐘 向jserv學習作業系統設計
by
鍾誠 陳鍾誠
What's hot
PDF
LLVM introduction
by
National Cheng Kung University
PDF
Anatomy of the loadable kernel module (lkm)
by
Adrian Huang
PDF
LLVM Register Allocation
by
Wang Hsiangkai
PDF
How to write a TableGen backend
by
Min-Yih Hsu
PPTX
Linux Kernel Module - For NLKB
by
shimosawa
PDF
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
by
Anne Nicolas
PPTX
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
by
Peter Hlavaty
PDF
BPF - in-kernel virtual machine
by
Alexei Starovoitov
PDF
DPDK: Multi Architecture High Performance Packet Processing
by
Michelle Holley
PDF
Qemu Introduction
by
Chiawei Wang
PDF
Embedded_Linux_Booting
by
Rashila Rr
PPTX
RISC-V Boot Process: One Step at a Time
by
Atish Patra
PDF
ROP 輕鬆談
by
hackstuff
PPTX
QEMU - Binary Translation
by
Jiann-Fuh Liaw
PDF
강좌 06 부트로더
by
chcbaram
PDF
Embedded Linux Kernel - Build your custom kernel
by
Emertxe Information Technologies Pvt Ltd
PDF
Kernel crashdump
by
Adrien Mahieux
PDF
Sigreturn Oriented Programming
by
Angel Boy
PDF
Linux Porting
by
Champ Yen
PDF
GNU ld的linker script簡介
by
Wen Liao
LLVM introduction
by
National Cheng Kung University
Anatomy of the loadable kernel module (lkm)
by
Adrian Huang
LLVM Register Allocation
by
Wang Hsiangkai
How to write a TableGen backend
by
Min-Yih Hsu
Linux Kernel Module - For NLKB
by
shimosawa
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
by
Anne Nicolas
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
by
Peter Hlavaty
BPF - in-kernel virtual machine
by
Alexei Starovoitov
DPDK: Multi Architecture High Performance Packet Processing
by
Michelle Holley
Qemu Introduction
by
Chiawei Wang
Embedded_Linux_Booting
by
Rashila Rr
RISC-V Boot Process: One Step at a Time
by
Atish Patra
ROP 輕鬆談
by
hackstuff
QEMU - Binary Translation
by
Jiann-Fuh Liaw
강좌 06 부트로더
by
chcbaram
Embedded Linux Kernel - Build your custom kernel
by
Emertxe Information Technologies Pvt Ltd
Kernel crashdump
by
Adrien Mahieux
Sigreturn Oriented Programming
by
Angel Boy
Linux Porting
by
Champ Yen
GNU ld的linker script簡介
by
Wen Liao
Similar to COSCUP2016 - LLVM框架、由淺入淺
PDF
from Source to Binary: How GNU Toolchain Works
by
National Cheng Kung University
PDF
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
by
National Cheng Kung University
PDF
Linux binary Exploitation - Basic knowledge
by
Angel Boy
PDF
[嵌入式系統] 嵌入式系統進階
by
Simen Li
PDF
Binary exploitation - AIS3
by
Angel Boy
DOCX
系統程式 -- 第 9 章 虛擬機器
by
鍾誠 陳鍾誠
PDF
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
by
Li Hsuan Hung
PDF
程式設計師的自我修養 Chapter 1
by
Shu-Yu Fu
PPTX
Hcsm lect-20120913
by
lusecheng
PDF
Example my hdl
by
sean chen
from Source to Binary: How GNU Toolchain Works
by
National Cheng Kung University
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
by
National Cheng Kung University
Linux binary Exploitation - Basic knowledge
by
Angel Boy
[嵌入式系統] 嵌入式系統進階
by
Simen Li
Binary exploitation - AIS3
by
Angel Boy
系統程式 -- 第 9 章 虛擬機器
by
鍾誠 陳鍾誠
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
by
Li Hsuan Hung
程式設計師的自我修養 Chapter 1
by
Shu-Yu Fu
Hcsm lect-20120913
by
lusecheng
Example my hdl
by
sean chen
More from hydai
PDF
連哈秋都懂的Git教學
by
hydai
PDF
Introduction to Ewasm - crosslink taipei 2019
by
hydai
PDF
Introduction to ewasm
by
hydai
PDF
Lity - 讓你更安全的 Smart Contract Language
by
hydai
PDF
Vim 由淺入淺
by
hydai
PDF
Slack&typora
by
hydai
連哈秋都懂的Git教學
by
hydai
Introduction to Ewasm - crosslink taipei 2019
by
hydai
Introduction to ewasm
by
hydai
Lity - 讓你更安全的 Smart Contract Language
by
hydai
Vim 由淺入淺
by
hydai
Slack&typora
by
hydai
COSCUP2016 - LLVM框架、由淺入淺
1.
LLVM框架、由淺⼊入淺 浪打、Hydai
2.
Speakers $ whoami
3.
楊宗凡 — 浪打 ‣
成功⼤大學電機系四年級 ‣ sonic.tw.tp (at) gmail.com 戴宏穎 — Hydai ‣ 清華⼤大學資⼯工碩⼀一年級 ‣ z54981220 (at) gmail.com
4.
Github Repos: https://github.com/sonicyang/ws-frontend https://github.com/sonicyang/llvm-z80
5.
Code to Executable $
gcc helloworld.c
6.
#include <stdio.h> int main(int
argc, char* argv[]){ puts(“Hello World!”); return 0; } In C Hello World! print “Hello World!” In Python Hello World! 魔法 我想學魔法!
7.
The Magic 原始碼 組合語⾔言
機械碼 AssemblerCompiler print “!@#$” mov d, msg$ mov c, 9 call 5 110100…. >./hw 機械碼 110100…. Hello World!
8.
Compiler 原始碼 組合語⾔言 Lex Parse Token Stream 轉譯AST
9.
bdos equ 0005H start:
mvi c,9 lxi d,msg$ call bdos ret msg$:db 'Hello, world!$' end start Intel 8080 Assembler MSG: .ASCIIZ "Hello, world!" LDX #0 LDA MSG,X @LP: JSR $FFD2 INX LDA MSG,X BNE @LP RTS MOS 6502 8080 Assemble 6502 Assemble 110110.. 010111.. CP/M Apple Dos
10.
Perl Python Java C Ruby Javascript 他們都造⾃自⼰己的輪⼦子 對應不同的機器 IA-32 AMD64 IA-64 Arch32 AArch64 Sun
Sparc
11.
Compiler 原始碼 組合語⾔言 Lex Parse Token Stream 轉譯AST
12.
Modern Compiler $ export
CFLAGS = “-O3”
13.
Modern Wheel 原始碼 組合語⾔言 Lex Yacc AST 演算法 中介語⾔言 轉譯
14.
三階段編譯流程 原始碼 Backend 組合語⾔言 OptimizerFrontend
15.
Copy Propagation
16.
Constant Propagation
17.
Constant Folding
18.
Dead Code Elimination(1)
19.
Dead Code Elimination(2)
20.
三階段編譯流程 原始碼 Backend 組合語⾔言 OptimizerFrontend
21.
Python的故事 Python 組合語⾔言 Interpreter C Code GCC
22.
LLVM Framework $ git
clone http://llvm.org/git/llvm.git
23.
三階段編譯流程 原始碼 Backend 組合語⾔言 OptimizerFrontend
24.
IR LLVM Framework - Front
End 原始碼 Backend 組合語⾔言Frontend IRPass IR Pass … Pass IR Pass
25.
IR LLVM Framework - Optimizer 原始碼
Backend 組合語⾔言Frontend IRPass IR Pass … Pass IR Pass
26.
IR LLVM Framework - Back
End 原始碼 Backend 組合語⾔言Frontend IRPass IR Pass … Pass IR Pass
27.
模組化的開發 原始碼 Backend 組合語⾔言 OptimizerFrontend LLVM IR
28.
Front End $ clang
-S -emit-llvm main.c
29.
以下使⽤用 Whitespace 語⾔言
30.
Hello, world!
31.
Hello, world(syntax hl)
32.
Whitespace 簡介 • 只有三種
Tokens: • Space 空⽩白(' ') • Tabs 制表符(t) • New lines 換⾏行(n) • 其餘的字元全部都被當成註解
33.
Front End to
IR 程式碼 LLVM IR
34.
Front End to
IR 程式碼 LLVM IRParser LLVM API • Module • IRBuilder • Function • BasicBlock • Instruction
35.
LLVM IR $ cat
main.ll
36.
LLVM IR • RISC-style
(Reduced Instruction Set Computing) • ⼈人類可讀的 • 具備 SSA form (Static Single Assignment) • 無限多的虛擬暫存器 • 任意位元⼤大⼩小 • 不改變⾏行為下 Transform IR ,來做最佳化。
37.
C to IR
39.
int a =
1;
40.
int c =
a+b;
41.
Optimizer • LLVM 使⽤用
opt 做最佳化 • 每⼀一種類的分析跟轉換的 pass 都是 opt 的參數 • opt 會照順序幫你⼀一個⼀一個⾛走過這些 pass • 每個 pass 會⾃自⼰己決定要不要做事
42.
opt 剛才的 C
Code
43.
Backend $ llc -march=z80
main.ll
44.
Basic Ideas LLVM IR
組合語⾔言
45.
Basic Ideas SelectionDAGLLVM IR
組合語⾔言 •Combining •Legalizing •Scheduling •Register Allocation
46.
What’s a DAG?
47.
llvm::SelectionDAGISel LLVM IR 組合語⾔言 Original
DAG Combined DAG Legalized DAG Target Legalizing DAG Combiner Instruction Selection TableGe n
48.
llvm::SelectionDAGISel LLVM IR 組合語⾔言 Original
DAG Combined DAG Legalized DAG Target Legalizing DAG Combiner Instruction Selection TableGe n
49.
TableGen 組譯器 反組譯器 編譯器 除錯器 Target CPU 暫存器 指令格式 指令 代表A 代表B 代表C 代表D
50.
TableGen 組譯器 反組譯器 編譯器 除錯器 Target CPU Table Gen 暫存器 指令格式 指令
51.
Legalizing LOAD LD 8bit 加法 除法 32bit 加法 ⼀一堆 減法 Legal Promote Custom
52.
Instruction Selecting 組合語⾔言 Legalized DAG Instruction Selection TableGe n
53.
Register Allocation SSA 虛擬暫存器 CPU暫存器 分配 最佳化 Instruction Scheduling 原先指令順序
CPU 更適合的順續 順序 最佳化
54.
llvm::SelectionDAGISel LLVM IR 組合語⾔言 Original
DAG Combined DAG Legalized DAG Target Legalizing DAG Combiner Instruction Selection TableGe n
55.
Demo A 40 years
portal by LLVM, Linking 1976 and 2016
56.
Demo A 40 years
portal by LLVM, Linking 1976 and 2016 WhiteSpace LLVM IR 組合語⾔言 CP/M LLVM Zilog Z80
57.
模組化的LLVM 原始碼 Backend 組合語⾔言 OptimizerFrontend
58.
Reference $ uname -a
59.
1. Architecture for
Next Generation GCC ftp://gcc.gnu.org/pub/gcc/summit/2003/Architecture%20for%20a%20Next-Generation %20GCC.pdf 2. Life of an Instruction in LLVM http://eli.thegreenplace.net/2012/11/24/life-of-an-instruction-in-llvm 3. A deeper look into the LLVM code generator http://eli.thegreenplace.net/2013/02/25/a-deeper-look-into-the-llvm-code-generator- part-1 4. LLVM TableGen Documentation http://llvm.org/docs/TableGen/index.html 5. LLVM TableGen Introduction http://llvm.org/docs/TableGen/LangIntro.html 6. Independent Code Generator http://llvm.org/docs/CodeGenerator.html 7. The Relationship between selectiondag and selectiondagisel http://stackoverflow.com/questions/26814062/the-relationship-between-selectiondag- and-selectiondagisel 8. How TableGen’s DAGISel Backend Works https://github.com/draperlaboratory/fracture/wiki/How-TableGen's-DAGISel-Backend- Works 9. ZASM - Z80 Assembler http://k1.spdns.de/Develop/Projects/zasm/Documentation/ 10. LLVM Z80 Backend https://github.com/mostlyuseful/llvm-z80/network 11. Whitespace LLVM https://github.com/Subv/Whitespace-LLVM
60.
Q & A $
man man
Download