[PATCH] D79829: [mlir][Affine] Introduce affine memory interfaces

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 03:45:29 PDT 2020


ftynse added a comment.

In D79829#2044547 <https://reviews.llvm.org/D79829#2044547>, @dcaballe wrote:

> > Interface methods are not visible because there is no inheritance from interface. Trait methods (referred to as default implementations) _are_ visible.
> >  An interface is like OOP interface in e.g. Java, it expects all classes that implement it to define the interface methods themselves. We have the possibility of providing a default implementation for them.
>
> I think the only remaining question for my understanding is why we need both `methodBody` and `defaultImplementation`. Wouldn't the latter suffice? I'm trying to think of a use case for the former that can't be implemented with the latter (other than having a default implementation without visibility in the concrete op).


I am afraid I don't have an answer for that. Generally, there is some redundancy between interfaces and traits that may be eventually reduced. There may be cases where you want to dispatch the interface function differently than the default approach (wrap/unwrap arguments, call different functions in different classes, etc.); this dispatch may be more expensive and you may not want to pay for it unless you use interfaces. That's the underlying idea of the concept approach: you don't get pay the virtual dispatch cost unless you need it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79829/new/

https://reviews.llvm.org/D79829





More information about the llvm-commits mailing list