Skip to content

vyperlang/vyper / skills

vyper-compiler

Verified

Vyper smart contract compiler internals. Use when working on the Vyper compiler codebase — compilation pipeline, Venom IR, semantic analysis, code generation, testing, or contributing. Triggers on vyper compiler development, Venom passes, AST/semantics changes, codegen work, or test writing.

FileKindSize
SKILL.mdskill md4.4 KB
codegen.mdmarkdown1.1 KB
contributing.mdmarkdown7.8 KB
semantics.mdmarkdown2.3 KB
testing.mdmarkdown1.6 KB
venom.mdmarkdown2.0 KB
# Venom IR

SSA-based intermediate representation for Vyper. Inspired by LLVM IR, adapted for stack-based EVM.

Primary reference: [vyper/venom/README.md](../vyper/venom/README.md) — full instruction set, grammar, examples.

## Structure

```
IRContext → IRFunction(s) → IRBasicBlock(s) → IRInstruction(s)
```

- Variables: `%`-prefixed, immutable after assignment (SSA)
- Basic blocks: non-branching, terminated by `jmp`/`jnz`/`djmp`/`ret`/`return`/`stop`/`exit`
- Normalized form: no block has both multiple predecessors AND multiple successors

## Key Files

Core data structures in `vyper/venom/`:
- `context.py` — `IRContext`, top-level container
- `function.py` — `IRFunction`
- `basicblock.py` — `IRBasicBlock`, `IRInstruction`, `IROperand`
- `builder.py` — helper for programmatic IR construction
- `venom_to_assembly.py` — final pass: Venom → EVM assembly
- `parser.py` — text format parser (for testing)

Passes and analysis live in `venom/passes/` and `venom/analysis/` respectively.

## Pass Architecture

Passes inherit from base classes in `venom/passes/base_pass.py`. Three categories:
- **Analysis** — `venom/analysis/` (CFG, DFG, liveness, dominators, etc.)
- **Transformation** — normalization, SSA construction, phi elimination
- **Optimization** — DCE, SCCP, CSE, load elimination, mem2var, inlining, 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.

## Inspecting Venom Output

```bash
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.

## Entry Path

AST → `vyper/codegen_venom/` → Venom IR (direct translation, no legacy IR involved).
Entry point: `vyper/codegen_venom/module.py`.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall