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,
50 BufferLikeType bufferType;
57 if (llvm::is_contained(invocationStack, opOperand->get()))
61 BufferLikeType callerType;
63 dyn_cast<BufferLikeType>(opOperand->get().getType())) {
65 callerType = bufferType;
67 FailureOr<BufferLikeType> maybeCallerType =
68 bufferization::getBufferType(opOperand->get(),
options, state,
70 if (failed(maybeCallerType))
72 callerType = *maybeCallerType;
77 bufferType = callerType;
81 if (bufferType == callerType)
87 if (
auto tensorType = dyn_cast<TensorLikeType>(value.
getType())) {
89 assert(succeeded(tensorType.verifyCompatibleBufferType(bufferType,
91 "incompatible buffer type");
92 assert(succeeded(tensorType.verifyCompatibleBufferType(callerType,
94 "incompatible caller type");
98 auto reconciled =
options.reconcileBufferTypeMismatchFn(
99 bufferType, callerType,
options);
100 if (failed(reconciled)) {
101 return op->
emitError(
"incoming operands of block argument have "
102 "incompatible buffer types");
105 bufferType = *reconciled;
109 return op->
emitOpError(
"could not infer buffer type of block argument");
118 AliasingOpOperandList
125 AliasingOpOperandList
result;
128 {opOperand, BufferRelation::Equivalent,
false});
136template <
typename ConcreteModel,
typename ConcreteOp>
138 :
public BufferizableOpInterface::ExternalModel<ConcreteModel, ConcreteOp> {
142 auto branchOp = cast<BranchOpInterface>(op);
146 for (
const auto &it : llvm::enumerate(op->
getSuccessors())) {
147 Block *block = it.value();
150 "produced operands not supported");
158 bool matchingDestination = operandNumber >= firstOperandIndex &&
159 operandNumber < lastOperandIndex;
162 if (!matchingDestination)
166 block->
getArgument(operandNumber - firstOperandIndex);
168 {bbArg, BufferRelation::Equivalent,
false});
p<< " : "<< getMemRefType()<< ", "<< getType();}static LogicalResult verifyVectorMemoryOp(Operation *op, MemRefType memrefType, VectorType vectorType) { if(memrefType.getElementType() !=vectorType.getElementType()) return op-> emitOpError("requires memref and vector types of the same elemental type")
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.
static llvm::ManagedStatic< PassManagerOptions > options
Base class for generic analysis states.
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() const
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.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
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