diff options
author | Twice <twice@apache.org> | 2025-10-13 11:56:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-13 11:56:57 +0800 |
commit | 06e2c78680d753d97b0cd6b7a86b4dbd0dbfb1e9 (patch) | |
tree | 53d302d38ae454d4daccb8d553da17cd269c1dab /llvm/lib/Support/DebugCounter.cpp | |
parent | 6785c4f2ff16b4453d1140d9ccbbf00a93d6542e (diff) | |
download | llvm-06e2c78680d753d97b0cd6b7a86b4dbd0dbfb1e9.zip llvm-06e2c78680d753d97b0cd6b7a86b4dbd0dbfb1e9.tar.gz llvm-06e2c78680d753d97b0cd6b7a86b4dbd0dbfb1e9.tar.bz2 |
[MLIR][Python] Pass OpView subclasses instead of Operation in rewrite patterns (#163080)
This is a follow-up PR for #162699.
Currently, in the function where we define rewrite patterns, the `op` we
receive is of type `ir.Operation` rather than a specific `OpView` type
(such as `arith.AddIOp`). This means we can’t conveniently access
certain parts of the operation — for example, we need to use
`op.operands[0]` instead of `op.lhs`. The following example code
illustrates this situation.
```python
def to_muli(op, rewriter):
# op is typed ir.Operation instead of arith.AddIOp
pass
patterns.add(arith.AddIOp, to_muli)
```
In this PR, we convert the operation to its corresponding `OpView`
subclass before invoking the rewrite pattern callback, making it much
easier to write patterns.
---------
Co-authored-by: Maksim Levental <maksim.levental@gmail.com>
Diffstat (limited to 'llvm/lib/Support/DebugCounter.cpp')
0 files changed, 0 insertions, 0 deletions