[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / mlir / lib / Conversion / TosaToMLProgram / TosaToMLProgramPass.cpp
blob8c39f5e8a63631d3b3ec6c47b9f751de3a50f9f5
1 //===- TosaToMLProgramPass.cpp - Lowering Tosa to MLProgram Dialect--------===//
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 transformation pass legalizes the TOSA dialect to the MLProgram dialect.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Conversion/TosaToMLProgram/TosaToMLProgram.h"
14 #include "mlir/Dialect/MLProgram/IR/MLProgram.h"
15 #include "mlir/Dialect/Tosa/IR/TosaOps.h"
16 #include "mlir/Dialect/Tosa/Transforms/Passes.h"
17 #include "mlir/IR/PatternMatch.h"
18 #include "mlir/Pass/PassManager.h"
19 #include "mlir/Transforms/DialectConversion.h"
21 namespace mlir {
22 #define GEN_PASS_DEF_TOSATOMLPROGRAM
23 #include "mlir/Conversion/Passes.h.inc"
24 } // namespace mlir
26 using namespace mlir;
27 using namespace tosa;
29 namespace {
30 struct TosaToMLProgram : public impl::TosaToMLProgramBase<TosaToMLProgram> {
31 public:
32 void runOnOperation() override {
33 auto *context = &getContext();
34 auto moduleOp = getOperation();
36 RewritePatternSet patterns(context);
37 ConversionTarget target(*context);
38 target.addIllegalOp<tosa::VariableOp, tosa::VariableReadOp,
39 tosa::VariableWriteOp>();
40 target.markUnknownOpDynamicallyLegal([](Operation *) { return true; });
42 mlir::tosa::populateTosaToMLProgramConversionPatterns(&patterns);
44 if (failed(applyPartialConversion(moduleOp, target, std::move(patterns))))
45 signalPassFailure();
48 } // namespace