Writing a compiler with LLVM
summary
A worked example builds MethodScript into native executables using LLVM 12 and the toolchain llc/opt/llvm-link, emitting human-readable LLVM IR then object files and a final exe. The compiler emits stack alloc/store/load for locals but mem2reg removes them, turning locals into SSA registers; loop-unroll plus instcombine collapses repeated adds into a single add. Demonstrations include a Minecraft SMS demo that runs, and a platform detail: Windows rand() is 16‑bit so two calls are combined into a wider value.
AI-written summary · about
chapters (7)
- 0:00Introduction to MethodScript
- 1:43Compiler architecture basics
- 7:28Understanding the LLVM model
- 11:20Parsing and building the AST
- 14:40Generating and linking IR
- 21:40Compiler optimizations
- 37:25Resources and Q&A
related talks
39mDemystifying LLVM: Writing Your First Compiler - The Good, The Bad, The Ugly
28mTshepang Lekhonkhobe: Behind The Scenes Of Producing An Executable
40mScala Goes Native
42mScala goes Native
26mHow Rust Compiles - Noratrieb
01h 03mto pass and return, the story of functions, values and compilers
08mOn "simple" Optimizations
01h 13mJai Demo and Design Explanation (KEYNOTE) - Updated
