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);
84 bool isFolderOwnedConstant(Operation *op)
const;
90 LogicalResult
tryToFold(Operation *op, SmallVectorImpl<Value> &results,
91 int maxIterations = INT_MAX);
95 LogicalResult processFoldResults(Operation *op,
96 SmallVectorImpl<Value> &results,
97 ArrayRef<OpFoldResult> foldResults);
101 Operation *tryGetOrCreateConstant(ConstantMap &uniquedConstants,
102 Dialect *dialect, Attribute value,
103 Type type, Location loc);
106 UnknownLoc erasedFoldedLocation;
117 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.
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...
bool insertKnownConstant(Operation *op, Attribute constValue={})
Tries to fold a pre-existing constant operation.
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.