forked from OSchip/llvm-project
[mlir] Fix bad rebase landed in acb69f3b7c
.
Differential Revision: https://reviews.llvm.org/D92265
This commit is contained in:
parent
acb69f3b7c
commit
e9e45b3887
|
@ -177,7 +177,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LogicalResult
|
LogicalResult
|
||||||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
matchAndRewrite(gpu::AllocOp allocOp, ArrayRef<Value> operands,
|
||||||
ConversionPatternRewriter &rewriter) const override;
|
ConversionPatternRewriter &rewriter) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LogicalResult
|
LogicalResult
|
||||||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
matchAndRewrite(gpu::DeallocOp deallocOp, ArrayRef<Value> operands,
|
||||||
ConversionPatternRewriter &rewriter) const override;
|
ConversionPatternRewriter &rewriter) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -343,18 +343,16 @@ LogicalResult ConvertHostRegisterOpToGpuRuntimeCallPattern::matchAndRewrite(
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicalResult ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
|
LogicalResult ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
|
||||||
Operation *op, ArrayRef<Value> operands,
|
gpu::AllocOp allocOp, ArrayRef<Value> operands,
|
||||||
ConversionPatternRewriter &rewriter) const {
|
ConversionPatternRewriter &rewriter) const {
|
||||||
auto allocOp = cast<gpu::AllocOp>(op);
|
|
||||||
MemRefType memRefType = allocOp.getType();
|
MemRefType memRefType = allocOp.getType();
|
||||||
|
|
||||||
if (failed(areAllLLVMTypes(op, operands, rewriter)) ||
|
if (failed(areAllLLVMTypes(allocOp, operands, rewriter)) ||
|
||||||
!isSupportedMemRefType(memRefType) ||
|
!isSupportedMemRefType(memRefType) ||
|
||||||
failed(
|
failed(isAsyncWithOneDependency(rewriter, allocOp)))
|
||||||
isAsyncWithOneDependency(rewriter, cast<gpu::AsyncOpInterface>(op))))
|
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
auto loc = op->getLoc();
|
auto loc = allocOp.getLoc();
|
||||||
|
|
||||||
// Get shape of the memref as values: static sizes are constant
|
// Get shape of the memref as values: static sizes are constant
|
||||||
// values and dynamic sizes are passed to 'alloc' as operands.
|
// values and dynamic sizes are passed to 'alloc' as operands.
|
||||||
|
@ -367,7 +365,8 @@ LogicalResult ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
|
||||||
// Allocate the underlying buffer and store a pointer to it in the MemRef
|
// Allocate the underlying buffer and store a pointer to it in the MemRef
|
||||||
// descriptor.
|
// descriptor.
|
||||||
Type elementPtrType = this->getElementPtrType(memRefType);
|
Type elementPtrType = this->getElementPtrType(memRefType);
|
||||||
auto adaptor = gpu::AllocOpAdaptor(operands, op->getAttrDictionary());
|
auto adaptor = gpu::AllocOpAdaptor(
|
||||||
|
operands, allocOp.getOperation()->getAttrDictionary());
|
||||||
auto stream = adaptor.asyncDependencies().front();
|
auto stream = adaptor.asyncDependencies().front();
|
||||||
Value allocatedPtr =
|
Value allocatedPtr =
|
||||||
allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult(0);
|
allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult(0);
|
||||||
|
@ -381,29 +380,29 @@ LogicalResult ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
|
||||||
auto memRefDescriptor = this->createMemRefDescriptor(
|
auto memRefDescriptor = this->createMemRefDescriptor(
|
||||||
loc, memRefType, allocatedPtr, alignedPtr, shape, strides, rewriter);
|
loc, memRefType, allocatedPtr, alignedPtr, shape, strides, rewriter);
|
||||||
|
|
||||||
rewriter.replaceOp(op, {memRefDescriptor, stream});
|
rewriter.replaceOp(allocOp, {memRefDescriptor, stream});
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicalResult ConvertDeallocOpToGpuRuntimeCallPattern::matchAndRewrite(
|
LogicalResult ConvertDeallocOpToGpuRuntimeCallPattern::matchAndRewrite(
|
||||||
Operation *op, ArrayRef<Value> operands,
|
gpu::DeallocOp deallocOp, ArrayRef<Value> operands,
|
||||||
ConversionPatternRewriter &rewriter) const {
|
ConversionPatternRewriter &rewriter) const {
|
||||||
if (failed(areAllLLVMTypes(op, operands, rewriter)) ||
|
if (failed(areAllLLVMTypes(deallocOp, operands, rewriter)) ||
|
||||||
failed(
|
failed(isAsyncWithOneDependency(rewriter, deallocOp)))
|
||||||
isAsyncWithOneDependency(rewriter, cast<gpu::AsyncOpInterface>(op))))
|
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
Location loc = op->getLoc();
|
Location loc = deallocOp.getLoc();
|
||||||
|
|
||||||
auto adaptor = gpu::DeallocOpAdaptor(operands, op->getAttrDictionary());
|
auto adaptor = gpu::DeallocOpAdaptor(
|
||||||
|
operands, deallocOp.getOperation()->getAttrDictionary());
|
||||||
Value pointer =
|
Value pointer =
|
||||||
MemRefDescriptor(adaptor.memref()).allocatedPtr(rewriter, loc);
|
MemRefDescriptor(adaptor.memref()).allocatedPtr(rewriter, loc);
|
||||||
auto casted = rewriter.create<LLVM::BitcastOp>(loc, llvmPointerType, pointer);
|
auto casted = rewriter.create<LLVM::BitcastOp>(loc, llvmPointerType, pointer);
|
||||||
Value stream = adaptor.asyncDependencies().front();
|
Value stream = adaptor.asyncDependencies().front();
|
||||||
deallocCallBuilder.create(loc, rewriter, {casted, stream});
|
deallocCallBuilder.create(loc, rewriter, {casted, stream});
|
||||||
|
|
||||||
rewriter.replaceOp(op, {stream});
|
rewriter.replaceOp(deallocOp, {stream});
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue