-
Notifications
You must be signed in to change notification settings - Fork 73
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
core: add functional-type directive #3517
base: main
Are you sure you want to change the base?
Conversation
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.
Very very nice
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3517 +/- ##
==========================================
+ Coverage 90.38% 90.39% +0.01%
==========================================
Files 466 466
Lines 58583 58709 +126
Branches 5585 5592 +7
==========================================
+ Hits 52948 53068 +120
+ Misses 4206 4205 -1
- Partials 1429 1436 +7 ☔ View full report in Codecov by Sentry. |
c8bc6f7
to
940bc1a
Compare
I've added an extra test to this. This also has given a way to actually trigger |
pos_start = parser.pos | ||
if s := self._set_using_variadic_index( | ||
state.operand_types, "operand types", (parser.parse_type(),) | ||
): | ||
parser.raise_error(s, at_position=pos_start, end_position=parser.pos) |
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.
should these then be in a separate PR? With a separate test to demonstrate the impact of the change?
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.
Maybe, though I'm not quite sure how to test them, as the functional-type
directive is the only thing that actually uses these functions
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.
I have an idea, will cook something up
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.
Now separated
83b2fa4
to
aa4e259
Compare
I've stacked this on #3553 , separating out the changes mentioned in the comment above |
Reworks the way 'parse_single_type' works for operands/results directives, reusing the infrastructure introduced for 'parse_many_types'. This now allows 'parse_single_type' to work when there are variadic operands, as demonstrated by the new tests. The new tests manually make a `FormatProgram`, as the format program parser will never generate such a program. This currently makes no difference, as these functions are never called, but it will be important for the functional-type directive (#3517), as it allows a type like: ```mlir (i32, i32) -> i32 ``` to be parsed, even if the results of the operation is a variadic (the functional type directive calls 'parse_single_type' when the results are not wrapped in parentheses).
Adds the functional-type directive, which takes two typeable directives as input.
The key difficulty here was dealing with the results, which are usually surrounded by parentheses but don't have to be if there is exactly one result.
Still a draft as this needs more tests, also stacked on #3516.