14 #ifndef MLIR_TRANSFORMS_FOLDUTILS_H
15 #define MLIR_TRANSFORMS_FOLDUTILS_H
36 : erasedFoldedLocation(UnknownLoc::
get(ctx)), interfaces(ctx),
37 rewriter(ctx, listener) {}
77 DenseMap<std::tuple<Dialect *, Attribute, Type>, Operation *>;
81 bool isFolderOwnedConstant(Operation *op)
const;
85 LogicalResult
tryToFold(Operation *op, SmallVectorImpl<Value> &results);
89 LogicalResult processFoldResults(Operation *op,
90 SmallVectorImpl<Value> &results,
91 ArrayRef<OpFoldResult> foldResults);
95 Operation *tryGetOrCreateConstant(ConstantMap &uniquedConstants,
96 Dialect *dialect, Attribute value,
97 Type type, Location loc);
100 UnknownLoc erasedFoldedLocation;
104 DenseMap<Region *, ConstantMap> foldScopes;
108 DenseMap<Operation *, SmallVector<Dialect *, 2>> referencedDialects;
111 DialectInterfaceCollection<DialectFoldInterface> interfaces;
Attributes are known-constant values of operations.
MLIRContext is the top-level object for a collection of MLIR operations.
A utility class for folding operations, and unifying duplicated constants generated along the way.
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)
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.
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...
This class represents a listener that may be used to hook into various actions within an OpBuilder.