1*a45e58afSMatthias Springer //===- BufferViewFlowOpInterfaceImpl.cpp - Buffer View Flow Analysis ------===// 2*a45e58afSMatthias Springer // 3*a45e58afSMatthias Springer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*a45e58afSMatthias Springer // See https://llvm.org/LICENSE.txt for license information. 5*a45e58afSMatthias Springer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*a45e58afSMatthias Springer // 7*a45e58afSMatthias Springer //===----------------------------------------------------------------------===// 8*a45e58afSMatthias Springer 9*a45e58afSMatthias Springer #include "mlir/Dialect/Arith/Transforms/BufferViewFlowOpInterfaceImpl.h" 10*a45e58afSMatthias Springer 11*a45e58afSMatthias Springer #include "mlir/Dialect/Arith/IR/Arith.h" 12*a45e58afSMatthias Springer #include "mlir/Dialect/Bufferization/IR/BufferViewFlowOpInterface.h" 13*a45e58afSMatthias Springer 14*a45e58afSMatthias Springer using namespace mlir; 15*a45e58afSMatthias Springer using namespace mlir::bufferization; 16*a45e58afSMatthias Springer 17*a45e58afSMatthias Springer namespace mlir { 18*a45e58afSMatthias Springer namespace arith { 19*a45e58afSMatthias Springer namespace { 20*a45e58afSMatthias Springer 21*a45e58afSMatthias Springer struct SelectOpInterface 22*a45e58afSMatthias Springer : public BufferViewFlowOpInterface::ExternalModel<SelectOpInterface, 23*a45e58afSMatthias Springer SelectOp> { 24*a45e58afSMatthias Springer void populateDependenciesmlir::arith::__anon4a0ef3550111::SelectOpInterface25*a45e58afSMatthias Springer populateDependencies(Operation *op, 26*a45e58afSMatthias Springer RegisterDependenciesFn registerDependenciesFn) const { 27*a45e58afSMatthias Springer auto selectOp = cast<SelectOp>(op); 28*a45e58afSMatthias Springer 29*a45e58afSMatthias Springer // Either one of the true/false value may be selected at runtime. 30*a45e58afSMatthias Springer registerDependenciesFn(selectOp.getTrueValue(), selectOp.getResult()); 31*a45e58afSMatthias Springer registerDependenciesFn(selectOp.getFalseValue(), selectOp.getResult()); 32*a45e58afSMatthias Springer } 33*a45e58afSMatthias Springer }; 34*a45e58afSMatthias Springer 35*a45e58afSMatthias Springer } // namespace 36*a45e58afSMatthias Springer } // namespace arith 37*a45e58afSMatthias Springer } // namespace mlir 38*a45e58afSMatthias Springer registerBufferViewFlowOpInterfaceExternalModels(DialectRegistry & registry)39*a45e58afSMatthias Springervoid arith::registerBufferViewFlowOpInterfaceExternalModels( 40*a45e58afSMatthias Springer DialectRegistry ®istry) { 41*a45e58afSMatthias Springer registry.addExtension(+[](MLIRContext *ctx, arith::ArithDialect *dialect) { 42*a45e58afSMatthias Springer SelectOp::attachInterface<SelectOpInterface>(*ctx); 43*a45e58afSMatthias Springer }); 44*a45e58afSMatthias Springer } 45