[Mlir-commits] [mlir] [mlir][EmitC] Add pass that combines all available emitc conversions (PR #117549)
Marius Brehler
llvmlistbot at llvm.org
Mon Nov 25 07:04:08 PST 2024
================
@@ -0,0 +1,82 @@
+//===- ConvertToEmitCPass.cpp - MLIR EmitC Conversion ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h"
+#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
+#include "mlir/Conversion/FuncToEmitC/FuncToEmitC.h"
+#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h"
+#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/EmitC/IR/EmitC.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
+#include "mlir/Dialect/SCF/IR/SCF.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Rewrite/FrozenRewritePatternSet.h"
+#include "mlir/Transforms/DialectConversion.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+#define DEBUG_TYPE "convert-to-emitc"
+
+namespace mlir {
+#define GEN_PASS_DEF_CONVERTTOEMITCPASS
+#include "mlir/Conversion/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+namespace {
+
+void populateConvertToEmitCTypeConverter(TypeConverter &typeConverter) {
+ typeConverter.addConversion([](Type type) { return type; });
+ populateMemRefToEmitCTypeConversion(typeConverter);
+}
+
+/// Populate patterns for each dialect.
+void populateConvertToEmitCPatterns(TypeConverter &typeConverter,
+ RewritePatternSet &patterns) {
+ populateArithToEmitCPatterns(typeConverter, patterns);
+ populateFuncToEmitCPatterns(patterns);
+ populateMemRefToEmitCConversionPatterns(patterns, typeConverter);
+ populateSCFToEmitCConversionPatterns(patterns);
+ populateFunctionOpInterfaceTypeConversionPattern<emitc::FuncOp>(
+ patterns, typeConverter);
+}
----------------
marbre wrote:
May want to move those to a separate `ConvertToEmitC.cpp` similar to what we do for `MemRefToEmitC`, `FuncToEmitC` and `ArithToEmitC`?
https://github.com/llvm/llvm-project/pull/117549
More information about the Mlir-commits
mailing list