14#include "mlir/IR/SymbolTable.h"
15#include "llvm/Support/Debug.h"
17#define DEBUG_TYPE "emit-reductions"
30 void beforeReduction(mlir::ModuleOp op)
override {
34 uint64_t match(Operation *op)
override {
35 if (!isa_and_nonnull<emit::EmitDialect>(op->getDialect()))
37 if (innerSymUses.hasRef(op))
42 LogicalResult rewrite(Operation *op)
override {
47 std::string getName()
const override {
return "emit-op-eraser"; }
48 bool acceptSizeIncrease()
const override {
return true; }
61struct EmitReducePatternDialectInterface
64 void populateReducePatterns(ReducePatternSet &patterns)
const override {
65 patterns.
add<EmitOpEraser, 1000>();
71 mlir::DialectRegistry ®istry) {
72 registry.addExtension(+[](MLIRContext *ctx, EmitDialect *dialect) {
73 dialect->addInterfaces<EmitReducePatternDialectInterface>();
void registerReducePatternDialectInterface(mlir::DialectRegistry ®istry)
Register the Emit Reduction pattern dialect interface to the given registry.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
A dialect interface to provide reduction patterns to a reducer tool.
ReducePatternDialectInterface(Dialect *dialect)
An abstract reduction pattern.
A helper struct that scans a root operation and all its nested operations for InnerRefAttrs.