agentleFS
rainoftimerainoftime/pl-skills/llvm-backend-generator/SKILL.md

llvm-backend-generator

Skill17 starsChanged 9 months agoApache-2.0View on GitHub

Generates LLVM IR and builds compilers targeting LLVM. Use when: (1)

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use existing language frontends (Clang, Swift) as reference

    line 60
  2. Distinctive:

    Use debug info metadata for debugging support

    line 63
  3. Distinctive:

    Consider embedded languages (Emscripten, Rust)

    line 64

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

LLVM Backend Generator

Generates LLVM Intermediate Representation (IR) and builds compiler backends targeting LLVM.

When to Use

  • Building compilers for new languages
  • Implementing language backends
  • Creating optimization pipelines
  • Generating native code
  • Integrating with existing LLVM-based tools

What This Skill Does

  1. Generates LLVM IR - Creates valid LLVM bitcode
  2. Builds instruction selection - Patterns for code generation
  3. Implements optimization passes - Built-in and custom passes
  4. Handles ABI - Calling conventions, data layout

Key Concepts

ConceptDescription
LLVM IRThree-address code, SSA form
Basic blockSequence of instructions, single entry/exit
SSAStatic Single Assignment - each variable assigned once
PassTransformation or analysis
Target tripleCPU/OS/platform combination

Optimization Pass Categories

CategoryPasses
AnalysisDominators, loop info, alias analysis
TransformsGVN, LICM, inlining, vectorization
CodeGenInstruction selection, register allocation

Tips

  • Use existing language frontends (Clang, Swift) as reference
  • Implement proper name mangling for C++ interop
  • Handle alignment and endianness correctly
  • Use debug info metadata for debugging support
  • Consider embedded languages (Emscripten, Rust)

Related Skills

  • jit-compiler-builder - JIT with LLVM ORC
  • ssa-constructor - SSA form construction
  • type-checker-generator - Type checking frontend
  • dataflow-analysis-framework - Analysis passes

Canonical References

ReferenceWhy It Matters
Lattner & Adve, "LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation" (CGO 2004)LLVM design
The LLVM Language ReferenceIR specification
LLVM DocumentationOfficial docs and tutorials
Kaleidoscope TutorialBuilding a language with LLVM

Tradeoffs and Limitations

Approaches

ApproachProsCons
Use LLVM APIFull control, optimizedComplex API
Use MCJIT/ORCEasier JITLess control
Emit textual IRSimple, debuggableSlower

Limitations

  • Complex API learning curve
  • Generated code quality depends on patterns
  • Limited portability without target description
  • Some targets less mature than x86/AArch64

Research Tools & Artifacts

LLVM-based compilers:

ToolWhat to Learn
ClangC/C++ frontend
RustRust compiler
SwiftSwift compiler

Research Frontiers

1. WASM Compilation

  • Goal: WebAssembly targets

Implementation Pitfalls

PitfallReal ConsequenceSolution
Target bugsWrong codeTest extensively

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.