MLIR  20.0.0git
BufferDeallocationOpInterfaceImpl.cpp
Go to the documentation of this file.
1 //===- BufferDeallocationOpInterfaceImpl.cpp ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
13 
14 using namespace mlir;
15 using namespace mlir::bufferization;
16 
17 namespace {
18 ///
19 struct GPUTerminatorOpInterface
20  : public BufferDeallocationOpInterface::ExternalModel<
21  GPUTerminatorOpInterface, gpu::TerminatorOp> {
22  FailureOr<Operation *> process(Operation *op, DeallocationState &state,
23  const DeallocationOptions &options) const {
24  SmallVector<Value> updatedOperandOwnerships;
26  state, op, {}, updatedOperandOwnerships);
27  }
28 };
29 
30 } // namespace
31 
33  DialectRegistry &registry) {
34  registry.addExtension(+[](MLIRContext *ctx, GPUDialect *dialect) {
35  gpu::TerminatorOp::attachInterface<GPUTerminatorOpInterface>(*ctx);
36  });
37 }
static llvm::ManagedStatic< PassManagerOptions > options
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.
Definition: MLIRContext.h:60
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
This class collects all the state that we need to perform the buffer deallocation pass with associate...
FailureOr< Operation * > insertDeallocOpForReturnLike(DeallocationState &state, Operation *op, ValueRange operands, SmallVectorImpl< Value > &updatedOperandOwnerships)
Insert a bufferization.dealloc operation right before op which has to be a terminator without any suc...
void registerBufferDeallocationOpInterfaceExternalModels(DialectRegistry &registry)
Include the generated interface declarations.
Options for BufferDeallocationOpInterface-based buffer deallocation.