[llvm-branch-commits] [mlir] 19a0d0a - [mlir] Rename ConvertToLLVMPattern::isSupportedMemRefType() to isConvertibleAndHasIdentityMaps().

Christian Sigg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 23 03:27:55 PST 2020


Author: Christian Sigg
Date: 2020-12-23T12:23:29+01:00
New Revision: 19a0d0a40ce991836d930ecf8614ad21a1c3c32c

URL: https://github.com/llvm/llvm-project/commit/19a0d0a40ce991836d930ecf8614ad21a1c3c32c
DIFF: https://github.com/llvm/llvm-project/commit/19a0d0a40ce991836d930ecf8614ad21a1c3c32c.diff

LOG: [mlir] Rename ConvertToLLVMPattern::isSupportedMemRefType() to isConvertibleAndHasIdentityMaps().

Reviewed By: ftynse, herhut

Differential Revision: https://reviews.llvm.org/D93752

Added: 
    

Modified: 
    mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
    mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
    mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index 63547db56e6d..d5c1e923fab9 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -512,8 +512,9 @@ class ConvertToLLVMPattern : public ConversionPattern {
                              ValueRange indices,
                              ConversionPatternRewriter &rewriter) const;
 
-  /// Returns if the givem memref type is supported.
-  bool isSupportedMemRefType(MemRefType type) const;
+  /// Returns if the given memref has identity maps and the element type is
+  /// convertible to LLVM.
+  bool isConvertibleAndHasIdentityMaps(MemRefType type) const;
 
   /// Returns the type of a pointer to an element of the memref.
   Type getElementPtrType(MemRefType type) const;

diff  --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
index bbb2bf1e04ff..d35aa0346f74 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
+++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
@@ -369,7 +369,7 @@ LogicalResult ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   MemRefType memRefType = allocOp.getType();
 
   if (failed(areAllLLVMTypes(allocOp, operands, rewriter)) ||
-      !isSupportedMemRefType(memRefType) ||
+      !isConvertibleAndHasIdentityMaps(memRefType) ||
       failed(isAsyncWithOneDependency(rewriter, allocOp)))
     return failure();
 
@@ -670,7 +670,7 @@ LogicalResult ConvertMemcpyOpToGpuRuntimeCallPattern::matchAndRewrite(
   auto memRefType = memcpyOp.src().getType().cast<MemRefType>();
 
   if (failed(areAllLLVMTypes(memcpyOp, operands, rewriter)) ||
-      !isSupportedMemRefType(memRefType) ||
+      !isConvertibleAndHasIdentityMaps(memRefType) ||
       failed(isAsyncWithOneDependency(rewriter, memcpyOp)))
     return failure();
 

diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 97e763fc08c4..f4d1df81565b 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1087,7 +1087,8 @@ Value ConvertToLLVMPattern::getStridedElementPtr(
 
 // Check if the MemRefType `type` is supported by the lowering. We currently
 // only support memrefs with identity maps.
-bool ConvertToLLVMPattern::isSupportedMemRefType(MemRefType type) const {
+bool ConvertToLLVMPattern::isConvertibleAndHasIdentityMaps(
+    MemRefType type) const {
   if (!typeConverter->convertType(type.getElementType()))
     return false;
   return type.getAffineMaps().empty() ||
@@ -1105,7 +1106,7 @@ void ConvertToLLVMPattern::getMemRefDescriptorSizes(
     Location loc, MemRefType memRefType, ArrayRef<Value> dynamicSizes,
     ConversionPatternRewriter &rewriter, SmallVectorImpl<Value> &sizes,
     SmallVectorImpl<Value> &strides, Value &sizeBytes) const {
-  assert(isSupportedMemRefType(memRefType) &&
+  assert(isConvertibleAndHasIdentityMaps(memRefType) &&
          "layout maps must have been normalized away");
 
   sizes.reserve(memRefType.getRank());
@@ -1977,7 +1978,7 @@ struct AllocLikeOpLowering : public ConvertToLLVMPattern {
 
   LogicalResult match(Operation *op) const override {
     MemRefType memRefType = getMemRefResultType(op);
-    return success(isSupportedMemRefType(memRefType));
+    return success(isConvertibleAndHasIdentityMaps(memRefType));
   }
 
   // An `alloc` is converted into a definition of a memref descriptor value and
@@ -2411,7 +2412,7 @@ struct GlobalMemrefOpLowering : public ConvertOpToLLVMPattern<GlobalMemrefOp> {
   matchAndRewrite(GlobalMemrefOp global, ArrayRef<Value> operands,
                   ConversionPatternRewriter &rewriter) const override {
     MemRefType type = global.type().cast<MemRefType>();
-    if (!isSupportedMemRefType(type))
+    if (!isConvertibleAndHasIdentityMaps(type))
       return failure();
 
     LLVM::LLVMType arrayTy =
@@ -3031,12 +3032,12 @@ struct RankOpLowering : public ConvertOpToLLVMPattern<RankOp> {
 template <typename Derived>
 struct LoadStoreOpLowering : public ConvertOpToLLVMPattern<Derived> {
   using ConvertOpToLLVMPattern<Derived>::ConvertOpToLLVMPattern;
-  using ConvertOpToLLVMPattern<Derived>::isSupportedMemRefType;
+  using ConvertOpToLLVMPattern<Derived>::isConvertibleAndHasIdentityMaps;
   using Base = LoadStoreOpLowering<Derived>;
 
   LogicalResult match(Derived op) const override {
     MemRefType type = op.getMemRefType();
-    return isSupportedMemRefType(type) ? success() : failure();
+    return isConvertibleAndHasIdentityMaps(type) ? success() : failure();
   }
 };
 


        


More information about the llvm-branch-commits mailing list