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

Diego Caballero via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 18:31:17 PDT 2020


dcaballe added a comment.

I tried to change all the interface methods to have a default implementation but I'm hitting some problems. After reading again the documentation about interfaces, it's not clear to me what is the difference between providing a `methodBody` or a `defaultImplementation`. I had to dig into the generated code to have a bit better understanding but still, I couldn't make it work. I uploaded the patch with both approaches: methods in `AffineWriteOpInterface` has a `methodBody`, methods in `AffineReadOpInterface` has a `defaultImplementation`.

The problem that I'm hitting with `methodBody` is that the **interface methods are not visible from the concrete op**. For example, I cannot call `getMemRef()` using an `AffineStoreOp` object. Looking at the generated code, I see that the method `getMemRef()` is autogenerated for the class `AffineWriteOpInterface`, which is implemented like this:

  Value AffineReadOpInterface::getMemRef() {
        return getImpl()->getMemRef(getOperation());
    }

However, there is no `getMemRef()` declared/defined in the same way for `AffineStoreOp` or `AffineVectorStoreOp`. Shouldn't they have similar autogenerated code? Am I missing something?

For `defaultImplementation`, I followed the doc example so interface methods are defined like this:

  InterfaceMethod<
    /*desc=*/[{ Returns the memref operand to read from. }],
    /*retTy=*/"Value",
    /*methodName=*/"getMemRef",
    /*args=*/(ins),
    /*methodBody*/[{}],
    /*defaultImplementation=*/ [{
      ConcreteOp op = cast<ConcreteOp>(getOperation());
      return op.getOperand(op.getMemRefOperandIndex());
   }]
  >,

However, the compiler complains about invoking `getOperation()` without object:

  error: cannot call member function ‘mlir::Operation* mlir::Op<ConcreteT
  ype, Traits>::getOperation() [with ConcreteType = mlir::AffineReadOpInterface; Traits = {}]’ without object

I get a bit lost in the internal details but `ConcreteType = mlir::AffineReadOpInterface` looks suspicious. Shouldn't it be `AffineLoadOp`/`AffineVectorLoadOp`?

I would appreciate some help, @ftynse @mehdi_amini @rriddle.

Thanks,
Diego


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