14#ifndef MLIR_TRANSFORMS_FOLDUTILS_H
15#define MLIR_TRANSFORMS_FOLDUTILS_H
36 : erasedFoldedLocation(UnknownLoc::
get(ctx)), interfaces(ctx),
37 rewriter(ctx, listener) {}
46 int maxIterations = INT_MAX);
95 bool isFolderOwnedConstant(Operation *op)
const;
101 LogicalResult
tryToFold(Operation *op, SmallVectorImpl<Value> &results,
102 int maxIterations = INT_MAX);
106 LogicalResult processFoldResults(Operation *op,
107 SmallVectorImpl<Value> &results,
108 ArrayRef<OpFoldResult> foldResults);
112 Operation *tryGetOrCreateConstant(ConstantMap &uniquedConstants,
113 Dialect *dialect, Attribute value,
114 Type type, Location loc);
117 UnknownLoc erasedFoldedLocation;
128 DialectInterfaceCollection<DialectFoldInterface> interfaces;
Attributes are known-constant values of operations.
MLIRContext is the top-level object for a collection of MLIR operations.
Value getOrCreateConstant(Block *block, Dialect *dialect, Attribute value, Type type)
Get or create a constant for use in the specified block.
void clear()
Clear out any constants cached inside of the folder.
ConstantInsertionResult
The effect of inserting a known constant on the IR.
@ Hoisted
The operation was retained but moved to the insertion point.
@ Unchanged
The operation was retained without modifying the IR.
@ Replaced
The operation was replaced with an existing constant and erased.
ConstantInsertionResult insertKnownConstant(Operation *op, Attribute constValue={})
Tries to fold a pre-existing constant operation.
LogicalResult tryToFold(Operation *op, bool *inPlaceUpdate=nullptr, int maxIterations=INT_MAX)
Tries to perform folding on the given op, including unifying deduplicated constants.
void notifyRemoval(Operation *op)
Notifies that the given constant op should be remove from this OperationFolder's internal bookkeeping...
OperationFolder(MLIRContext *ctx, OpBuilder::Listener *listener=nullptr)
Operation is the basic unit of execution within MLIR.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap
This class represents a listener that may be used to hook into various actions within an OpBuilder.