20struct DefaultAllocationInterface
21 :
public bufferization::AllocationOpInterface::ExternalModel<
22 DefaultAllocationInterface, memref::AllocOp> {
23 static std::optional<Operation *> buildDealloc(OpBuilder &builder,
25 return memref::DeallocOp::create(builder, alloc.
getLoc(), alloc)
28 static std::optional<Value> buildClone(OpBuilder &builder, Value alloc) {
29 return bufferization::CloneOp::create(builder, alloc.
getLoc(), alloc)
32 static ::mlir::HoistingKind getHoistingKind() {
33 return HoistingKind::Loop | HoistingKind::Block;
35 static ::std::optional<::mlir::Operation *>
36 buildPromotedAlloc(OpBuilder &builder, Value alloc) {
38 memref::AllocaOp allocaOp = memref::AllocaOp::create(
39 builder, allocOp.getLoc(), allocOp.getType(), allocOp.getDynamicSizes(),
40 allocOp.getSymbolOperands(), allocOp.getAlignmentAttr());
41 allocaOp->setDiscardableAttrs(allocOp->getDiscardableAttrDictionary());
42 return allocaOp.getOperation();
46struct DefaultAutomaticAllocationHoistingInterface
47 :
public bufferization::AllocationOpInterface::ExternalModel<
48 DefaultAutomaticAllocationHoistingInterface, memref::AllocaOp> {
49 static ::mlir::HoistingKind getHoistingKind() {
return HoistingKind::Loop; }
52struct DefaultReallocationInterface
53 :
public bufferization::AllocationOpInterface::ExternalModel<
54 DefaultAllocationInterface, memref::ReallocOp> {
55 static std::optional<Operation *> buildDealloc(OpBuilder &builder,
57 return memref::DeallocOp::create(builder, realloc.
getLoc(), realloc)
66 memref::AllocOp::attachInterface<DefaultAllocationInterface>(*ctx);
67 memref::AllocaOp::attachInterface<
68 DefaultAutomaticAllocationHoistingInterface>(*ctx);
69 memref::ReallocOp::attachInterface<DefaultReallocationInterface>(*ctx);
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
Location getLoc() const
Return the location of this value.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
void registerAllocationOpInterfaceExternalModels(DialectRegistry ®istry)
Include the generated interface declarations.