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/Transforms/GreedyPatternRewriteDriver.h" 21 22 #define PASS_NAME "test-lower-to-arm-neon" 23 24 using namespace mlir; 25 using namespace mlir::arm_neon; 26 27 namespace { 28 struct TestLowerToArmNeon 29 : public PassWrapper<TestLowerToArmNeon, OperationPass<func::FuncOp>> { 30 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLowerToArmNeon) 31 32 StringRef getArgument() const final { return PASS_NAME; } 33 StringRef getDescription() const final { return "Tests lower to arm Neon."; } 34 TestLowerToArmNeon() = default; 35 TestLowerToArmNeon(const TestLowerToArmNeon &pass) = default; 36 37 void getDependentDialects(DialectRegistry ®istry) const override { 38 registry.insert<arm_neon::ArmNeonDialect>(); 39 } 40 41 void runOnOperation() override; 42 }; 43 44 } // namespace 45 46 void TestLowerToArmNeon::runOnOperation() { 47 MLIRContext *context = &getContext(); 48 RewritePatternSet patterns(context); 49 populateLowerContractionToSMMLAPatternPatterns(patterns); 50 if (failed(applyPatternsGreedily(getOperation(), std::move(patterns)))) 51 return signalPassFailure(); 52 } 53 54 namespace mlir { 55 namespace test { 56 57 void registerTestLowerToArmNeon() { PassRegistration<TestLowerToArmNeon>(); } 58 59 } // namespace test 60 } // namespace mlir 61