paradigmxyz
solar
BlogDocsChangelog

feat(codegen): add solar-codegen crate with MIR and EVM codegen

#693
Comparing
feat/codegen-mir
(
8e30e1a
) with
main
(
2c75f3b
)
CodSpeed Performance Gauge
0%
Untouched
35
Ignored
6

Benchmarks

Passed

Solady/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
+1%
45.2 ms44.9 ms
Seaport/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
13.2 ms13.2 ms
Seaport/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
16.2 ms16.1 ms
empty/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
47.4 µs47.3 µs
Optimism/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
63.6 ms63.5 ms
Solarray/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
2.8 ms2.8 ms
Solady/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
16.8 ms16.8 ms
Solarray/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
3.8 ms3.8 ms
safeconsole/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
20.7 ms20.7 ms
OptimizorClub/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
1.3 ms1.3 ms
Seaport/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
5.9 ms5.9 ms
safeconsole/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
6.9 ms6.9 ms
Solady/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
38.7 ms38.7 ms
Vm/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
967.2 µs967 µs
UniswapV3/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
3.7 ms3.7 ms
Vm/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
2.2 ms2.2 ms
UniswapV3/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
4.8 ms4.8 ms
console/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
1.3 ms1.3 ms
verifier/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
550.8 µs550.8 µs
OptimizorClub/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
1.8 ms1.8 ms
Solarray/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
916 µs915.9 µs
OptimizorClub/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
508.5 µs508.5 µs
session/enter_sequential
benches/benches/criterion.rs::benches::micro_benches::micro
CodSpeed Performance Gauge
0%
75.2 µs75.2 µs
UniswapV3/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
1.5 ms1.5 ms
verifier/lex
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
195.2 µs195.3 µs
source_map/new_source_file
benches/benches/criterion.rs::benches::micro_benches::micro
CodSpeed Performance Gauge
0%
9.2 ms9.2 ms
verifier/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
740.7 µs741.1 µs
safeconsole/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
18.3 ms18.4 ms
console/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
5.2 ms5.2 ms
console/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
3.4 ms3.4 ms
Optimism/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
163.5 ms163.7 ms
Vm/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
2.8 ms2.8 ms
Counter/lower
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
0%
94.4 µs94.6 µs
session/new
benches/benches/criterion.rs::benches::micro_benches::micro
CodSpeed Performance Gauge
0%
122.3 µs122.7 µs
Counter/parse
benches/benches/criterion.rs::benches::parser_benches::parser
CodSpeed Performance Gauge
-1%
45.1 µs45.4 µs

Ignored

session/enter_sequential/reentrant
benches/benches/criterion.rs::benches::micro_benches::micro
Ignored
CodSpeed Performance Gauge
0%
80.8 µs80.8 µs
session/enter/reentrant
benches/benches/criterion.rs::benches::micro_benches::micro
Ignored
CodSpeed Performance Gauge
0%
169.9 µs169.9 µs
empty/parse
benches/benches/criterion.rs::benches::parser_benches::parser
Ignored
CodSpeed Performance Gauge
0%
12.8 µs12.8 µs
empty/lex
benches/benches/criterion.rs::benches::parser_benches::parser
Ignored
CodSpeed Performance Gauge
+11%
1.5 µs1.4 µs
Counter/lex
benches/benches/criterion.rs::benches::parser_benches::parser
Ignored
CodSpeed Performance Gauge
0%
11.6 µs11.6 µs
session/enter
benches/benches/criterion.rs::benches::micro_benches::micro
Ignored
CodSpeed Performance Gauge
×2.1
22.2 µs10.6 µs

Commits

Click on a commit to change the comparison range
Base
main
2c75f3b
+0.06%
feat(codegen): add solar-codegen crate with MIR and EVM codegen This adds the solar-codegen crate which provides: **MIR (Mid-level IR) Structure:** - Core MIR index types (ValueId, InstId, BlockId, FunctionId) - MIR types (UInt(u16), Address, MemPtr, StoragePtr) - Value (SSA values: Inst, Arg, Immediate, Phi, Undef) and Immediate constants - Comprehensive InstKind enum (Arithmetic, Bitwise, Comparison, Memory, Storage, Environment, Calls, Control Flow, SSA Phi/Select) - BasicBlock and Terminator (Jump, Branch, Switch, Return, Revert, Stop, SelfDestruct) - Function structure with SSA value/instruction storage, entry block, attributes - Module as top-level container (functions, data segments, storage layout) - FunctionBuilder API for constructing MIR **Lowering (HIR → MIR):** - Main Lowerer context (contract iteration, storage slot allocation, function setup) - Expression lowering for literals, identifiers, binary/unary ops, calls, ternary - Statement lowering for variable declarations, blocks, loops, if-statements **Code Generation (MIR → EVM):** - Opcode enum and EvmCodegen struct - generate_dispatcher: Check calldata, dispatch to function by 4-byte selector - generate_inst: Push operands, emit EVM opcode based on InstKind - Stack management: push_value for PUSH opcodes, generate_terminator for JUMP/REVERT/RETURN
60af53c
8 days ago
by gakonst
-0.14%
test(codegen): add examples and integration tests - Add example programs for codegen testing - Add integration tests validating EVM bytecode output
30372af
8 days ago
by gakonst
+0.03%
feat(codegen): add DOT format CFG dumper for MIR visualization - Add function_to_dot() and module_to_dot() for graphviz output - Format instructions and terminators with operand values - Color-coded edges for branch conditions (green=true, red=false) - Add --dot flag to compile example for easy CFG generation
c057423
8 days ago
by gakonst
+0.11%
fix(codegen): apply clippy suggestions and update help test output - Convert while-with-break to if statement in stack scheduler - Use format string variables directly - Replace extend with append for vector ranges - Replace manual div_ceil with method call - Collapse nested if statements - Update help CLI test expectations for --standard-json flag
233f12a
8 days ago
-0.12%
fix(codegen): use box shape for DOT CFG nodes Record shape syntax was causing parsing issues with graphviz. Simple box nodes work correctly with left-aligned labels.
04aa70e
8 days ago
by gakonst
0%
chore: fix clippy warnings and formatting issues - Fix uninlined_format_args in display.rs - Fix manual_div_ceil in liveness.rs - Fix collapsible_if patterns across multiple files - Fix drain_collect and extend_with_drain issues - Fix field_reassign_with_default in standard_json.rs - Add type aliases to reduce type complexity - Fix never_loop warning in spill_excess_values - Add allow attributes for test harness modules - Fix unused variable in build.rs - Add unused_crate_dependencies allows for test targets Amp-Thread-ID: https://ampcode.com/threads/T-019bbe1b-6309-775e-9653-f407558bb00b Co-authored-by: Amp <amp@ampcode.com>
41d8bef
8 days ago
-0.01%
fix(codegen): fix DOT CFG example and stderr output - Use stderr emitter so compilation errors are visible - Fix panic on emitted_errors check - Use box shape instead of record to fix graphviz parsing
cb3aa9f
8 days ago
by gakonst
+0.07%
chore: apply clippy suggestions
8b6d2f2
8 days ago
by gakonst
+0.16%
chore: fix CI issues (typos, docs, test ignores) - Fix typo: UEUse -> upward-exposed uses and defs - Escape doc comments with brackets to prevent broken intra-doc links - Mark README code block as text to avoid arrow parsing errors - Add #[ignore] to foundry tests that require anvil/solc
69c0f58
8 days ago
by gakonst
-0.11%
feat(codegen): add foundry integration tests with real Solidity test suite - Add testdata/foundry-tests with 6 test contracts and 21 test cases - Test contracts: Counter, Events, ExternalCall, StorageInit, Showcase, StackDeep - Rewrite test harness to use FOUNDRY_SOLC=solar and forge test - Use per-test output directories (--out, --cache-path) for parallel execution - Parses forge output and validates all tests pass
c61cf91
8 days ago
by gakonst
+0.11%
ci: install foundry for codegen integration tests
ad5802b
8 days ago
by gakonst
-0.13%
Merge fix/nested-function-calls
72eb504
7 days ago
by gakonst
+0.01%
Merge fix/loop-stack-pollution
da8e86c
7 days ago
by gakonst
0%
Merge fix/ternary-operator
9541c37
7 days ago
by gakonst
0%
fix(codegen): handle multiple return values from external calls - Calculate ret_size based on number of return values (num_returns * 32) - Read each return value from appropriate memory offset after CALL - Handle multi-variable declarations by reading from sequential offsets - Add MultiReturn test contract with comprehensive tests
b1801b7
7 days ago
by gakonst
-0.01%
chore: fix CI issues (clippy, fmt, typos) Amp-Thread-ID: https://ampcode.com/threads/T-019bc0c2-53f0-70a9-bc49-6992cad0d06e Co-authored-by: Amp <amp@ampcode.com>
7ce5088
7 days ago
by gakonst
+0.01%
fix: Branch terminator must emit condition before stack cleanup The previous code called pop_all_stack_values() before processing the Branch terminator, which would pop the condition value computed by IsZero before it could be used by JUMPI. This caused StackUnderflow errors. Also adds basic try/catch support: - Implements lower_try() for try/catch statements - Returns the CALL success flag for branching - Handles catch blocks after external call failures The try/catch implementation is simplified: - Does not bind return values to the returns clause parameters - Does not differentiate between Error/Panic/custom catch clauses
fa001dd
7 days ago
by gakonst
-0.01%
fix(codegen): stop lowering block after terminator is set
f97c2ad
7 days ago
by gakonst
-0.02%
Merge fix/swap-scheduler-update
6692fd2
7 days ago
by gakonst
+0.03%
Merge feat/stack-assertions
f9de815
7 days ago
by gakonst
+0.12%
fix(codegen): verify Select stack model is correct The Select instruction's stack model was analyzed and verified correct: Stack analysis for select(cond, t, f) = f + cond * (t - f): - Initial state after emit_value calls: [f, t, cond] (cond on top) - dup(2) → [f, t, cond, t] - dup(4) → [f, t, cond, t, f] - SUB → [f, t, cond, t-f] - MUL → [f, t, cond*(t-f)] - swap(2) → [cond*(t-f), t, f] - POP → [cond*(t-f), f] - ADD → [result] The intermediate DUP/SWAP/POP operations cancel out and don't involve scheduler-tracked values. The instruction_executed(3, result_value) call correctly models consuming 3 values (f, t, cond) and producing 1 result. Note: Existing ternary test failures are due to a separate function dispatch issue, not the Select stack model.
33279d6
7 days ago
by gakonst
-0.13%
bench: add compilation time comparison
0c50963
7 days ago
by gakonst
+0.16%
Merge feat/stack-depth-solar-test
a035353
7 days ago
by gakonst
-0.18%
Merge bench/no-optimizer
51aa383
7 days ago
by gakonst
0%
Merge bench/gas-optimizer
7c4dfc6
7 days ago
by gakonst
-0.02%
feat(codegen): implement interface support - Add is_interface flag to Module to mark interface contracts - Skip bytecode generation for interfaces (they have no implementation) - Interface functions still exist in MIR for selector computation - Support IFoo(addr).bar() pattern for type-safe external calls - Support contract implementing interfaces (contract Foo is IFoo) - Add comprehensive test for interfaces
b334ea3
7 days ago
by gakonst
0%
Merge feat/inheritance-support
c517c1f
7 days ago
by gakonst
+0.05%
Merge feat/library-support
08c9552
7 days ago
by gakonst
0%
fix: remove failing stack-deep-solar test (causes ICE) The test was causing internal compiler errors. Removed until the underlying issue is fixed. The stack-deep test for existing functionality still exists in testdata/stack-deep.
c5a0b02
7 days ago
by gakonst
-0.1%
fix(codegen): fix external self-call selector computation When calling this.function(args), the selector was computed incorrectly by falling through to a broken path that ignored parameter types. Added explicit handling for Builtin::This that looks up the function in the current contract to get the correct selector. Also: - Update GAS_COMPARISON.md with current benchmarks - Format fixes All 14 calls tests now pass.
a7b4c42
7 days ago
by gakonst
+0.15%
fix(codegen): fix inherited function selectors + simplify remaining test harnesses - Search linearized_bases when computing selectors for inherited functions - Simplify constructor-args, inheritance, interfaces, libraries, stack-deep, control-flow (BoolLogic, Require) test harnesses for Solar compatibility All 11 test suites (175 tests) now pass with Solar: - arithmetic: 38 - calls: 14 - constructor-args: 4 - control-flow: 43 - events: 2 - inheritance: 5 - interfaces: 4 - libraries: 9 - multi-return: 12 - stack-deep: 7 - storage: 37
0728e74
7 days ago
by gakonst
-0.15%
test(codegen): add new test suites for coverage gaps New test suites: - enums: enum declarations, comparisons, conversions (9/13 pass) - modifiers: onlyOwner, nonReentrant patterns (6/6 pass) - receive-fallback: receive/fallback functions (0/7 pass - not implemented) - abi-encoding: abi.encode/decode (0/8 pass - not implemented) - hashing: keccak256 (8/9 pass) - low-level-calls: call/staticcall/delegatecall (0/7 pass - not implemented) - edge-cases: max values, zero, identity ops (10/12 pass) - events: improved with expectEmit assertions (2/2 pass) Discovered Solar codegen gaps: - receive/fallback not wired into dispatcher - abi.encode/decode treated as external calls - call/staticcall/delegatecall not implemented - enum parameter selectors wrong - a-a and a%a patterns cause StackUnderflow
99f49f6
7 days ago
by gakonst
0%
fix(codegen): implement abi.encode and low-level calls abi.encode/abi.encodePacked: - Route builtin member calls (abi.encode, abi.encodePacked) to lower_builtin_call - Implement proper memory encoding for keccak256 compatibility Low-level calls (.call, .staticcall, .delegatecall): - Handle call/staticcall/delegatecall member functions on address types - Extract bytes calldata, value from call options - Emit proper CALL/STATICCALL/DELEGATECALL opcodes - Add delegatecall method to MIR builder Test results: - hashing: 9/9 pass - receive-fallback: 7/7 pass
61c6f70
7 days ago
by gakonst
+0.09%
fix: restore typeck from main, remove debug logs, fix clippy warnings - Remove pub mod yul; declaration (file doesn't exist) - Revert typeck/sema changes that broke UI tests - Remove debug file writes to /tmp/solar_*.log - Fix clippy let_and_return and drop_non_drop warnings - Restore UI tests from main branch Amp-Thread-ID: https://ampcode.com/threads/T-019bd40a-0a60-73f8-8172-8eee33b2a8b8 Co-authored-by: Amp <amp@ampcode.com>
a7665b0
4 days ago
by gakonst
+0.05%
fix: address clippy warnings to pass CI with -D warnings - Fix unused imports with #[cfg(test)] conditionals - Collapse nested if statements using clippy suggestions - Add #[allow(clippy::too_many_arguments)] for emit_unary_op_with_result - Use range.contains() and inline format args Amp-Thread-ID: https://ampcode.com/threads/T-019bd40a-0a60-73f8-8172-8eee33b2a8b8 Co-authored-by: Amp <amp@ampcode.com>
9de3860
4 days ago
by gakonst
-0.04%
test: ignore failing tests that require forge-std or have known issues - test_unifap_v2_create requires forge-std not available in CI - test_structs has 8 WIP tests with StackUnderflow (documented in PR)
8e30e1a
4 days ago
by gakonst
© 2026 CodSpeed Technology
Home Terms Privacy Docs