MLIR 23.0.0git
FuncToEmitCPass.cpp
Go to the documentation of this file.
1//===- FuncToEmitCPass.cpp - Func to EmitC Pass -----------------*- C++ -*-===//
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 to convert the Func dialect to the EmitC dialect.
10//
11//===----------------------------------------------------------------------===//
12
14
19#include "mlir/Pass/Pass.h"
21
22namespace mlir {
23#define GEN_PASS_DEF_CONVERTFUNCTOEMITC
24#include "mlir/Conversion/Passes.h.inc"
25} // namespace mlir
26
27using namespace mlir;
28
29namespace {
30struct ConvertFuncToEmitC
31 : public impl::ConvertFuncToEmitCBase<ConvertFuncToEmitC> {
32 using Base::Base;
33 void runOnOperation() override;
34};
35} // namespace
36
37void ConvertFuncToEmitC::runOnOperation() {
38 ConversionTarget target(getContext());
39
40 target.addLegalDialect<emitc::EmitCDialect>();
41 target.addIllegalOp<func::CallOp, func::FuncOp, func::ReturnOp>();
42
43 RewritePatternSet patterns(&getContext());
44
45 EmitCTypeConverter typeConverter(&getContext());
46
47 populateFuncToEmitCPatterns(typeConverter, patterns, this->lowerToCpp);
48
49 if (failed(
50 applyPartialConversion(getOperation(), target, std::move(patterns))))
51 signalPassFailure();
52}
b getContext())
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:717
Include the generated interface declarations.
void populateFuncToEmitCPatterns(const TypeConverter &typeConverter, RewritePatternSet &patterns, bool lowerToCpp=true)