Human documentation starts at the README and continues under docs/src.
Everything written for this repository is short and human-readable.
- No headings, bold labels or numbered scaffolding where a paragraph is enough.
- No lead that summarizes what follows, and no closing that repeats it.
- No restatement of what the reader can already see.
- No account of how the work was done, and no approval of what is already correct.
- No hedging: a claim that is not verified is not made.
- No sycophancy, no emoji, and no sentence that only introduces the next one.
- No tombstones: what was removed leaves no trace.
- No negative definitions: what a thing is not stays unwritten.
- solx (this repo) is the Rust workspace of the
slangcompiler: the CLI, the Slang frontend, the dialect binding and codegen. - Slang is the parser and binder, a git dependency pinned by
revinCargo.toml. - solx-llvm (submodule) is a fork of LLVM with the Sol and Yul MLIR dialects and an EVM target backend.
- solidity (submodule) is upstream solc, kept for its
test/libsolidity/semanticTests, which the tester runs.
Solidity → Slang (parse, bind) → Sol-dialect MLIR → Sol→Yul→Standard passes → LLVM IR → LLVM optimizer → EVM bytecode
| Crate | Purpose |
|---|---|
solx |
CLI entry point, the slang binary |
solx-core |
Pipeline orchestration |
solx-slang |
Lowers the Slang AST to Sol-dialect MLIR |
solx-mlir |
The Sol and Yul dialect binding over melior: values, places, types, blocks |
solx-codegen-evm |
LLVM IR to EVM bytecode: optimization and emission |
solx-standard-json |
solc-compatible JSON I/O protocol |
solx-utils |
Shared types: contract names, EVM versions, hashing, CBOR metadata |
solx-dev |
Developer tool: builds LLVM, runs project tests |
solx-tester |
Test runner over the REVM corpus |
solx-compiler-downloader |
Downloads and verifies compiler binaries |
solx-benchmark-converter |
Benchmark analysis and comparison |
A type has one inherent impl block, with public items before private ones.
solx-slang lowers the Slang AST to Sol-dialect MLIR through solx-mlir. The rules below are the design law of that frontend.
-
Ground truth is legacy solc:
solc --asm,--binand--storage-layoutdefine behavior. The compiler is never evidence about itself. -
LIT fixtures follow the compiler: one that stops matching a correct change is rewritten, and no emission code exists to keep a fixture passing. The semantic tests are followed: they come from solc, and the compiler changes to pass them.
-
Codegen does no validation. Slang owns every check on the program. The frontend lowers whatever Slang accepts and never re-implements a solc rule.
-
Emission has no error path: no
Result, no diagnostics. A construct not lowered yet isunimplemented!. Any other panic names the Slang guarantee that turned out broken. Input Slang accepts is never a panic site. -
Dispatch is decided up front. The handler for a construct is resolved and called. There is no try-this-then-that and no "not applicable" return value.
-
A file-level output such as
astis built from Slang alone, before the error check and codegen, so it is present even when compilation fails.
-
Slang is the single source of semantic truth. Types, selectors, signatures, layout, linearisation and name resolution come from its API and are never recomputed or approximated here, by the compiler or by the tester.
-
Type facts come from the dialect's own predicates, never from matching printed type text.
-
Codegen is one traversal. A definition is materialized the first time something names it, marked before its body is emitted, and nothing walks the program ahead of emission to collect or pre-register.
-
A segment's module defines what that segment reaches: the deploy module from the constructor, the runtime module from its externally visible functions and every function whose pointer the deploy code takes. No pass removes unused symbols.
-
Caches are memos filled on first use, living on the object that owns the fact. A cache that must be complete before a phase is a hidden pre-pass.
-
A fact the emitting context can derive from a relationship it already sees is derived there, never threaded down as a parameter.
-
Lowering is methods on the scope that owns the mutable state of that level: source unit, contract, function, assembly block. The AST node is input, the scope is the receiver, and each level's derived facts are computed once when the scope opens.
-
The lowering layer has no traits, macros, free functions or namespace types. One mechanism only.
-
Modules mirror what a construct is, not how Slang's grammar spells it. A group of files has one obvious reason to exist.
-
The dialect crate knows nothing about Slang, and vocabulary only the frontend uses lives in the frontend.
-
Every dialect op has exactly one home: the entity whose operation it is. Values cast and compare, places load and store, blocks branch. Nothing builds an op outside its home.
-
Solidity emits Sol ops, inline assembly emits Yul ops. A Sol value enters Yul only through the bridge ops, and emitting one dialect's operation with the other's op is wrong even when the result is equivalent.
-
Conversion has three separate layers: raw op emitters that do one thing, value-level policy that decides which to call, and expression-level helpers that lower an expression to a target type. Every site that needs a typed expression goes through the helpers.
- A domain lands complete over the types that exist when it lands. Later domains extend the earlier mechanisms for the types they introduce, so every mechanism is designed once as an extension point.
-
An op carries the first byte of the innermost node it is lowered from. A lowering that emits a node's own ops runs inside
at_node(node, …), and a Solidity body's implicit return insideat_node_end. A construct that emits no op of its own, such as a block or an expression statement, takes noat_node, so no position is resolved that no op carries. -
A construct that emits ops lands with its locations pinned in a
debug_location*.solfixture.
-
A LIT fixture pins op shape. A tester case under
tests/solidity/pins behavior. -
A fixture has one RUN line,
slang --emit-mlir=sol %s | FileCheck %s, and no prose. The CHECKs are the whole statement. A debug-location fixture runsslang --emit-mlir=sol --debug-info --debug-info-runtime %s | FileCheck %s --implicit-check-not='loc(unknown)'. -
One fixture per construct. A new case joins the fixture that owns its construct.
-
Every CHECK must fail when the input line it matches is deleted.
-
Every fixture source line is observed by some CHECK.
-
A base the fixture does not observe is
abstract. -
A file that only a fixture imports lives in
Inputs/, which lit skips, and joins the RUN line after%sas%S/Inputs/<file>.
-
A test input selects only the outputs the test asserts on.
-
An expected-output JSON fixture is compared as JSON, never after deserializing into the type it pins.
-
A test that can only fail together with another one is deleted.
-
One concept has one name across the frontend.
-
A lowering method is named after the node it lowers. The receiver already says which dialect.
-
An imported type that clashes with a local one takes the prefix of the crate it came from.
-
No contractions in Rust names:
identifier, notid;message, notmsg;context, notctx. Initialisms read as words stay short, such asabi,mlir,ods,url,api, and unit symbols such asms. FileCheck captures stay short, such asADDRandPTR. -
A doc says why the item exists or what is non-obvious, never its name again.
-
A
//comment carries only a constraint the code cannot express.
Build solx-dev, then LLVM with MLIR, then the compiler:
cargo build --release --bin solx-dev
./target/release/solx-dev llvm build --enable-utils --build-type RelWithDebInfo # target-llvm/target-final/
cargo build # target/debug/slang
cargo build --release # target/release/slangcargo test # unit and CLI tests
cargo clippy --all-targets
cargo build --release && cargo run-tester # the REVM corpus at -O M3B3 against target/release/slang
cargo run-tester --path tests/solidity/simple/default.sol # one testLIT runs the fixtures under solx-mlir/tests/lit/ against target/debug/slang:
export PATH="$PWD/target-llvm/target-final/bin:$PWD/target/debug:$PATH"
PYTHONPATH=solx-llvm/llvm/utils/lit python3 target-llvm/target-final/bin/llvm-lit solx-mlir/tests/lit/A PR body is one or two sentences saying what the PR delivers, with short bullets or a numbered list where they help.
It is forbidden to post low-level code changes, the process of how the work was done, or anything derivable from the PR diff.
The integration tests run on every PR. These labels switch on optional CI:
ci:sanitizerfor the address sanitizer testsci:integration-benchmark-fullto compare every compiler in the Foundry and Hardhat benchmarks, from the next push or re-runci:releasefor a dry run of the release pipelineci:sourcify-sweepfor the Sourcify sweep
A change to renovate.json is validated before pushing, with the checks CI repeats in its renovate-config-check job, at the Renovate version that job pins:
export RENOVATE_VERSION=$(sed -n 's/.*RENOVATE_VERSION: "\(.*\)"/\1/p' .github/workflows/test.yaml)
npx --yes --package "renovate@$RENOVATE_VERSION" -- renovate-config-validator renovate.json
LOG_LEVEL=debug npx --yes "renovate@$RENOVATE_VERSION" --platform=local --dry-run=fullThe dry run is what catches matchPackageNames silently missing a git-source cargo dependency, whose packageName is the git URL rather than the Cargo.toml key. Those are matched by matchDepNames, as the pinned-fork rule does for inkwell, melior, slang_solidity and web3.