My Project
Public Member Functions | List of all members
mlir::OperationFolder Class Reference

#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...
 

Detailed Description

A utility class for folding operations, and unifying duplicated constants generated along the way.

Constructor & Destructor Documentation

◆ OperationFolder()

mlir::OperationFolder::OperationFolder ( MLIRContext ctx)
inline

Member Function Documentation

◆ create() [1/3]

template<typename OpTy , typename... Args>
void mlir::OperationFolder::create ( OpBuilder builder,
SmallVectorImpl< Value > &  results,
Location  location,
Args &&...  args 
)
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.

◆ create() [2/3]

template<typename OpTy , typename... Args>
std::enable_if<OpTy::template hasTrait<OpTrait::OneResult>), Value>::type mlir::OperationFolder::create ( OpBuilder builder,
Location  location,
Args &&...  args 
)
inline

Overload to create or fold a single result operation.

◆ create() [3/3]

template<typename OpTy , typename... Args>
std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResult>), OpTy>::type mlir::OperationFolder::create ( OpBuilder builder,
Location  location,
Args &&...  args 
)
inline

Overload to create or fold a zero result operation.

◆ notifyRemoval()

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.

◆ tryToFold()

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.


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