MLIR  20.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 
18 #include "mlir/Pass/Pass.h"
20 
21 namespace mlir {
22 #define GEN_PASS_DEF_CONVERTFUNCTOEMITC
23 #include "mlir/Conversion/Passes.h.inc"
24 } // namespace mlir
25 
26 using namespace mlir;
27 
28 namespace {
29 struct ConvertFuncToEmitC
30  : public impl::ConvertFuncToEmitCBase<ConvertFuncToEmitC> {
31  void runOnOperation() override;
32 };
33 } // namespace
34 
35 void ConvertFuncToEmitC::runOnOperation() {
36  ConversionTarget target(getContext());
37 
38  target.addLegalDialect<emitc::EmitCDialect>();
39  target.addIllegalOp<func::CallOp, func::FuncOp, func::ReturnOp>();
40 
41  RewritePatternSet patterns(&getContext());
43 
44  if (failed(
45  applyPartialConversion(getOperation(), target, std::move(patterns))))
46  signalPassFailure();
47 }
static MLIRContext * getContext(OpFoldResult val)
This class describes a specific conversion target.
Include the generated interface declarations.
void populateFuncToEmitCPatterns(RewritePatternSet &patterns)
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Below we define several entry points for operation conversion.