feat(slang): lower additional EVM intrinsics#376
Merged
hedgar2017 merged 1 commit intomainfrom Apr 28, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Slang → MLIR lowering layer to support additional EVM “context/intrinsic” member accesses, including new block.* globals and address.* member intrinsics that require evaluating the base expression.
Changes:
- Plumbs full
MemberAccessExpressionintoemit_member_accessso the operand can be evaluated for address-based intrinsics. - Lowers
address.balanceandaddress.codehashto Sol-dialect ops taking the computed address operand. - Adds Sol-dialect lowering for
block.blobbasefee,block.difficulty, andblock.prevrandao.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| solx-slang/src/ast/contract/function/expression/mod.rs | Updates member-access emission to pass the full MemberAccessExpression into the call emitter. |
| solx-slang/src/ast/contract/function/expression/call/mod.rs | Extends emit_member_access to lower additional block.* and address.* built-ins to Sol-dialect operations. |
1755289 to
7f982d2
Compare
abinavpp
reviewed
Apr 28, 2026
e58b05c to
7b96711
Compare
7b96711 to
b41a9a0
Compare
b41a9a0 to
08b7e54
Compare
Wire up `block.blobbasefee`, `block.difficulty`, `block.prevrandao`, `address.balance`, and `address.codehash` member accesses to their Sol dialect ops. The address-base intrinsics evaluate the operand expression and emit `sol.balance` / `sol.code_hash` with the resulting address value. Built-in dispatch is routed through slang's `BuiltIn` binder for both member access and call sites. The lit test for EVM context is extended with the four new intrinsics; codehash coverage waits on bytes32 lowering.
08b7e54 to
7e3db46
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wires up five additional EVM intrinsics in the Slang/MLIR adapter: three zero-arg block-namespace globals (
block.blobbasefee,block.difficulty,block.prevrandao) and two runtime-base address intrinsics (address.balance,address.codehash). The address-base path is plumbed by passing the fullMemberAccessExpressiontoemit_member_access, so the operand can be evaluated and threaded throughsol.balance/sol.code_hash.The built-in dispatch (
assert,require, EVM intrinsics) is extracted fromcall/mod.rsinto a newcall/built_in.rsmodule, keepingcall/mod.rsas a thin dispatcher. The two address-base intrinsic arms share a privateemit_address_base_intrinsichelper that takes a closure to construct the operation.Newly passing tests
tests/solidity/simple/context/difficulty.sol(all)tests/solidity/simple/context/prevrandao.sol(all)Out of scope
address.code— depends on broader bytes/string lowering not yet in place.address.codehashSolidity-level test — blocked onbytes32lowering (panics intype_conversion.rs:45).msg.sig— needs a!sol.fixedbytes<4>type which has no FFI constructor insolx-mliryet.gasleft()— function-call dispatch path (separate from member access).