diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h --- a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_INTERFACES_AFFINEMEMORYOPINTERFACES_H_ -#define MLIR_INTERFACES_AFFINEMEMORYOPINTERFACES_H_ +#ifndef MLIR_DIALECT_AFFINE_IR_AFFINEMEMORYOPDIALECT_H_ +#define MLIR_DIALECT_AFFINE_IR_AFFINEMEMORYOPDIALECT_H_ #include "mlir/IR/AffineMap.h" #include "mlir/IR/OpDefinition.h" @@ -21,4 +21,4 @@ #include "mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h.inc" } // namespace mlir -#endif // MLIR_INTERFACES_AFFINEMEMORYOPINTERFACES_H_ +#endif // MLIR_DIALECT_AFFINE_IR_AFFINEMEMORYOPDIALECT_H_ diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td --- a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_AFFINEMEMORYOPINTERFACES -#define MLIR_AFFINEMEMORYOPINTERFACES +#ifndef AFFINEMEMORYOPINTERFACES +#define AFFINEMEMORYOPINTERFACES include "mlir/IR/OpBase.td" @@ -23,7 +23,7 @@ let methods = [ InterfaceMethod< - /*desc=*/[{ Returns the memref operand to read from. }], + /*desc=*/"Returns the memref operand to read from.", /*retTy=*/"Value", /*methodName=*/"getMemRef", /*args=*/(ins), @@ -34,7 +34,7 @@ }] >, InterfaceMethod< - /*desc=*/[{ Returns the type of the memref operand. }], + /*desc=*/"Returns the type of the memref operand.", /*retTy=*/"MemRefType", /*methodName=*/"getMemRefType", /*args=*/(ins), @@ -45,7 +45,7 @@ }] >, InterfaceMethod< - /*desc=*/[{ Returns affine map operands. }], + /*desc=*/"Returns affine map operands.", /*retTy=*/"Operation::operand_range", /*methodName=*/"getMapOperands", /*args=*/(ins), @@ -56,8 +56,9 @@ }] >, InterfaceMethod< - /*desc=*/[{ Returns the affine map used to index the memref for this - operation. }], + /*desc=*/[{ + Returns the affine map used to index the memref for this operation. + }], /*retTy=*/"AffineMap", /*methodName=*/"getAffineMap", /*args=*/(ins), @@ -78,7 +79,7 @@ let methods = [ InterfaceMethod< - /*desc=*/[{ Returns the memref operand to write to. }], + /*desc=*/"Returns the memref operand to write to.", /*retTy=*/"Value", /*methodName=*/"getMemRef", /*args=*/(ins), @@ -89,7 +90,7 @@ }] >, InterfaceMethod< - /*desc=*/[{ Returns the type of the memref operand. }], + /*desc=*/"Returns the type of the memref operand.", /*retTy=*/"MemRefType", /*methodName=*/"getMemRefType", /*args=*/(ins), @@ -100,7 +101,7 @@ }] >, InterfaceMethod< - /*desc=*/[{ Returns affine map operands. }], + /*desc=*/"Returns affine map operands.", /*retTy=*/"Operation::operand_range", /*methodName=*/"getMapOperands", /*args=*/(ins), @@ -111,8 +112,9 @@ }] >, InterfaceMethod< - /*desc=*/[{ Returns the affine map used to index the memref for this - operation. }], + /*desc=*/[{ + Returns the affine map used to index the memref for this operation. + }], /*retTy=*/"AffineMap", /*methodName=*/"getAffineMap", /*args=*/(ins), @@ -125,4 +127,4 @@ ]; } -#endif // MLIR_AFFINEMEMORYOPINTERFACES +#endif // AFFINEMEMORYOPINTERFACES diff --git a/mlir/include/mlir/Dialect/Affine/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Affine/IR/CMakeLists.txt --- a/mlir/include/mlir/Dialect/Affine/IR/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/Affine/IR/CMakeLists.txt @@ -1,10 +1,5 @@ add_mlir_dialect(AffineOps affine) add_mlir_doc(AffineOps -gen-op-doc AffineOps Dialects/) -set(LLVM_TARGET_DEFINITIONS AffineMemoryOpInterfaces.td) -mlir_tablegen(AffineMemoryOpInterfaces.h.inc -gen-op-interface-decls) -mlir_tablegen(AffineMemoryOpInterfaces.cpp.inc -gen-op-interface-defs) -add_public_tablegen_target(MLIRAffineMemoryOpInterfacesIncGen) -add_dependencies(mlir-generic-headers MLIRAffineMemoryOpInterfacesIncGen) - +add_mlir_interface(AffineMemoryOpInterfaces) add_dependencies(MLIRAffineOpsIncGen MLIRAffineMemoryOpInterfacesIncGen) diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -660,12 +660,11 @@ void MemRefAccess::getAccessMap(AffineValueMap *accessMap) const { // Get affine map from AffineLoad/Store. AffineMap map; - if (auto loadOp = dyn_cast(opInst)) { + if (auto loadOp = dyn_cast(opInst)) map = loadOp.getAffineMap(); - } else { - auto storeOp = cast(opInst); - map = storeOp.getAffineMap(); - } + else + map = cast(opInst).getAffineMap(); + SmallVector operands(indices.begin(), indices.end()); fullyComposeAffineMapAndOperands(&map, &operands); map = simplifyAffineMap(map); diff --git a/mlir/lib/Dialect/Affine/IR/AffineMemoryOpInterfaces.cpp b/mlir/lib/Dialect/Affine/IR/AffineMemoryOpInterfaces.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineMemoryOpInterfaces.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineMemoryOpInterfaces.cpp @@ -1,4 +1,4 @@ -//===- AffineMemoryOpInterfaces.cpp - Loop-like operations in MLIR --------===// +//===- AffineMemoryOpInterfaces.cpp ---------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information.