MLIR 22.0.0git
TosaToSCFPass.cpp
Go to the documentation of this file.
1//===- TosaToSCFPass.cpp - Lowering Tosa to SCF 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 Tosa operations to the SCF dialect.
10//
11//===----------------------------------------------------------------------===//
12
14
22
23namespace mlir {
24#define GEN_PASS_DEF_TOSATOSCFPASS
25#include "mlir/Conversion/Passes.h.inc"
26} // namespace mlir
27
28using namespace mlir;
29using namespace tosa;
30
31namespace {
32struct TosaToSCF : public impl::TosaToSCFPassBase<TosaToSCF> {
33public:
34 void runOnOperation() override {
35 RewritePatternSet patterns(&getContext());
36 ConversionTarget target(getContext());
37 target.addLegalDialect<tensor::TensorDialect, scf::SCFDialect>();
38 target.addIllegalOp<tosa::IfOp, tosa::ScatterOp, tosa::WhileOp>();
39 target.markUnknownOpDynamicallyLegal([](Operation *) { return true; });
40
41 auto *op = getOperation();
43 if (failed(applyPartialConversion(op, target, std::move(patterns))))
44 signalPassFailure();
45 }
46};
47} // namespace
48
b getContext())
This class represents a pass manager that runs passes on either a specific operation type,...
Definition PassManager.h:46
void addNestedPass(std::unique_ptr< Pass > pass)
Add the given pass to a nested pass manager for the given operation kind OpT.
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:561
void addTosaToSCFPasses(OpPassManager &pm)
Populates passes to convert from TOSA to SCF.
void populateTosaToSCFConversionPatterns(RewritePatternSet *patterns)
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
std::unique_ptr<::mlir::Pass > createTosaToSCFPass()