skills/venom.md
SSA-based intermediate representation for Vyper. Inspired by LLVM IR, adapted for stack-based EVM.
Primary reference: vyper/venom/README.md — full instruction set, grammar, examples.
IRContext → IRFunction(s) → IRBasicBlock(s) → IRInstruction(s)
%-prefixed, immutable after assignment (SSA)jmp/jnz/djmp/ret/return/stop/exitCore data structures in vyper/venom/:
context.py — IRContext, top-level containerfunction.py — IRFunctionbasicblock.py — IRBasicBlock, IRInstruction, IROperandbuilder.py — helper for programmatic IR constructionvenom_to_assembly.py — final pass: Venom → EVM assemblyparser.py — text format parser (for testing)Passes and analysis live in venom/passes/ and venom/analysis/ respectively.
Passes inherit from base classes in venom/passes/base_pass.py. Three categories:
venom/analysis/ (CFG, DFG, liveness, dominators, etc.)Pass ordering matters — e.g. assembly emission requires normalization, which requires CFG.
Browse venom/passes/ and venom/analysis/ for the full set. File names are self-descriptive.
vyper -f ir_runtime contract.vy # Venom IR (runtime)
vyper -f ir contract.vy # Venom IR (deploy)
vyper -f cfg_runtime contract.vy # CFG as dot graph
vyper -f asm contract.vy # final assembly
Enable Venom: --experimental-codegen flag or #pragma experimental-codegen in source.
AST → vyper/codegen_venom/ → Venom IR (direct translation, no legacy IR involved).
Entry point: vyper/codegen_venom/module.py.