Remove verify from OperationBuilder and SameOperandsAndResultType verification implementation#3
Open
lima-limon-inc wants to merge 24 commits intonextfrom
Open
Remove verify from OperationBuilder and SameOperandsAndResultType verification implementation#3lima-limon-inc wants to merge 24 commits intonextfrom
verify from OperationBuilder and SameOperandsAndResultType verification implementation#3lima-limon-inc wants to merge 24 commits intonextfrom
Conversation
SameTypeOperands implementationSameOperandsAndResultType implementation
ac061f1 to
8dc03a9
Compare
lima-limon-inc
commented
May 14, 2025
6fc9bea to
5959688
Compare
SameOperandsAndResultType implementationverify from op builder + SameOperandsAndResultType implementation
verify from op builder + SameOperandsAndResultType implementationverify from OperationBuilder + SameOperandsAndResultType implementation
verify from OperationBuilder + SameOperandsAndResultType implementationverify from OperationBuilder and SameOperandsAndResultType verification implementation
…t is fixed. Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
…alect Dialect Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com> Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com> Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
…explicit dependency Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
…rently comma separated) Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
…on which matches both patterns Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
e007d01 to
4baa815
Compare
Author
|
Just Rebased |
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
igamigo
approved these changes
May 20, 2025
| /// Op expects all operands and results to be of the same type | ||
| /// Op expects all operands and results to be of the same type. | ||
| /// NOTE: Operations that implements this trait must also explicitely implement | ||
| /// [`SameTypeOperands`]. This can be achieved by using the "traits" filed in the [#operation] |
| parent_info: Option<&PipelineParentInfo>, | ||
| ) -> Result<(), Report> { | ||
|
|
||
| if verify { |
Collaborator
There was a problem hiding this comment.
Would be great if this were an enum instead of a bool but it was there from before so it should be fine to leave it as-is.
| ) | ||
| .with_secondary_label( | ||
| value.span(), | ||
| "which differs from this value" |
Collaborator
There was a problem hiding this comment.
nit: Should this be something more like the following:
Suggested change
| "which differs from this value" | |
| "which differs from this value's type" |
Author
There was a problem hiding this comment.
Fair point!. I tried to replicate the structure/text present in the original verifier here: https://github.com/0xMiden/compiler/blob/f0ff05aca81e9dc579899223d2f19bb7200fbffd/hir/src/ir/traits/types.rs#L40-L61.
But I do think that it is clearer with your suggestion.
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
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.
Closes # issue nm
The issue states that currently
Operation::verifyis called inside theOperationBuilderwhich is called before operations are added to blocks, which could lead failure in operation verification. Because of this,SameTypeOperands' verification function had been commented out.This PR removes the call to
Operation::verifyfrom theOperationBuilderand moves it to the beggining ofPassManager::run.Operation::verifyis already called inside thePassManager::run(more precisely, inside theOpToOpPassAdaptor::run_pipeline), however an earlierverifycall was added to "compensate" the removal and assureOperationintegrity before applying passes. Now, thePassMangeris responsible forOperationintegrity verification, which is done before passes are applied and after each pass applies its modifications.With the call to
verifyin theOperationBuildernow removed,SameTypeOperands' verification function was re-enabled and so was its test (derived_op_verifier_test).Additionally, an implementation for
SameOperandsAndResultType's verification function was added (which was marked here as a TODO-item). Following the comment's requirements,SameTypeOperandsrequired as a super-trait.To support this, the
derive!macro was expanded to support super-traits. The macro supports an arbitrary amount of traits; but it is important to note that the traits must be comma separated instead of the usual "+" separated format. As far as I am aware, it is not possible to use "+" as a separator inside amacro_rules!context.With the super-trait now added, operations that implemented
SameOperandsAndResultTypebut did not implementSameTypeOperandswere updated to now explicitely implement both. This was done explicitely in order to replicate Rust's#[derive]macro's behavior of explicitely declaring all derive traits.Finally, a unit test was added to test
SameOperandsAndResultType's verify function. For this, a test operationInvalidOpsWithReturnwas added and registered in the test dialect.Side note: I tried to keep the
SameOperandsAndResultType's doc comment relatively short in order for it to show up in its entirety when a compilation error shows up, it is currently displayed like so: