13 #ifndef MLIR_TRANSFORMS_INLININGUTILS_H
14 #define MLIR_TRANSFORMS_INLININGUTILS_H
25 class CallableOpInterface;
26 class CallOpInterface;
58 bool wouldBeCloned)
const {
105 llvm_unreachable(
"must implement handleTerminator in the case of multiple "
120 "must implement handleTerminator in the case of one inlined block");
172 bool wouldBeCloned)
const;
208 LogicalResult
inlineRegion(InlinerInterface &interface, Region *src,
209 Operation *inlinePoint, IRMapping &mapper,
210 ValueRange resultsToReplace,
211 TypeRange regionResultTypes,
212 std::optional<Location> inlineLoc = std::nullopt,
213 bool shouldCloneInlinedRegion =
true);
214 LogicalResult
inlineRegion(InlinerInterface &interface, Region *src,
216 IRMapping &mapper, ValueRange resultsToReplace,
217 TypeRange regionResultTypes,
218 std::optional<Location> inlineLoc = std::nullopt,
219 bool shouldCloneInlinedRegion =
true);
224 LogicalResult
inlineRegion(InlinerInterface &interface, Region *src,
225 Operation *inlinePoint, ValueRange inlinedOperands,
226 ValueRange resultsToReplace,
227 std::optional<Location> inlineLoc = std::nullopt,
228 bool shouldCloneInlinedRegion =
true);
229 LogicalResult
inlineRegion(InlinerInterface &interface, Region *src,
231 ValueRange inlinedOperands,
232 ValueRange resultsToReplace,
233 std::optional<Location> inlineLoc = std::nullopt,
234 bool shouldCloneInlinedRegion =
true);
242 LogicalResult
inlineCall(InlinerInterface &interface, CallOpInterface call,
243 CallableOpInterface callable, Region *src,
244 bool shouldCloneInlinedRegion =
true);
Block represents an ordered list of Operations.
OpListType::iterator iterator
This is the interface that must be implemented by the dialects of operations to be inlined.
virtual bool isLegalToInline(Operation *call, Operation *callable, bool wouldBeCloned) const
Returns true if the given operation 'callable', that implements the 'CallableOpInterface',...
virtual Operation * materializeCallConversion(OpBuilder &builder, Value input, Type resultType, Location conversionLoc) const
Attempt to materialize a conversion for a type mismatch between a call from this dialect,...
virtual bool shouldAnalyzeRecursively(Operation *op) const
This hook is invoked on an operation that contains regions.
virtual bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned, IRMapping &valueMapping) const
Returns true if the given region 'src' can be inlined into the region 'dest' that is attached to an o...
DialectInlinerInterface(Dialect *dialect)
virtual void processInlinedCallBlocks(Operation *call, iterator_range< Region::iterator > inlinedBlocks) const
Process a set of blocks that have been inlined for a call.
virtual void handleTerminator(Operation *op, ArrayRef< Value > valuesToReplace) const
Handle the given inlined terminator by replacing it with a new operation as necessary.
virtual void handleTerminator(Operation *op, Block *newDest) const
Handle the given inlined terminator by replacing it with a new operation as necessary.
virtual bool isLegalToInline(Operation *op, Region *dest, bool wouldBeCloned, IRMapping &valueMapping) const
Returns true if the given operation 'op', that is registered to this dialect, can be inlined into the...
A collection of dialect interfaces within a context, for a given concrete interface type.
DialectInterfaceCollection< DialectInlinerInterface > Base
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
This is a utility class for mapping one set of IR entities to another.
This interface provides the hooks into the inlining interface.
virtual bool shouldAnalyzeRecursively(Operation *op) const
virtual void handleTerminator(Operation *op, Block *newDest) const
Handle the given inlined terminator by replacing it with a new operation as necessary.
virtual void processInlinedCallBlocks(Operation *call, iterator_range< Region::iterator > inlinedBlocks) const
virtual void processInlinedBlocks(iterator_range< Region::iterator > inlinedBlocks)
Process a set of blocks that have been inlined.
virtual bool isLegalToInline(Operation *call, Operation *callable, bool wouldBeCloned) const
These hooks mirror the hooks for the DialectInlinerInterface, with default implementations that call ...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
The base class used for all derived interface types.
Include the generated interface declarations.
LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, IRMapping &mapper, ValueRange resultsToReplace, TypeRange regionResultTypes, std::optional< Location > inlineLoc=std::nullopt, bool shouldCloneInlinedRegion=true)
This function inlines a region, 'src', into another.
LogicalResult inlineCall(InlinerInterface &interface, CallOpInterface call, CallableOpInterface callable, Region *src, bool shouldCloneInlinedRegion=true)
This function inlines a given region, 'src', of a callable operation, 'callable', into the location d...