Created
December 26, 2022 23:47
-
-
Save uzluisf/e54634d5c52eb6380d411b58dd58949e to your computer and use it in GitHub Desktop.
D2 script (https://github.com/terrastruct/d2) for a three stage compiler diagram (https://en.wikipedia.org/wiki/Compiler#Three-stage_compiler_structure).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title: Three-stage compiler structure { | |
shape: text | |
near: frontend | |
style: { | |
font-size: 80 | |
bold: true | |
} | |
} | |
direction: right | |
llvm-ir1: LLVM-IR { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
llvm-ir2: LLVM-IR { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
frontend: Frontend { | |
clang: Clang { | |
style: { | |
stroke-width: 3 | |
stroke: "#000000" | |
fill: white | |
} | |
} | |
gollvm: Gollvm { | |
style: { | |
stroke-width: 3 | |
stroke: "#000000" | |
fill: white | |
} | |
} | |
rustc: { | |
style: { | |
stroke-width: 3 | |
stroke: "#000000" | |
fill: white | |
} | |
} | |
boltc: { | |
style: { | |
stroke-width: 3 | |
stroke: "#000000" | |
stroke-dash: 3 | |
fill: white | |
} | |
} | |
style: { | |
stroke-width: 3 | |
stroke: "#5721ff" | |
fill: white | |
} | |
} | |
middle-end: Middle-end { | |
llvm-optimizer: LLVM optimizer { | |
style: { | |
stroke-width: 3 | |
stroke: "#000000" | |
fill: white | |
} | |
} | |
style: { | |
stroke-width: 3 | |
stroke: "#5721ff" | |
fill: white | |
} | |
} | |
backend: Backend { | |
llvm-static-compiler: LLVM static compiler { | |
style: { | |
stroke-width: 3 | |
stroke: "#000000" | |
fill: white | |
} | |
} | |
style: { | |
stroke-width: 3 | |
stroke: "#5721ff" | |
fill: white | |
} | |
} | |
# Input Languages | |
c: C { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
cpp: C++ { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
go: Go { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
rust: Rust { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
bolt: Bolt { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
# Output | |
x86: x86 { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
ARM: { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
RISC-V: { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
MIPS: { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
PowerPC: { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
other-output: "..." { | |
style: { | |
stroke-width: 0 | |
fill: white | |
} | |
} | |
# Input languages to frontend | |
c -> frontend.clang | |
cpp -> frontend.clang | |
go -> frontend.gollvm | |
rust -> frontend.rustc | |
bolt -> frontend.boltc | |
# Frontend to LLVM | |
frontend.clang -> llvm-ir1 | |
frontend.gollvm -> llvm-ir1 | |
frontend.rustc -> llvm-ir1 | |
frontend.boltc -> llvm-ir1 | |
# LLVM to Middle-end | |
llvm-ir1 -> middle-end.llvm-optimizer | |
llvm-ir2 <- middle-end.llvm-optimizer | |
# Middle-end to backend | |
llvm-ir2 -> backend.llvm-static-compiler | |
# Backend to output | |
backend.llvm-static-compiler -> x86 | |
backend.llvm-static-compiler -> ARM | |
backend.llvm-static-compiler -> RISC-V | |
backend.llvm-static-compiler -> MIPS | |
backend.llvm-static-compiler -> PowerPC | |
backend.llvm-static-compiler -> other-output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment