Skip to content

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

Merged

Conversation

ttjost
Copy link

@ttjost ttjost commented Jun 19, 2023

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.

@ttjost ttjost requested review from martin-luecke and ljfitz June 19, 2023 16:19
Copy link

@martin-luecke martin-luecke 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 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

@ttjost ttjost requested review from martin-luecke and ljfitz June 21, 2023 08:28
Copy link

@martin-luecke martin-luecke 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 for the changes. This looks good now!
I only have two tiny nits

@ttjost ttjost merged commit 9be5cb0 into feature/fused-ops Jun 22, 2023
@mgehre-amd mgehre-amd deleted the tiagot.FXML-2223.FXML-2293.PDLL_array_dict_attrs branch September 3, 2024 07:21
mgehre-amd pushed a commit that referenced this pull request Sep 20, 2024
)

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