mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-25 06:40:18 +00:00
[MLIR] Fix standard -> LLVM conversion to fail for unsupported memref element type.
- Move isSupportedMemRefType() to ConvertToLLVMPatterns and check if the memref element type is supported there. Differential Revision: https://reviews.llvm.org/D91374
This commit is contained in:
parent
c2bccd66f6
commit
5883c4b470
@ -522,6 +522,9 @@ protected:
|
||||
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;
|
||||
|
@ -1094,11 +1094,20 @@ Value ConvertToLLVMPattern::getDataPtr(
|
||||
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(
|
||||
@ -1912,14 +1921,6 @@ struct ConstantOpLowering : public ConvertOpToLLVMPattern<ConstantOp> {
|
||||
}
|
||||
};
|
||||
|
||||
// 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;
|
||||
@ -3070,6 +3071,7 @@ struct RankOpLowering : public ConvertOpToLLVMPattern<RankOp> {
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user