9#ifndef MLIR_DIALECT_BUFFERIZATION_IR_UNSTRUCTUREDCONTROLFLOW_H_
10#define MLIR_DIALECT_BUFFERIZATION_IR_UNSTRUCTUREDCONTROLFLOW_H_
31template <
typename ConcreteModel,
typename ConcreteOp>
33 :
public BufferizableOpInterface::ExternalModel<ConcreteModel, ConcreteOp> {
35 FailureOr<BufferLikeType>
37 const BufferizationState &state,
42 if (isa<OpResult>(value))
43 return bufferization::detail::defaultGetBufferType(value,
options, state,
51 auto tensorType = cast<TensorType>(value.
getType());
58 if (llvm::is_contained(invocationStack, opOperand->get()))
64 dyn_cast<BaseMemRefType>(opOperand->get().getType())) {
66 callerType = memrefType;
68 FailureOr<BufferLikeType> maybeCallerType =
69 bufferization::getBufferType(opOperand->get(),
options, state,
71 if (failed(maybeCallerType))
73 assert(isa<BaseMemRefType>(*maybeCallerType) &&
"expected memref type");
74 callerType = cast<BaseMemRefType>(*maybeCallerType);
79 bufferType = callerType;
83 if (bufferType == callerType)
90 if (
auto rankedTensorType = dyn_cast<RankedTensorType>(tensorType)) {
92 "expected ranked memrefs");
94 rankedTensorType.getShape()}) &&
95 "expected same shape");
98 "expected unranked memrefs");
103 return op->
emitOpError(
"incoming operands of block argument have "
104 "inconsistent memory spaces");
106 bufferType = getMemRefTypeWithFullyDynamicLayout(
111 return op->
emitOpError(
"could not infer buffer type of block argument");
113 return cast<BufferLikeType>(bufferType);
120 AliasingOpOperandList
127 AliasingOpOperandList
result;
130 {opOperand, BufferRelation::Equivalent,
false});
138template <
typename ConcreteModel,
typename ConcreteOp>
140 :
public BufferizableOpInterface::ExternalModel<ConcreteModel, ConcreteOp> {
144 auto branchOp = cast<BranchOpInterface>(op);
148 for (
const auto &it : llvm::enumerate(op->
getSuccessors())) {
149 Block *block = it.value();
152 "produced operands not supported");
160 bool matchingDestination = operandNumber >= firstOperandIndex &&
161 operandNumber < lastOperandIndex;
164 if (!matchingDestination)
168 block->
getArgument(operandNumber - firstOperandIndex);
170 {bbArg, BufferRelation::Equivalent,
false});
static llvm::ManagedStatic< PassManagerOptions > options
Base class for generic analysis states.
This class provides a shared interface for ranked and unranked memref types.
ArrayRef< int64_t > getShape() const
Returns the shape of this memref type.
Attribute getMemorySpace() const
Returns the memory space in which data referred to by this memref resides.
bool hasRank() const
Returns if this type is ranked, i.e. it has a known number of dimensions.
This class represents an argument of a Block.
Block * getOwner() const
Returns the block that owns this argument.
Block represents an ordered list of Operations.
BlockArgument getArgument(unsigned i)
Operation * getParentOp()
Returns the closest surrounding operation that contains this block.
This class represents an operand of an operation.
unsigned getOperandNumber()
Return which operand this is in the OpOperand list of the Operation.
unsigned getBeginOperandIndex() const
Return the operand index of the first element of this range.
Operation is the basic unit of execution within MLIR.
SuccessorRange getSuccessors()
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class models how operands are forwarded to block arguments in control flow.
unsigned getProducedOperandCount() const
Returns the amount of operands that are produced internally by the operation.
OperandRange getForwardedOperands() const
Get the range of operands that are simply forwarded to the successor.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
SmallVector< OpOperand * > getCallerOpOperands(BlockArgument bbArg)
Return a list of operands that are forwarded to the given block argument.
Include the generated interface declarations.
A template that provides a default implementation of getAliasingValues for ops that implement the Bra...
AliasingValueList getAliasingValues(Operation *op, OpOperand &opOperand, const AnalysisState &state) const
A template that provides a default implementation of getAliasingOpOperands for ops that support unstr...
AliasingOpOperandList getAliasingBranchOpOperands(Operation *op, BlockArgument bbArg, const AnalysisState &state) const
Assuming that bbArg is a block argument of a block that belongs to the given op, return all OpOperand...
FailureOr< BufferLikeType > getBufferType(Operation *op, Value value, const BufferizationOptions &options, const BufferizationState &state, SmallVector< Value > &invocationStack) const