-
Notifications
You must be signed in to change notification settings - Fork 248
refactor: create 1-1 mapping between operations and AsmOp decorators #2455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
refactor: create 1-1 mapping between operations and AsmOp decorators #2455
Conversation
huitseeker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! This change needs a test that goes through the assembly path to verify the 1-1 mapping.
Existing tests in core/src/mast/tests.rs manually construct decorators like vec![(2, decorator_id)], which doesn't test that set_instruction_cycle_count() creates the mapping.
I would suggest a test in this PR in crates/assembly/src/tests.rs that:
- Assembles MASM code with multi-cycle instructions
- Verifies all operations in a multi-cycle range share the same DecoratorId
- Uses
MastForest::all_decorators()(which should be gated under thetestingfeature, andmiden-coreshould be imported as adev-dependencyofmiden-assemblyactivating that feature to get access to it)
huitseeker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the test!
core/src/mast/mod.rs
Outdated
| // ================================================================================================ | ||
|
|
||
| #[cfg(test)] | ||
| #[cfg(feature = "testing")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using #[cfg(any(test, feature = "testing"))] instead of just #[cfg(feature = "testing")].
The current approach means that unit tests in the core crate itself cannot use all_decorators() when running cargo test without explicitly enabling the testing feature.
The suggested alternative is the standard pattern for test helpers that need to be shared across crates while still being available for local unit tests.
|
Thanks for the review! So i fixed test naming and also fixed fmt |
|
@PivasDesant - seems like build/tests are currently failing on this PR. Would you be able to fix this? |
Implements 1-1 mapping for operations and AsmOp decorators (#2446)
Before this change, only the first operation was linked to an AsmOp when an instruction compiled to multiple operations. Now all operations are linked.
The implementation adds decorator links for all operations in
set_instruction_cycle_count(). This also simplifiesget_assembly_op()since we can check index equality directly instead of doing range checks.No data duplication since we reuse the same
DecoratorIdfor all operations covered by an AsmOp.