49 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// This pass tests the functionality of the commutativity utility pattern.10//11//===----------------------------------------------------------------------===//12 13#include "mlir/Transforms/CommutativityUtils.h"14 15#include "TestDialect.h"16#include "mlir/Pass/Pass.h"17#include "mlir/Transforms/GreedyPatternRewriteDriver.h"18 19using namespace mlir;20 21namespace {22 23struct CommutativityUtils24 : public PassWrapper<CommutativityUtils, OperationPass<func::FuncOp>> {25 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)26 27 StringRef getArgument() const final { return "test-commutativity-utils"; }28 StringRef getDescription() const final {29 return "Test the functionality of the commutativity utility";30 }31 32 void runOnOperation() override {33 auto func = getOperation();34 auto *context = &getContext();35 36 RewritePatternSet patterns(context);37 populateCommutativityUtilsPatterns(patterns);38 39 (void)applyPatternsGreedily(func, std::move(patterns));40 }41};42} // namespace43 44namespace mlir {45namespace test {46void registerCommutativityUtils() { PassRegistration<CommutativityUtils>(); }47} // namespace test48} // namespace mlir49