14 #ifndef MLIR_INTERFACES_CONTROLFLOWINTERFACES_H 15 #define MLIR_INTERFACES_CONTROLFLOWINTERFACES_H 20 class BranchOpInterface;
21 class RegionBranchOpInterface;
57 return producedOperandCount + forwardedOperands.
size();
70 return index < producedOperandCount;
79 return forwardedOperands[index - producedOperandCount];
89 "can't slice operands produced by the operation");
90 return forwardedOperands.
slice(subStart - producedOperandCount, subLen);
95 void erase(
unsigned subStart,
unsigned subLen = 1) {
97 "can't erase operands produced by the operation");
98 forwardedOperands.
erase(subStart - producedOperandCount, subLen);
109 "can't map operand produced by the operation");
112 (blockArgumentIndex - producedOperandCount);
118 unsigned producedOperandCount;
133 unsigned operandIndex,
Block *successor);
165 : region(region), inputs(regionInputs) {}
175 bool isParent()
const {
return region ==
nullptr; }
194 assert((!ub || ub >= lb) &&
"upper bound cannot be less than lower bound");
264 template <
typename ConcreteType>
267 static_assert(ConcreteType::template hasTrait<IsTerminator>(),
268 "expected operation to be a terminator");
269 static_assert(ConcreteType::template hasTrait<ZeroResults>(),
270 "expected operation to have zero results");
271 static_assert(ConcreteType::template hasTrait<ZeroSuccessors>(),
272 "expected operation to have zero successors");
285 #include "mlir/Interfaces/ControlFlowInterfaces.h.inc" 287 #endif // MLIR_INTERFACES_CONTROLFLOWINTERFACES_H void append(ValueRange valueRange)
Add new operands that are forwarded to the successor.
Include the generated interface declarations.
This class contains a list of basic blocks and a link to the parent operation it is attached to...
This class represents upper and lower bounds on the number of times a region of a RegionBranchOpInter...
static LogicalResult verifyTrait(Operation *op)
Optional< OperandRange > getRegionBranchSuccessorOperands(Operation *operation, Optional< unsigned > regionIndex)
Returns the read only operands that are passed to the region with the given regionIndex.
SuccessorOperands(MutableOperandRange forwardedOperands)
Constructs a SuccessorOperands with no produced operands that simply forwards operands to the success...
Operation is a basic unit of execution within MLIR.
RegionSuccessor(Optional< Operation::result_range > results={})
Initialize a successor that branches back to/out of the parent operation.
Block represents an ordered list of Operations.
unsigned getOperandIndex(unsigned blockArgumentIndex) const
Gets the index of the forwarded operand within the operation which maps to the block argument denoted...
bool empty() const
Returns true if there are no successor operands.
bool isRegionReturnLike(Operation *operation)
Returns true if the given operation is either annotated with the ReturnLike trait or implements the R...
void append(ValueRange values)
Append the given values to the range.
void erase(unsigned subStart, unsigned subLen=1)
Erase operands forwarded to the successor.
Value operator[](unsigned index) const
Returns the Value that is passed to the successors block argument denoted by index.
Optional< unsigned > getUpperBound() const
Return the upper bound.
static constexpr const bool value
Region * getSuccessor() const
Return the given region successor.
unsigned getLowerBound() const
Return the lower bound.
unsigned getBeginOperandIndex() const
Return the operand index of the first element of this range.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
This class represents an efficient way to signal success or failure.
void erase(unsigned subStart, unsigned subLen=1)
Erase the operands within the given sub-range.
unsigned size() const
Returns the amount of operands passed to the successor.
LogicalResult verifyTypesAlongControlFlowEdges(Operation *op)
Verify that types match along control flow edges described the given op.
Optional< MutableOperandRange > getMutableRegionBranchSuccessorOperands(Operation *operation, Optional< unsigned > regionIndex)
Returns the mutable operands that are passed to the region with the given regionIndex.
This class provides a mutable adaptor for a range of operands.
bool isOperandProduced(unsigned index) const
Returns true if the successor operand denoted by index is produced by the operation.
This class models how operands are forwarded to block arguments in control flow.
Optional< BlockArgument > getBranchSuccessorArgument(const SuccessorOperands &operands, unsigned operandIndex, Block *successor)
Return the BlockArgument corresponding to operand operandIndex in some successor if operandIndex is w...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
OperandRange getForwardedOperands() const
Get the range of operands that are simply forwarded to the successor.
Helper class for implementing traits.
This class represents a successor of a region.
MutableOperandRange slice(unsigned subStart, unsigned subLen, Optional< OperandSegment > segment=llvm::None) const
Slice this range into a sub range, with the additional operand segment.
unsigned size() const
Returns the current size of the range.
InvocationBounds(unsigned lb, Optional< unsigned > ub)
Create invocation bounds.
LogicalResult verifyBranchSuccessorOperands(Operation *op, unsigned succNo, const SuccessorOperands &operands)
Verify that the given operands match those of the given successor block.
bool isParent() const
Return true if the successor is the parent operation.
unsigned getProducedOperandCount() const
Returns the amount of operands that are produced internally by the operation.
static InvocationBounds getUnknown()
Returns the unknown invocation bounds, i.e., there is no information on how many times a region may b...
Region * getEnclosingRepetitiveRegion(Operation *op)
Return the first enclosing region of the given op that may be executed repetitively as per RegionBran...
This class implements the operand iterators for the Operation class.
ValueRange getSuccessorInputs() const
Return the inputs to the successor that are remapped by the exit values of the current region...
bool insideMutuallyExclusiveRegions(Operation *a, Operation *b)
Return true if a and b are in mutually exclusive regions as per RegionBranchOpInterface.
RegionSuccessor(Region *region, Block::BlockArgListType regionInputs={})
Initialize a successor that branches to another region of the parent operation.
This class provides an abstraction over the different types of ranges over Values.
MutableOperandRange slice(unsigned subStart, unsigned subLen) const
Get a slice of the operands forwarded to the successor.
This trait indicates that a terminator operation is "return-like".