48 lines · cpp
1//===- TestSimplification.cpp - Test simplification -----------------------===//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#include "mlir/Dialect/Arith/IR/Arith.h"10#include "mlir/Dialect/Shard/IR/ShardDialect.h"11#include "mlir/Dialect/Shard/Transforms/Simplifications.h"12#include "mlir/IR/SymbolTable.h"13#include "mlir/Pass/Pass.h"14#include "mlir/Transforms/GreedyPatternRewriteDriver.h"15 16using namespace mlir;17 18namespace {19struct TestShardSimplificationsPass20 : public PassWrapper<TestShardSimplificationsPass, OperationPass<>> {21 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestShardSimplificationsPass)22 23 void runOnOperation() override;24 void getDependentDialects(DialectRegistry ®istry) const override {25 registry.insert<arith::ArithDialect, shard::ShardDialect>();26 }27 StringRef getArgument() const final { return "test-grid-simplifications"; }28 StringRef getDescription() const final { return "Test grid simplifications"; }29};30} // namespace31 32void TestShardSimplificationsPass::runOnOperation() {33 RewritePatternSet patterns(&getContext());34 SymbolTableCollection symbolTableCollection;35 shard::populateSimplificationPatterns(patterns, symbolTableCollection);36 [[maybe_unused]] LogicalResult status =37 applyPatternsGreedily(getOperation(), std::move(patterns));38 assert(succeeded(status) && "Rewrite patters application did not converge.");39}40 41namespace mlir {42namespace test {43void registerTestShardSimplificationsPass() {44 PassRegistration<TestShardSimplificationsPass>();45}46} // namespace test47} // namespace mlir48