forked from OSchip/llvm-project
[mlir] Canonicalizer constructor should accept disabled/enabled patterns
There is no way to programmatically configure the list of disabled and enabled patterns in the canonicalizer pass, other than the duplicate the whole pass. This patch exposes the `disabledPatterns` and `enabledPatterns` options. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D116055
This commit is contained in:
parent
25226f3e4a
commit
42ac4f3dc6
|
@ -40,9 +40,13 @@ public:
|
|||
|
||||
/// Freeze the patterns held in `patterns`, and take ownership.
|
||||
/// `disabledPatternLabels` is a set of labels used to filter out input
|
||||
/// patterns with a label in this set. `enabledPatternLabels` is a set of
|
||||
/// labels used to filter out input patterns that do not have one of the
|
||||
/// labels in this set.
|
||||
/// patterns with a debug label or debug name in this set.
|
||||
/// `enabledPatternLabels` is a set of labels used to filter out input
|
||||
/// patterns that do not have one of the labels in this set. Debug labels must
|
||||
/// be set explicitly on patterns or when adding them with
|
||||
/// `RewritePatternSet::addWithLabel`. Debug names may be empty, but patterns
|
||||
/// created with `RewritePattern::create` have their default debug name set to
|
||||
/// their type name.
|
||||
FrozenRewritePatternSet(
|
||||
RewritePatternSet &&patterns,
|
||||
ArrayRef<std::string> disabledPatternLabels = llvm::None,
|
||||
|
|
|
@ -62,8 +62,17 @@ std::unique_ptr<Pass> createBufferResultsToOutParamsPass();
|
|||
std::unique_ptr<Pass> createCanonicalizerPass();
|
||||
|
||||
/// Creates an instance of the Canonicalizer pass with the specified config.
|
||||
/// `disabledPatterns` is a set of labels used to filter out input patterns with
|
||||
/// a debug label or debug name in this set. `enabledPatterns` is a set of
|
||||
/// labels used to filter out input patterns that do not have one of the labels
|
||||
/// in this set. Debug labels must be set explicitly on patterns or when adding
|
||||
/// them with `RewritePatternSet::addWithLabel`. Debug names may be empty, but
|
||||
/// patterns created with `RewritePattern::create` have their default debug name
|
||||
/// set to their type name.
|
||||
std::unique_ptr<Pass>
|
||||
createCanonicalizerPass(const GreedyRewriteConfig &config);
|
||||
createCanonicalizerPass(const GreedyRewriteConfig &config,
|
||||
ArrayRef<std::string> disabledPatterns = llvm::None,
|
||||
ArrayRef<std::string> enabledPatterns = llvm::None);
|
||||
|
||||
/// Creates a pass to perform common sub expression elimination.
|
||||
std::unique_ptr<Pass> createCSEPass();
|
||||
|
|
|
@ -21,7 +21,13 @@ using namespace mlir;
|
|||
namespace {
|
||||
/// Canonicalize operations in nested regions.
|
||||
struct Canonicalizer : public CanonicalizerBase<Canonicalizer> {
|
||||
Canonicalizer(const GreedyRewriteConfig &config) : config(config) {}
|
||||
Canonicalizer(const GreedyRewriteConfig &config,
|
||||
ArrayRef<std::string> disabledPatterns,
|
||||
ArrayRef<std::string> enabledPatterns)
|
||||
: config(config) {
|
||||
this->disabledPatterns = disabledPatterns;
|
||||
this->enabledPatterns = enabledPatterns;
|
||||
}
|
||||
|
||||
Canonicalizer() {
|
||||
// Default constructed Canonicalizer takes its settings from command line
|
||||
|
@ -61,6 +67,9 @@ std::unique_ptr<Pass> mlir::createCanonicalizerPass() {
|
|||
|
||||
/// Creates an instance of the Canonicalizer pass with the specified config.
|
||||
std::unique_ptr<Pass>
|
||||
mlir::createCanonicalizerPass(const GreedyRewriteConfig &config) {
|
||||
return std::make_unique<Canonicalizer>(config);
|
||||
createCanonicalizerPass(const GreedyRewriteConfig &config,
|
||||
ArrayRef<std::string> disabledPatterns = llvm::None,
|
||||
ArrayRef<std::string> enabledPatterns = llvm::None) {
|
||||
return std::make_unique<Canonicalizer>(config, disabledPatterns,
|
||||
enabledPatterns);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue