← Back to Blog
Technical Mar 20, 2026

How Vexel Compiles to LLVM IR

When you run vexel run hello.vx, a lot happens before your program executes. Here's the full pipeline.

The Pipeline

  1. Lexer: tokenizes source text into keywords, identifiers, operators
  2. Parser: builds an Abstract Syntax Tree (AST) from tokens
  3. Semantic Analyzer: type-checks, resolves names, validates the program
  4. LLVM IR Codegen: walks the AST and emits LLVM IR via llvmlite
  5. LLVM: optimizes and compiles IR to native machine code

From Source to IR

This Vexel function:

fn add(a: int, b: int) -> int:
    return a + b

Becomes this LLVM IR:

define i64 @add(i64 %a, i64 %b) {
entry:
  %result = add i64 %a, %b
  ret i64 %result
}

You can inspect the IR yourself with vexel ir yourfile.vx.