1//===- TestLowerToArmNeon.cpp - Test lowering to ArmNeon as a sink pass -===//
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 file implements a pass for testing the lowering to ArmNeon as a
10// generally usable sink pass.
11//
12//===----------------------------------------------------------------------===//
13
14#include "mlir/Dialect/ArmNeon/ArmNeonDialect.h"
15#include "mlir/Dialect/ArmNeon/Transforms.h"
16#include "mlir/Dialect/Func/IR/FuncOps.h"
17#include "mlir/IR/PatternMatch.h"
18#include "mlir/Pass/Pass.h"
19#include "mlir/Pass/PassManager.h"
20#include "mlir/Support/LogicalResult.h"
21#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
22
23#define PASS_NAME "test-lower-to-arm-neon"
24
25using namespace mlir;
26using namespace mlir::arm_neon;
27
28namespace {
29struct TestLowerToArmNeon
30 : public PassWrapper<TestLowerToArmNeon, OperationPass<func::FuncOp>> {
31 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLowerToArmNeon)
32
33 StringRef getArgument() const final { return PASS_NAME; }
34 StringRef getDescription() const final { return "Tests lower to arm Neon."; }
35 TestLowerToArmNeon() = default;
36 TestLowerToArmNeon(const TestLowerToArmNeon &pass) = default;
37
38 void getDependentDialects(DialectRegistry &registry) const override {
39 registry.insert<arm_neon::ArmNeonDialect>();
40 }
41
42 void runOnOperation() override;
43};
44
45} // namespace
46
47void TestLowerToArmNeon::runOnOperation() {
48 MLIRContext *context = &getContext();
49 RewritePatternSet patterns(context);
50 populateLowerContractionToSMMLAPatternPatterns(patterns);
51 if (failed(applyPatternsAndFoldGreedily(getOperation(), std::move(patterns))))
52 return signalPassFailure();
53}
54
55namespace mlir {
56namespace test {
57
58void registerTestLowerToArmNeon() { PassRegistration<TestLowerToArmNeon>(); }
59
60} // namespace test
61} // namespace mlir
62

source code of mlir/test/lib/Dialect/ArmNeon/TestLowerToArmNeon.cpp