MLIR  15.0.0git
Public Member Functions | List of all members
mlir::DialectInlinerInterface Class Reference

This is the interface that must be implemented by the dialects of operations to be inlined. More...

#include "mlir/Transforms/InliningUtils.h"

+ Inheritance diagram for mlir::DialectInlinerInterface:
+ Collaboration diagram for mlir::DialectInlinerInterface:

Public Member Functions

 DialectInlinerInterface (Dialect *dialect)
 
virtual bool isLegalToInline (Operation *call, Operation *callable, bool wouldBeCloned) const
 Returns true if the given operation 'callable', that implements the 'CallableOpInterface', can be inlined into the position given call operation 'call', that is registered to the current dialect and implements the CallOpInterface. More...
 
virtual bool isLegalToInline (Region *dest, Region *src, bool wouldBeCloned, BlockAndValueMapping &valueMapping) const
 Returns true if the given region 'src' can be inlined into the region 'dest' that is attached to an operation registered to the current dialect. More...
 
virtual bool isLegalToInline (Operation *op, Region *dest, bool wouldBeCloned, BlockAndValueMapping &valueMapping) const
 Returns true if the given operation 'op', that is registered to this dialect, can be inlined into the given region, false otherwise. More...
 
virtual bool shouldAnalyzeRecursively (Operation *op) const
 This hook is invoked on an operation that contains regions. More...
 
virtual void handleTerminator (Operation *op, Block *newDest) const
 Handle the given inlined terminator by replacing it with a new operation as necessary. More...
 
virtual void handleTerminator (Operation *op, ArrayRef< Value > valuesToReplace) const
 Handle the given inlined terminator by replacing it with a new operation as necessary. More...
 
virtual OperationmaterializeCallConversion (OpBuilder &builder, Value input, Type resultType, Location conversionLoc) const
 Attempt to materialize a conversion for a type mismatch between a call from this dialect, and a callable region. More...
 
virtual void processInlinedCallBlocks (Operation *call, iterator_range< Region::iterator > inlinedBlocks) const
 Process a set of blocks that have been inlined for a call. More...
 

Additional Inherited Members

- Public Types inherited from mlir::detail::DialectInterfaceBase< ConcreteType, BaseT >
using Base = DialectInterfaceBase< ConcreteType, BaseT >
 
- Static Public Member Functions inherited from mlir::detail::DialectInterfaceBase< ConcreteType, BaseT >
static TypeID getInterfaceID ()
 Get a unique id for the derived interface type. More...
 
- Protected Member Functions inherited from mlir::detail::DialectInterfaceBase< ConcreteType, BaseT >
 DialectInterfaceBase (Dialect *dialect)
 

Detailed Description

This is the interface that must be implemented by the dialects of operations to be inlined.

This interface should only handle the operations of the given dialect.

Definition at line 40 of file InliningUtils.h.

Constructor & Destructor Documentation

◆ DialectInlinerInterface()

mlir::DialectInlinerInterface::DialectInlinerInterface ( Dialect dialect)
inline

Definition at line 43 of file InliningUtils.h.

Referenced by containsReturn(), eachHasOnlyOneOfTypes(), and remainsLegalAfterInline().

Member Function Documentation

◆ handleTerminator() [1/2]

virtual void mlir::DialectInlinerInterface::handleTerminator ( Operation op,
Block newDest 
) const
inlinevirtual

Handle the given inlined terminator by replacing it with a new operation as necessary.

This overload is called when the inlined region has more than one block. The 'newDest' block represents the new final branching destination of blocks within this region, i.e. operations that release control to the parent operation will likely now branch to this block. Its block arguments correspond to any values that need to be replaced by terminators within the inlined region.

Definition at line 103 of file InliningUtils.h.

Referenced by mlir::InlinerInterface::processInlinedBlocks().

◆ handleTerminator() [2/2]

virtual void mlir::DialectInlinerInterface::handleTerminator ( Operation op,
ArrayRef< Value valuesToReplace 
) const
inlinevirtual

Handle the given inlined terminator by replacing it with a new operation as necessary.

This overload is called when the inlined region only contains one block. 'valuesToReplace' contains the previously returned values of the call site before inlining. These values must be replaced by this callback if they had any users (for example for traditional function calls, these are directly replaced with the operands of the return operation). The given 'op' will be removed by the caller, after this function has been called.

Definition at line 116 of file InliningUtils.h.

◆ isLegalToInline() [1/3]

virtual bool mlir::DialectInlinerInterface::isLegalToInline ( Operation call,
Operation callable,
bool  wouldBeCloned 
) const
inlinevirtual

Returns true if the given operation 'callable', that implements the 'CallableOpInterface', can be inlined into the position given call operation 'call', that is registered to the current dialect and implements the CallOpInterface.

'wouldBeCloned' is set to true if the region of the given 'callable' is set to be cloned during the inlining process, or false if the region is set to be moved in-place(i.e. no duplicates would be created).

Definition at line 56 of file InliningUtils.h.

Referenced by mlir::InlinerInterface::processInlinedBlocks().

◆ isLegalToInline() [2/3]

virtual bool mlir::DialectInlinerInterface::isLegalToInline ( Region dest,
Region src,
bool  wouldBeCloned,
BlockAndValueMapping valueMapping 
) const
inlinevirtual

Returns true if the given region 'src' can be inlined into the region 'dest' that is attached to an operation registered to the current dialect.

'wouldBeCloned' is set to true if the given 'src' region is set to be cloned during the inlining process, or false if the region is set to be moved in-place(i.e. no duplicates would be created). 'valueMapping' contains any remapped values from within the 'src' region. This can be used to examine what values will replace entry arguments into the 'src' region for example.

Definition at line 69 of file InliningUtils.h.

◆ isLegalToInline() [3/3]

virtual bool mlir::DialectInlinerInterface::isLegalToInline ( Operation op,
Region dest,
bool  wouldBeCloned,
BlockAndValueMapping valueMapping 
) const
inlinevirtual

Returns true if the given operation 'op', that is registered to this dialect, can be inlined into the given region, false otherwise.

'wouldBeCloned' is set to true if the given 'op' is set to be cloned during the inlining process, or false if the operation is set to be moved in-place(i.e. no duplicates would be created). 'valueMapping' contains any remapped values from within the 'src' region. This can be used to examine what values may potentially replace the operands to 'op'.

Definition at line 81 of file InliningUtils.h.

◆ materializeCallConversion()

virtual Operation* mlir::DialectInlinerInterface::materializeCallConversion ( OpBuilder builder,
Value  input,
Type  resultType,
Location  conversionLoc 
) const
inlinevirtual

Attempt to materialize a conversion for a type mismatch between a call from this dialect, and a callable region.

This method should generate an operation that takes 'input' as the only operand, and produces a single result of 'resultType'. If a conversion can not be generated, nullptr should be returned. For example, this hook may be invoked in the following scenarios: func (i32) -> i32 { ... }

// Mismatched input operand ... = foo.call (input : i16) -> i32

// Mismatched result type. ... = foo.call (input : i32) -> i16

NOTE: This hook may be invoked before the 'isLegal' checks above.

Definition at line 137 of file InliningUtils.h.

Referenced by materializeConversion().

◆ processInlinedCallBlocks()

virtual void mlir::DialectInlinerInterface::processInlinedCallBlocks ( Operation call,
iterator_range< Region::iterator inlinedBlocks 
) const
inlinevirtual

Process a set of blocks that have been inlined for a call.

This callback is invoked before inlined terminator operations have been processed.

Definition at line 145 of file InliningUtils.h.

Referenced by mlir::InlinerInterface::processInlinedBlocks().

◆ shouldAnalyzeRecursively()

virtual bool mlir::DialectInlinerInterface::shouldAnalyzeRecursively ( Operation op) const
inlinevirtual

This hook is invoked on an operation that contains regions.

It should return true if the analyzer should recurse within the regions of this operation when computing legality and cost, false otherwise. The default implementation returns true.

Definition at line 90 of file InliningUtils.h.

Referenced by mlir::InlinerInterface::processInlinedBlocks().


The documentation for this class was generated from the following file: