[clang-tidy][NFC]remove deps of clang in clang tidy test (#116588)
[llvm-project.git] / mlir / test / lib / Transforms / TestCommutativityUtils.cpp
blob2ec0334ae0d05a1191d405ae55e3175097e162cd
1 //===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This pass tests the functionality of the commutativity utility pattern.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Transforms/CommutativityUtils.h"
15 #include "TestDialect.h"
16 #include "mlir/Pass/Pass.h"
17 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
19 using namespace mlir;
21 namespace {
23 struct CommutativityUtils
24 : public PassWrapper<CommutativityUtils, OperationPass<func::FuncOp>> {
25 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
27 StringRef getArgument() const final { return "test-commutativity-utils"; }
28 StringRef getDescription() const final {
29 return "Test the functionality of the commutativity utility";
32 void runOnOperation() override {
33 auto func = getOperation();
34 auto *context = &getContext();
36 RewritePatternSet patterns(context);
37 populateCommutativityUtilsPatterns(patterns);
39 (void)applyPatternsAndFoldGreedily(func, std::move(patterns));
42 } // namespace
44 namespace mlir {
45 namespace test {
46 void registerCommutativityUtils() { PassRegistration<CommutativityUtils>(); }
47 } // namespace test
48 } // namespace mlir