Skip to content

Commit 4d750db

Browse files
[Python] Add regression check for OpOperand owner having wrong type (#9139)
Add an integration test to ensure the `owner` property of `OpOperand` returns a concrete op subclass, not a plain old `OpView`.
1 parent b809bf8 commit 4d750db

File tree

1 file changed

+23
-0
lines changed
  • integration_test/Bindings/Python

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# REQUIRES: bindings_python
2+
# RUN: %PYTHON% %s
3+
4+
import circt
5+
from circt import ir
6+
from circt.dialects import arith
7+
8+
# Ensure that the `OpOperand`s returned as the `uses` list of a value have a
9+
# concrete subclass of `OpView`, not just `OpView` itself. This was a regression
10+
# that happened upstream, where you could no longer use
11+
# `isinstance(use.owner, AddIOp)` to check whether a user of a value is a
12+
# specific op.
13+
with ir.Context() as ctx, ir.Location.unknown() as loc:
14+
circt.register_dialects(ctx)
15+
module = ir.Module.parse("""
16+
%0 = arith.constant 0 : i8
17+
%1 = arith.addi %0, %0 : i8
18+
""")
19+
zero, add = list(module.body)
20+
use = list(zero.result.uses)[0]
21+
assert use.owner == add
22+
assert isinstance(add, arith.AddIOp)
23+
assert isinstance(use.owner, arith.AddIOp)

0 commit comments

Comments
 (0)