My Project
|
#include <FoldUtils.h>
Public Member Functions | |
OperationFolder (MLIRContext *ctx) | |
LogicalResult | tryToFold (Operation *op, function_ref< void(Operation *)> processGeneratedConstants=nullptr, function_ref< void(Operation *)> preReplaceAction=nullptr) |
void | notifyRemoval (Operation *op) |
template<typename OpTy , typename... Args> | |
void | create (OpBuilder &builder, SmallVectorImpl< Value > &results, Location location, Args &&... args) |
template<typename OpTy , typename... Args> | |
std::enable_if< OpTy::template hasTrait< OpTrait::OneResult >), Value >::type | create (OpBuilder &builder, Location location, Args &&... args) |
Overload to create or fold a single result operation. More... | |
template<typename OpTy , typename... Args> | |
std::enable_if< OpTy::template hasTrait< OpTrait::ZeroResult >), OpTy >::type | create (OpBuilder &builder, Location location, Args &&... args) |
Overload to create or fold a zero result operation. More... | |
A utility class for folding operations, and unifying duplicated constants generated along the way.
|
inline |
|
inline |
Create an operation of specific op type with the given builder, and immediately try to fold it. This function populates 'results' with the results after folding the operation.
|
inline |
Overload to create or fold a single result operation.
|
inline |
Overload to create or fold a zero result operation.
void OperationFolder::notifyRemoval | ( | Operation * | op | ) |
Notifies that the given constant op
should be remove from this OperationFolder's internal bookkeeping.
Note: this method must be called if a constant op is to be deleted externally to this OperationFolder. op
must be a constant op.
Notifies that the given constant op
should be remove from this OperationFolder's internal bookkeeping.
LogicalResult OperationFolder::tryToFold | ( | Operation * | op, |
function_ref< void(Operation *)> | processGeneratedConstants = nullptr , |
||
function_ref< void(Operation *)> | preReplaceAction = nullptr |
||
) |
Tries to perform folding on the given op
, including unifying deduplicated constants. If successful, replaces op
's uses with folded results, and returns success. preReplaceAction
is invoked on op
before it is replaced. 'processGeneratedConstants' is invoked for any new operations generated when folding. If the op was completely folded it is erased.