-
Notifications
You must be signed in to change notification settings - Fork 3
Feat: add support for Dictionary and Array attributes in PDLL rewrite sections. #56
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
Feat: add support for Dictionary and Array attributes in PDLL rewrite sections. #56
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.
Thank you for looking at this! I added a few thoughts.
I think it would make sense to take some time to figure out how to make the PDLL language server type checking and code completion aware of this. I think this should not be that complicated. There are many references to code_complete tokens flying around in the PDLL parser.
Currently there are only tests for MLIR code generation. I think we also need tests for the PDLL parser, i.e. here
- add parser tests
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.
Thank you for the changes. This looks good now!
I only have two tiny nits
) Currently, process of replacing bitwise operations consisting of `LSR`/`LSL` with `And` is performed by `DAGCombiner`. However, in certain cases, the `AND` generated by this process can be removed. Consider following case: ``` lsr x8, x8, #56 and x8, x8, #0xfc ldr w0, [x2, x8] ret ``` In this case, we can remove the `AND` by changing the target of `LDR` to `[X2, X8, LSL #2]` and right-shifting amount change to 56 to 58. after changed: ``` lsr x8, x8, #58 ldr w0, [x2, x8, lsl #2] ret ``` This patch checks to see if the `SHIFTING` + `AND` operation on load target can be optimized and optimizes it if it can.
This PR introduces support for the creation of Array and Dictionary attributes in PDLL rewrite sections.
The solution instructs PDLL parser to generate calls to
apply_native_rewrite
operation that can be used to integrate C++ code into PDLL. For that reason, users of this functionality are required to provide C++ implementations of these functions, as well as link and register them in passes that process PDLL files.Functions that need to be implemented are:
createDictionaryAttr(PatternRewriter &rewriter)
: creates and returns an attribute that represents a dictionary.addEntryToDictionaryAttr (PatternRewriter &rewriter, Attribute attr, Attribute attrName, Attribute attrEntry)
: add an entry to the dictionary and returns the new dictionary.createArrayAttr(mlir::PatternRewriter &rewriter)
: creates and returns an attribute that represents an array.addElemToArrayAttr(PatternRewriter &rewriter, Attribute attr, Attribute element)
: add an element attribute to the array and returns the new array.