[mlir][Sol] Support struct types in abi.encode/abi.decode lowering#44
Merged
vladimirradosavljevic merged 4 commits intomainfrom Mar 23, 2026
Merged
[mlir][Sol] Support struct types in abi.encode/abi.decode lowering#44vladimirradosavljevic merged 4 commits intomainfrom
vladimirradosavljevic merged 4 commits intomainfrom
Conversation
…::SolBase Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
…tType This adds memberSlotOffsets and memberByteOffsets to StructType, which are used to compute the storage slot and byte offset of each struct member. Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
… structs Previously, we didn't take into account that smaller types can be packed into same slots, so fix this by taking that into account. Also, add storageSlotCount parameter for StructType. Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
There was a problem hiding this comment.
Pull request overview
This PR extends the Solidity dialect lowering pipeline to support sol.struct types in ABI tuple encoding/decoding, including storage-layout-aware handling for packed members.
Changes:
- Added shared Sol-dialect storage layout helpers (
getStorageSlotCount,canBePacked,getStorageByteSize) and precomputed storage member offsets forsol.struct. - Implemented struct-aware ABI tuple encoding/decoding in
EVMUtil(calldata/memory/storage), and centralized packed-storage load cleanup in a new helper. - Updated Sol→Standard conversion code to use the new Sol-dialect storage-layout helpers instead of
evm::*variants.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| mlir/lib/Dialect/Sol/SolBase.cpp | Adds storage layout helpers and computes per-member storage slot/byte offsets for storage structs. |
| mlir/include/mlir/Dialect/Sol/SolBase.td | Extends sol.struct type parameters to carry derived storage layout metadata and adds a custom builder. |
| mlir/include/mlir/Dialect/Sol/Sol.h | Exposes storage-layout helper APIs from the Sol dialect. |
| mlir/lib/Conversion/SolToStandard/EVMUtil.cpp | Implements struct ABI encode/decode, calldata reading guards for some dynamic members, and packed storage cleanup helper. |
| mlir/include/mlir/Conversion/SolToStandard/EVMUtil.h | Removes old storage-layout declarations and adds genCleanupPackedStorageValue. |
| mlir/lib/Conversion/SolToStandard/SolToYul.cpp | Updates storage layout queries to sol::* and switches struct field offset computation to use precomputed offsets. |
| mlir/lib/Conversion/SolToStandard/TypeConverter.cpp | Switches packing query from evm::canBePacked to sol::canBePacked. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
solx-solidity PR.