Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Pass/Pass.h
Show First 20 Lines • Show All 335 Lines • ▼ Show 20 Lines | template <typename T> struct FunctionPass : public OperationPass<T, FuncOp> { | ||||
virtual void runOnFunction() = 0; | virtual void runOnFunction() = 0; | ||||
/// The polymorphic API that runs the pass over the currently held operation. | /// The polymorphic API that runs the pass over the currently held operation. | ||||
void runOnOperation() final { | void runOnOperation() final { | ||||
if (!getFunction().isExternal()) | if (!getFunction().isExternal()) | ||||
runOnFunction(); | runOnFunction(); | ||||
} | } | ||||
/// Return the current module being transformed. | /// Return the current function being transformed. | ||||
FuncOp getFunction() { return this->getOperation(); } | FuncOp getFunction() { return this->getOperation(); } | ||||
}; | }; | ||||
/// A model for providing module pass specific utilities. | |||||
/// | |||||
/// Derived module passes are expected to provide the following: | |||||
/// - A 'void runOnModule()' method. | |||||
template <typename T> struct ModulePass : public OperationPass<T, ModuleOp> { | |||||
/// The polymorphic API that runs the pass over the currently held module. | |||||
virtual void runOnModule() = 0; | |||||
/// The polymorphic API that runs the pass over the currently held operation. | |||||
void runOnOperation() final { runOnModule(); } | |||||
/// Return the current module being transformed. | |||||
ModuleOp getModule() { return this->getOperation(); } | |||||
}; | |||||
} // end namespace mlir | } // end namespace mlir | ||||
#endif // MLIR_PASS_PASS_H | #endif // MLIR_PASS_PASS_H |