Skip to content

[mlir][Sol] Support struct types in abi.encode/abi.decode lowering#44

Merged
vladimirradosavljevic merged 4 commits intomainfrom
mlir_abi_structs_support
Mar 23, 2026
Merged

[mlir][Sol] Support struct types in abi.encode/abi.decode lowering#44
vladimirradosavljevic merged 4 commits intomainfrom
mlir_abi_structs_support

Conversation

@vladimirradosavljevic
Copy link
Copy Markdown
Contributor

@vladimirradosavljevic vladimirradosavljevic commented Mar 20, 2026

…::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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for sol.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.

Copy link
Copy Markdown
Contributor

@abinavpp abinavpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@vladimirradosavljevic vladimirradosavljevic merged commit aaa4060 into main Mar 23, 2026
15 of 19 checks passed
@vladimirradosavljevic vladimirradosavljevic deleted the mlir_abi_structs_support branch March 23, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants