llvm/mlir/include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h

//===- UnstructuredControlFlow.h - Op Interface Helpers ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_BUFFERIZATION_IR_UNSTRUCTUREDCONTROLFLOW_H_
#define MLIR_DIALECT_BUFFERIZATION_IR_UNSTRUCTUREDCONTROLFLOW_H_

#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"

//===----------------------------------------------------------------------===//
// Helpers for Unstructured Control Flow
//===----------------------------------------------------------------------===//

namespace mlir {
namespace bufferization {

namespace detail {
/// Return a list of operands that are forwarded to the given block argument.
/// I.e., find all predecessors of the block argument's owner and gather the
/// operands that are equivalent to the block argument.
SmallVector<OpOperand *> getCallerOpOperands(BlockArgument bbArg);
} // namespace detail

/// A template that provides a default implementation of `getAliasingOpOperands`
/// for ops that support unstructured control flow within their regions.
template <typename ConcreteModel, typename ConcreteOp>
struct OpWithUnstructuredControlFlowBufferizableOpInterfaceExternalModel
    : public BufferizableOpInterface::ExternalModel<ConcreteModel, ConcreteOp> {};

/// A template that provides a default implementation of `getAliasingValues`
/// for ops that implement the `BranchOpInterface`.
template <typename ConcreteModel, typename ConcreteOp>
struct BranchOpBufferizableOpInterfaceExternalModel
    : public BufferizableOpInterface::ExternalModel<ConcreteModel, ConcreteOp> {};

} // namespace bufferization
} // namespace mlir

#endif // MLIR_DIALECT_BUFFERIZATION_IR_UNSTRUCTUREDCONTROLFLOW_H_