39 auto newOp = rewriter.
create<IfOp>(loc, convertedResultTypes,
40 op.getCondition(),
true);
49 newOp.getThenRegion().end());
51 newOp.getElseRegion().end());
53 rewriter.
replaceOp(op, newOp->getResults(), resultMapping);
79 auto newOp = rewriter.
create<WhileOp>(loc, convertedResultTypes,
80 adaptor.getFlatOperands());
84 std::array<OneToNTypeMapping, 2> blockMappings = {operandMapping,
86 for (
unsigned int i : {0u, 1u}) {
87 Region *region = &op.getRegion(i);
93 Region &dstRegion = newOp.getRegion(i);
97 rewriter.
replaceOp(op, newOp->getResults(), resultMapping);
110 if (!adaptor.getOperandMapping().hasNonIdentityConversion())
115 op, [&] { op->setOperands(adaptor.getFlatOperands()); });
130 if (!adaptor.getOperandMapping().hasNonIdentityConversion())
135 op, [&] { op->setOperands(adaptor.getFlatOperands()); });
161 if (lbs.size() != 1 || ubs.size() != 1 || steps.size() != 1)
163 forOp,
"index operands converted to multiple values");
167 Region *region = &forOp.getRegion();
171 ValueRange newInits = adaptor.getFlatOperands().drop_front(3);
173 rewriter.
create<ForOp>(loc, lbs[0], ubs[0], steps[0], newInits);
189 Region &dstRegion = newOp.getBodyRegion();
192 rewriter.
replaceOp(forOp, newOp.getResults(), resultMapping);
211 >(typeConverter,
patterns.getContext());
LogicalResult matchAndRewrite(ConditionOp op, OpAdaptor adaptor, OneToNPatternRewriter &rewriter) const override
Overload that derived classes have to override for their op type.
LogicalResult matchAndRewrite(ForOp forOp, OpAdaptor adaptor, OneToNPatternRewriter &rewriter) const override
Overload that derived classes have to override for their op type.
LogicalResult matchAndRewrite(IfOp op, OpAdaptor adaptor, OneToNPatternRewriter &rewriter) const override
Overload that derived classes have to override for their op type.
LogicalResult matchAndRewrite(WhileOp op, OpAdaptor adaptor, OneToNPatternRewriter &rewriter) const override
Overload that derived classes have to override for their op type.
LogicalResult matchAndRewrite(YieldOp op, OpAdaptor adaptor, OneToNPatternRewriter &rewriter) const override
Overload that derived classes have to override for their op type.
Block represents an ordered list of Operations.
ValueTypeRange< BlockArgListType > getArgumentTypes()
Return a range containing the types of the arguments for this block.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class is a wrapper around OneToNConversionPattern for matching against instances of a particular...
Specialization of PatternRewriter that OneToNConversionPatterns use.
Block * applySignatureConversion(Block *block, OneToNTypeMapping &argumentConversion)
Applies the given argument conversion to the given block.
void replaceOp(Operation *op, ValueRange newValues, const OneToNTypeMapping &resultMapping)
Replaces the results of the operation with the specified list of values mapped back to the original t...
Stores a 1:N mapping of types and provides several useful accessors.
TypeRange getConvertedTypes(unsigned originalTypeNo) const
Returns the list of types that corresponds to the original type at the given index.
bool hasNonIdentityConversion() const
Returns true iff at least one type conversion maps an input type to a type that is different from its...
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
void setAttrs(DictionaryAttr newAttrs)
Set the attributes from a dictionary on this operation.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
virtual void eraseBlock(Block *block)
This method erases all operations in a block.
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
void inlineRegionBefore(Region ®ion, Region &parent, Region::iterator before)
Move the blocks that belong to "region" before the given position in another region "parent".
This class provides an abstraction over the various different ranges of value types.
This class provides an abstraction over the different types of ranges over Values.
void populateSCFStructuralOneToNTypeConversions(const TypeConverter &typeConverter, RewritePatternSet &patterns)
Populates the provided pattern set with patterns that do 1:N type conversions on (some) SCF ops.
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns