-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][ODS] Allow operations to specify interfaces using the HasParent
trait constraint
#66196
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
base: main
Are you sure you want to change the base?
Conversation
... by emitting an operation name for interfaces. The name is only emitted for the parent interface (i.e. base interfaces are not considered). This change is needed by https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/OpDefinition.h#L1324C38-L1324C38 wherein _some_ name needs to be reported to the user. ... should interfaces be identified by `getOperationName` and not i.e. `getInterfaceName`? it's a possibility, but would obviously complicate code which wants to treat operation types and interface types as equals.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-core Changes... by emitting an operation name for interfaces. The name is only emitted for the parent interface (i.e. base interfaces are not considered).This change is needed by https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/OpDefinition.h#L1324C38-L1324C38 wherein some name needs to be reported to the user. ... should interfaces be identified by
|
HasParent
trait constraint
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.
Yeah I'm not sold on the interface name. Why does it do a check using a string name anyways. Shouldn't it use dyn_cast/isa? ODS can generate an error message directly
Just updated the PR with a reference to the location that relies on |
The URL is not immutable (the code can move or change), hence I had used a description that made the message more standalone. |
Makes sense - my apologies, did not see that you modified the PR message 🤦. |
No worries: I was just providing context in case you were wondering! |
So how do we want to solve this? change |
... by requiring that handshake ops are nested within an operation that inherits the `FineGrainedDataflowRegionOpInterface`. This is somewhat of a half-way solution, seeing as there isn't support for `HasParent` with an interface upstream. I've raised the issue and suggested a fix here llvm/llvm-project#66196 but we'll see how long that takes to resolve. Until then, added a `HasParentInterface` which does the same thing, albeit with a cryptic error message about which interface the parent op lacked (note: the whole issue here is that there isn't any name literal being generated for op interfaces). I'll be monitoring the upstream stuff, and changing this over until then. For now, the motivation for adding this into circt is to unblock me in using handshake outside of a `handshake.func` while still having a restriction on where handshake ops can be used - i.e. i don't want to completely lift the `HasParent` restriction - users should still explicitly opt-into the fact that "using handshake => handshake ops is in a fine-grained dataflow region".
... by requiring that handshake ops are nested within an operation that inherits the `FineGrainedDataflowRegionOpInterface`. This is somewhat of a half-way solution, seeing as there isn't support for `HasParent` with an interface upstream. I've raised the issue and suggested a fix here llvm/llvm-project#66196 but we'll see how long that takes to resolve. Until then, added a `HasParentInterface` which does the same thing, albeit with a cryptic error message about which interface the parent op lacked (note: the whole issue here is that there isn't any name literal being generated for op interfaces). I'll be monitoring the upstream stuff, and changing this over until then. For now, the motivation for adding this into circt is to unblock me in using handshake outside of a `handshake.func` while still having a restriction on where handshake ops can be used - i.e. i don't want to completely lift the `HasParent` restriction - users should still explicitly opt-into the fact that "using handshake => handshake ops is in a fine-grained dataflow region".
Why do you need a name comparison? I would just do an |
@Mogball : it's not for a name comparison, it's for diagnostics. The verifier code in the traits looks like:
|
…nc` (#6132) ... by requiring that handshake ops are nested within an operation that inherits the `FineGrainedDataflowRegionOpInterface`. This is somewhat of a half-way solution, seeing as there isn't support for `HasParent` with an interface upstream. I've raised the issue and suggested a fix here llvm/llvm-project#66196 but we'll see how long that takes to resolve. Until then, added a `HasParentInterface` which does the same thing, albeit with a cryptic error message about which interface the parent op lacked (note: the whole issue here is that there isn't any name literal being generated for op interfaces). I'll be monitoring the upstream stuff, and changing this over until then. For now, the motivation for adding this into circt is to unblock me in using handshake outside of a `handshake.func` while still having a restriction on where handshake ops can be used - i.e. i don't want to completely lift the `HasParent` restriction - users should still explicitly opt-into the fact that "using handshake => handshake ops is in a fine-grained dataflow region".
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.
Ah I see. My mistake. But still, having getOperationName
on an interface seems a little off. WDYT about adding a new trait called hasInterfaceParent
?
Sure, whatever can accomplish this pattern. The original idea of folding this into the |
3d318bb
to
4e1f546
Compare
This requires interfaces to expose a getOperationName(). The name is only emitted for the parent interface (i.e. base interfaces are not considered).
This change is needed by
https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/OpDefinition.h#L1325C41-L1325C41
wherein some name needs to be reported to the user.
should interfaces be identified by
getOperationName
and not i.e.getInterfaceName
? it's a possibility, but would obviously complicate code which wants to treat operation types and interface types as equals.