How inside-compiler/inside-llvm-code-gen works
Project type and purpose
• This is an educational “compiler code-generation” project accompanying the Chinese book “深入理解LLVM代码生成” (“Deep Understanding of LLVM Code Generation”).
• It contains sample programs (.c), LLVM IR files (.ll), Machine IR (.mir), machine code files (.mc/.s), and disassemblies, organized per chapter (ch1, ch2, …, ch12).
• Its goal is to walk the reader through each stage of LLVM’s codegen pipeline, from C source through to object code.
File structure
• Top-level:
• A/ – Misc. examples
• ch1…ch12/ – Chapter-by-chapter code samples
• README.md – Project overview, points to the LLVM fork (inside-compiler/llvm-project, release/15.x)
• Each chapter directory contains:
• .c – C source input to Clang
• .ll – LLVM IR produced by Clang
• .mir – LLVM “Machine IR” after instruction selection
• .mc, .s – Target assembly output
• .disassembly/.log – Disassembler output or logs for verification
• There are no web-frontend or database files; this is a language/compiler project.
README for additional insights
• Confirms this is companion code for the LLVM code-generation book.
• References the LLVM project repo and version.
Detailed capture of essential elements
• External dependency: the inside-compiler/llvm-project repo version at the top corner.
• Chapter as a sub-module or annotation around the relevant stage (“ch10 examples illustrate MC layer”).
• Don’t overcrowd: group chapters by stage (e.g., chapters 1–3 under “Frontend”, 4–6 under “Mid-end IR”, 7–9 under “Machine IR”, 10–12 under “Assembly/Disassembly”).