ArrayRef<int64_t> strides, int64_t offset,
ConversionPatternRewriter &rewriter) const;
+ /// Returns if the givem memref type is supported.
+ bool isSupportedMemRefType(MemRefType type) const;
+
Value getDataPtr(Location loc, MemRefType type, Value memRefDesc,
ValueRange indices,
ConversionPatternRewriter &rewriter) const;
offset, rewriter);
}
+// Check if the MemRefType `type` is supported by the lowering. We currently
+// only support memrefs with identity maps.
+bool ConvertToLLVMPattern::isSupportedMemRefType(MemRefType type) const {
+ if (!typeConverter.convertType(type.getElementType()))
+ return false;
+ return type.getAffineMaps().empty() ||
+ llvm::all_of(type.getAffineMaps(),
+ [](AffineMap map) { return map.isIdentity(); });
+}
+
Type ConvertToLLVMPattern::getElementPtrType(MemRefType type) const {
auto elementType = type.getElementType();
- auto structElementType = typeConverter.convertType(elementType);
- return structElementType.cast<LLVM::LLVMType>().getPointerTo(
- type.getMemorySpace());
+ auto structElementType = unwrap(typeConverter.convertType(elementType));
+ return structElementType.getPointerTo(type.getMemorySpace());
}
void ConvertToLLVMPattern::getMemRefDescriptorSizes(
}
};
-// Check if the MemRefType `type` is supported by the lowering. We currently
-// only support memrefs with identity maps.
-static bool isSupportedMemRefType(MemRefType type) {
- return type.getAffineMaps().empty() ||
- llvm::all_of(type.getAffineMaps(),
- [](AffineMap map) { return map.isIdentity(); });
-}
-
/// Lowering for AllocOp and AllocaOp.
struct AllocLikeOpLowering : public ConvertToLLVMPattern {
using ConvertToLLVMPattern::createIndexConstant;
template <typename Derived>
struct LoadStoreOpLowering : public ConvertOpToLLVMPattern<Derived> {
using ConvertOpToLLVMPattern<Derived>::ConvertOpToLLVMPattern;
+ using ConvertOpToLLVMPattern<Derived>::isSupportedMemRefType;
using Base = LoadStoreOpLowering<Derived>;
LogicalResult match(Operation *op) const override {