How exaloop/codon works
Codon is a statically compiled Python implementation targeting native performance, with parallel and GPU execution plus Python interoperability. The principal workflow starts with a source file or code, parses and checks it, translates it into compiler IR, applies IR passes, emits LLVM, and produces or runs native code. The graph includes documented NumPy, JIT, Python-extension, and Jupyter capabilities. Some parser and backend links are inferred from the documented compiler workflow rather than inspected call sites, so those links are dashed and unevidenced.
Main entry points: compiler.cpp Compiler orchestration · manager.cpp Pass manager · main.cpp Codon CLI · engine.cpp JIT engine
Components 22
User entry points
- Codon CLI
codon/app/main.cpp - Jupyter interface
jupyter/jupyter.cpp
Language frontend
- Compiler orchestration
codon/compiler/compiler.cpp - Parsing and AST
codon/parser/ast/expr.cpp - Scoping
codon/parser/visitors/scoping/scoping.cpp - Type checking
codon/parser/visitors/typecheck - IR translation
codon/parser/visitors/translate
IR and optimization
- Codon IR
codon/cir/module.cpp - Pass manager
codon/cir/transform/manager.cpp - IR analyses
codon/cir/analyze - IR lowering
codon/cir/transform/lowering - NumPy transforms
codon/cir/transform/numpy - Parallel transforms
codon/cir/transform/parallel
Native execution
- LLVM code generation
codon/cir/llvm/llvisitor.cpp - JIT engine
codon/compiler/engine.cpp - Codon runtime
codon/runtime/lib.cpp - GPU backend
codon/cir/llvm/gpu.cpp
Integrations
- Python interoperability
codon/compiler/jit.cpp - Python JIT decorator
jit/codon/decorator.py - Python extensions
codon/cir/pyextension.h
Other components
- Program author
- Python ecosystem
Connections 24
- Program author → Codon CLI: invokes
README.md - Codon CLI → Compiler orchestration: compiles source
codon/app/main.cpp - Compiler orchestration → Parsing and AST: parses source
- Parsing and AST → Scoping: builds AST
- Scoping → Type checking: resolves names
- Type checking → IR translation: checks types
- IR translation → Codon IR: creates IR
- Compiler orchestration → Pass manager: owns pass manager
- Pass manager → IR analyses: runs analyses
codon/cir/transform/manager.cpp - Pass manager → IR lowering: registers passes
codon/cir/transform/manager.cpp - Pass manager → NumPy transforms: registers passes
codon/cir/transform/manager.cpp - Pass manager → Parallel transforms: registers passes
codon/cir/transform/manager.cpp - Compiler orchestration → LLVM code generation: owns code generator
- LLVM code generation → JIT engine: emits executable code
- JIT engine → Codon runtime: resolves runtime symbols
- Codon CLI → JIT engine: runs compiled code
- Jupyter interface → Compiler orchestration: uses compiler
jupyter/jupyter.cpp - Jupyter interface → Python ecosystem: serves notebook use
- Compiler orchestration → Python interoperability: supports Python interop
- Python JIT decorator → Python interoperability: uses JIT
- Compiler orchestration → Python extensions: builds extensions
- Compiler orchestration → GPU backend: supports GPU targets
- Parallel transforms → GPU backend: targets GPU
- Python ecosystem → Python interoperability: calls Codon